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
0
480
Ruby Require
by 吕小荣
Gene Wu
December 20, 2014
Tweet
Share
More Decks by Gene Wu
See All by Gene Wu
API Documentation with Swagger UI
genewoo
0
690
新手学习Web开发经验分享
genewoo
2
670
Other Decks in Technology
See All in Technology
スケーリングを封じられたEC2を救いたい
senseofunity129
0
120
トイルを超えたCREは何屋になるのか
bengo4com
0
100
MIX AUDIO EN BROADCAST
ralpherick
0
130
MCPで決済に楽にする
mu7889yoon
0
160
BFCacheを活用して無限スクロールのUX を改善した話
apple_yagi
0
130
OpenClawでPM業務を自動化
knishioka
2
340
開発チームとQAエンジニアの新しい協業モデル -年末調整開発チームで実践する【QAリード施策】-
qa
0
470
Why we keep our community?
kawaguti
PRO
0
340
OCI技術資料 : ロード・バランサ 概要 - FLB・NLB共通
ocise
4
27k
ブラックボックス化したMLシステムのVertex AI移行 / mlops_community_62
visional_engineering_and_design
1
230
GitHub Copilot CLI で Azure Portal to Bicep
tsubakimoto_s
0
300
Sansanの認証基盤を支えるアーキテクチャとその振り返り
sansantech
PRO
1
120
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
160
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
260
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
990
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
310
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Context Engineering - Making Every Token Count
addyosmani
9
780
Done Done
chrislema
186
16k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
190
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
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