Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Ruby Require
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Gene Wu
December 20, 2014
Technology
490
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ruby Require
by 吕小荣
Gene Wu
December 20, 2014
More Decks by Gene Wu
See All by Gene Wu
API Documentation with Swagger UI
genewoo
0
710
新手学习Web开发经验分享
genewoo
2
690
Other Decks in Technology
See All in Technology
OpenTelemetryのメトリクスをCloudWatchに送ってPromQLで見てみた
ota1022
0
140
20260912_スクラムにジェネラリストは必要か
ryugen04
0
390
NW運用でNWトポロジ可視化ツールに期待すること/shumoku-meetup1
corestate55
2
120
The Agent Builder Loop from Daily Work to OSS
minorun365
PRO
3
150
SQL文一行も書けない人事がCortexもろもろを使って人事業務を楽にしてみる
ponponmikankan
1
230
人間はどの意思決定を手放せるのか
kawasima
7
2.3k
目の前の楽しいが人生を変える - コミュニティの螺旋の歩き方と楽しむコツ / change your life
soudai
PRO
4
540
AIオーケストレーションを活用した 開発ワークフローの設計と実践
bqnq
0
170
Tab5をRubyで動くパソコンにする
kishima
2
360
絵ではじめるKubernetesセキュリティ
aoi1
3
230
株式会社シーエーシー エンジニア向け会社紹介資料
cac
0
57k
GoCon2026 - Open Source, Open World
sanposhiho
4
3.5k
Featured
See All Featured
Embracing the Ebb and Flow
colly
88
5.2k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
Bash Introduction
62gerente
615
220k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
How GitHub (no longer) Works
holman
316
150k
Navigating Team Friction
lara
192
16k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
410
So, you think you're a good person
axbom
PRO
2
2.2k
Scaling GitHub
holman
464
140k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Code Review Best Practice
trishagee
74
20k
Transcript
Ruby require 吕⼩小荣
医⽣生 产品狗 程序员 @xiaoronglv
2.1.5 > require 'json' => true 2.1.5 > JSON.parse "{\"a\":1}"
=> {"a"=>1}
⽅方法?关键字?
where?
咖啡机
> require 'coffee_machine'
$LOAD_PATH
拼接 /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb >
require 'coffee_machine'
失败
添加 $LOAD_PATH
/coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb /coffee_machine.rb >
require 'coffee_machine' => true
$LOADED_FEATURES
$LOADED_FEATURES > puts $LOADED_FEATURES ... ..... /…/…coffee_machine.rb • 全局变量 •
数组 • 已经require过的⽂文件 • 绝对地址(?) • 第⼆二次 require 时,直接 false
None
⼆二
None
require 'active_support'
/active_support.rb /active_support.rb /active_support.rb /active_support.rb /active_support.rb /active_support.rb /active_support.rb /active_support.rb require 'active_support'
=> it should raise LoadError, right?
require 'active_support' => true
RubyGems RubyGems was created in about November 2003 and is
now part of the standard library from Ruby version 1.9.
覆盖 require • load from the existing Ruby load path
• activate gem
activate gem
1.9.3 > spec = Gem::Specification.find_by_path('active_support') => #<Gem::Specification:0x80442624 activesupport-4.1.4> 1.9.3-p547 :005
> spec.activate => true active gem
Vs
None
Bundler 如何 require 它的 gems? 三
Gemfile
Gemfile
$LOAD_PATH
$LOAD_PATH > require 'bundler/setup' => true
$LOAD_PATH
将 Gemfile.lock 中的 所有gem 添加到 $LOAD_PATH中
Bundler.require(:default, development)
四 Rails 如何使⽤用 bundler require 它的 gems?
config.ru
enviroment.rb
application.rb
boot.rb
Learning • 与⼤大⽜牛 Pair • 参与多元项⺫⽬目
Thanks