如何忽略每台计算机的 gem?
How to ignore a gem per computer?
出于某种原因,一些开发人员使用 gem 而其他开发人员不使用。
有时我会遇到这样的代码:
if File.exist?('USE_MY_GEM')
gem 'my_gem'
end
和USE_MY_GEM
写成.gitignore
。但我认为这不是很好的做法。
如何为特定机器关闭/打开 gem?
我会选择 Bundler groups feature。这样 Gemfile
可能包含组,包含一些开发人员使用的这些多余的 gem[s]。
来自文档:
Restrict the groups of gems that you want to add to the load path. Only gems in these groups will be require'able:
require 'rubygems'
require 'bundler'
Bundler.setup(:default, :ci)
require 'nokogiri'
好吧,解决方案很明显。
我们可以按照通常管理群组的方式管理 gem。
只需将 gem 包裹在一个组中并添加 --without
选项:
Gemfile
group :my_gem do
gem 'my_gem'
end
在控制台中:
$ bundle install --without my_gem
确保 .gitignore
包含:
/.bundle
出于某种原因,一些开发人员使用 gem 而其他开发人员不使用。
有时我会遇到这样的代码:
if File.exist?('USE_MY_GEM')
gem 'my_gem'
end
和USE_MY_GEM
写成.gitignore
。但我认为这不是很好的做法。
如何为特定机器关闭/打开 gem?
我会选择 Bundler groups feature。这样 Gemfile
可能包含组,包含一些开发人员使用的这些多余的 gem[s]。
来自文档:
Restrict the groups of gems that you want to add to the load path. Only gems in these groups will be require'able:
require 'rubygems' require 'bundler' Bundler.setup(:default, :ci) require 'nokogiri'
好吧,解决方案很明显。
我们可以按照通常管理群组的方式管理 gem。
只需将 gem 包裹在一个组中并添加 --without
选项:
Gemfile
group :my_gem do
gem 'my_gem'
end
在控制台中:
$ bundle install --without my_gem
确保 .gitignore
包含:
/.bundle