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
プラットフォームエンジニア ワークショップ/ platform-workshop
databricksjapan
0
110
エンジニアは生成AIと どのように向き合うべきか? ことばの意味という観点から
verypluming
3
280
Javaコミュニティをもっと楽しむための9箇条
takasyou
0
370
RubyでRuby拡張を書いたらRubyより35倍速になったってどういうこと??
kazuho
3
710
Typiaで配信JSONの安全性を構造的に担保する(TSKaigi2026)
righttouch
PRO
1
190
GitHub Copilot のこれまでとこれから: From Copilot to Collaborative Agents
yuriemori
1
230
権限管理設計を完全に理解した
rsugi
2
230
Java正規表現エンジン(NFA)の仕組みと パフォーマンスを維持するための最適化手法
takeuchi_132917
0
140
データ分析基盤の信頼を支える視点と設計
yuki_saito
2
750
コードレビューを制するチームがソフトウェアデリバリーのフローを制す / Beyond Code Review: Distributing Its Responsibilities Across the SDLC
mtx2s
1
210
大規模災害時でも高い信頼性を維持するアプリケーション基盤の実現/nikkei-tech-talk46
nikkei_engineer_recruiting
0
110
基礎から解説!Icebergで紐解くSnowflake×Databricks連携の現在地
cm_yasuhara
0
360
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
3.7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.4k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
240
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.1k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
KATA
mclloyd
PRO
35
15k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
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