在 Gemfile 的组中指定类似的配置
Specify similar configuration in groups of a Gemfile
我们有一个 rails 应用程序,我们在其中将应用程序拆分为引擎。现在我们有很多引擎,所有引擎都必须指向开发或掌握,比如
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
我已经浏览了打包程序文档,但它只指定了如何为每个 gem 添加分支。有没有办法在没有做类似的配置。 gems.
毕竟 Gemfile
由普通的 Ruby 组成。你可以这样做:
%w(a b c d).each do |repo|
gem repo,
:git => "https://github.com/abc/#{repo}.git",
:branch => 'develop'
end
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
我们有一个 rails 应用程序,我们在其中将应用程序拆分为引擎。现在我们有很多引擎,所有引擎都必须指向开发或掌握,比如
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
我已经浏览了打包程序文档,但它只指定了如何为每个 gem 添加分支。有没有办法在没有做类似的配置。 gems.
Gemfile
由普通的 Ruby 组成。你可以这样做:
%w(a b c d).each do |repo|
gem repo,
:git => "https://github.com/abc/#{repo}.git",
:branch => 'develop'
end
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