在Gemfile設置gem

bundle init 命令在當前目錄下生存Gemfile文件。

  1. 默認情況下,執行bundle install的時候,自動去Gemfile中的sources中去下載gem。

  2. 如果你的gem需要從私有gem server 獲取 使用source

gem 'my_gem', '1.0', :source => 'https://gems.example.com'
如果,多個gem需要從相同的server獲取使用source塊組織
source 'https://gems.example.com' do
 gem 'my_gem', '1.0'
 gem 'another_gem', '1.2.1'
end

  1. 使用git repositories 作為source。使用':tag'、':branch'、'ref'聲明需要檢出的分支,默認的是msater分支。

gem 'nokogiri', :git => 'https://github.com/tenderlove/nokogiri.git', :branch => '1.4'

  1. 直接使用文件系統未打包的gem, 使用path

gem 'extracted_library', :path => './vendor/extracted_library'

如果你想直接使用你文件系統中(你當前使用的操作系統)的多個gem,設置一個全局的'path'參數,將自動加載.

path 'components' do
gem 'admin_ui'
gem 'public_ui'
end

參考鏈接http://bundler.io/v1.11/gemfile.html

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容