2015-02-10 68 views
0

我們有一個rails應用程序,我們已經將應用程序拆分爲引擎。現在我們有很多的發動機和所有的人必須要麼點被指定爲開發或主,像指定Gemfile組中的類似配置

gem 'a', :git => "https://github.com/abc/a.git", :branch => 'develop' 
gem 'b', :git => "https://github.com/abc/b.git", :branch => 'develop' 
gem 'c', :git => "https://github.com/abc/c.git", :branch => 'develop' 
gem 'd', :git => "https://github.com/abc/d.git", :branch => 'develop' 

我想他們組和組分支的基礎上,這樣的事情:

group :development, :branch => 'develop' do 
    gem 'a', :git => "https://github.com/abc/a.git" 
    gem 'b', :git => "https://github.com/abc/b.git" 
    gem 'c', :git => "https://github.com/abc/c.git" 
    gem 'd', :git => "https://github.com/abc/d.git" 
end 

我已經通過捆綁器文檔,但它只指定如何添加分支每個寶石。有沒有辦法在no上做類似的配置?的寶石。

回答

1

Gemfile畢竟由普通的Ruby組成。你可以這樣做:

%w(a b c d).each do |repo| 
    gem repo, 
    :git => "https://github.com/abc/#{repo}.git", 
    :branch => 'develop' 
end 
1

Gemfile有他自己的DSL。但是沒有什麼能阻止你使用Ruby:

branch = 'develop' 

group :development do 
    %(a b c d).each do |lib| 
    gem lib, :git => "https://github.com/abc/#{lib}.git", :branch => branch 
    end 
end