Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ruby Require
Search
Gene Wu
December 20, 2014
Technology
480
0
Share
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
700
新手学习Web开发经验分享
genewoo
2
680
Other Decks in Technology
See All in Technology
なぜハノーバーメッセに行くべきなのか 〜初参加だから語れること〜
tanakaseiya
0
160
イベントで大活躍する電子ペーパー名札 〜その3〜 / ビジュアルプログラミングIoTLT vol.23
you
PRO
0
160
大規模災害時でも高い信頼性を維持するアプリケーション基盤の実現/nikkei-tech-talk46
nikkei_engineer_recruiting
0
110
Claude Code x Accounting
kawaguti
PRO
1
340
ポスター発表&デモと総括 / Poster Presentations & Demonstrations and Summary
ks91
PRO
0
150
地元にいないローカルオーガナイザーの立ち回り
uvb_76
0
100
layerx-fde-practices
cipepser
6
2.8k
はじめてのAI-DLC
yoshidashingo
2
610
Don't Just Patch — MOTTAINAI! Learn Security from Laravel CVE Diffs
codmoninc
0
150
インフラが苦手でも大丈夫! 紙芝居 Kubernetes -WWGT 10周年編-
aoi1
1
290
Agentic Design Patterns
glaforge
0
250
Claude Codeですべての日常業務を爆速化しよう!
minorun365
PRO
16
15k
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1370
210k
The Spectacular Lies of Maps
axbom
PRO
1
770
How STYLIGHT went responsive
nonsquared
100
6.1k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
150
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
130
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.8k
WENDY [Excerpt]
tessaabrams
11
37k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
200
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
460
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
580
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