如何让 'bundle init' 默认包含宝石?
How can I make 'bundle init' include gems by default?
当我 运行 bundle init
开始一个新项目时,我得到一个标准的 Gemfile:
# A sample Gemfile
source "https://rubygems.org"
# gem "rails"
我如何自定义它?
我的目标是让一些 gems
我在默认包含的几乎每个项目中使用。
我在 bundle init 文档中看到它可以与 --gemspec=FILE
选项一起使用,但是有没有办法自定义仅使用 bundle init
时出现的默认版本?
bundle init
Generates a Gemfile into the current working directory
$ bundle init [--gemspec=FILE]
Options:
--gemspec
: Use the specified .gemspec to create the Gemfile Init
generates a default Gemfile in the current working directory. When
adding a Gemfile to a gem with a gemspec, the --gemspec option will
automatically add each dependency listed in the gemspec file to the
newly created Gemfile.
bundle init
所做的就是从模板生成一个 Gemfile,一个 gemspec。
如果你想要一个默认的 gem 列表,只需定义一个 gemspec 模板作为你的 'default'.
然后像这样使用它
$ bundle init --gemspec=~/.default
你甚至可以为它定义一个别名
#note the lack of a space in the alias name
$ alias bundleinit='bundle init --gemspec=~/.default'
然后像这样使用
$ bundleinit
你的想法是正确的。我有一个我也喜欢使用的模板,它看起来像这样:
~/.gemspec_template
Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "pry"
end
从那里,我只是 运行:
bundle init --gemspec=~/.gemspec_template
我得到一个 Gemfile
看起来像:
# Generated from /Users/anthonyross/.gemspec_template
source 'https://rubygems.org'
group :development do
gem "bundler", "~> 1.7"
gem "rake", "~> 10.0"
gem "pry", ">= 0"
end
当我 运行 bundle init
开始一个新项目时,我得到一个标准的 Gemfile:
# A sample Gemfile
source "https://rubygems.org"
# gem "rails"
我如何自定义它?
我的目标是让一些 gems
我在默认包含的几乎每个项目中使用。
我在 bundle init 文档中看到它可以与 --gemspec=FILE
选项一起使用,但是有没有办法自定义仅使用 bundle init
时出现的默认版本?
bundle init
Generates a Gemfile into the current working directory
$ bundle init [--gemspec=FILE]
Options:
--gemspec
: Use the specified .gemspec to create the Gemfile Init generates a default Gemfile in the current working directory. When adding a Gemfile to a gem with a gemspec, the --gemspec option will automatically add each dependency listed in the gemspec file to the newly created Gemfile.
bundle init
所做的就是从模板生成一个 Gemfile,一个 gemspec。
如果你想要一个默认的 gem 列表,只需定义一个 gemspec 模板作为你的 'default'.
然后像这样使用它
$ bundle init --gemspec=~/.default
你甚至可以为它定义一个别名
#note the lack of a space in the alias name
$ alias bundleinit='bundle init --gemspec=~/.default'
然后像这样使用
$ bundleinit
你的想法是正确的。我有一个我也喜欢使用的模板,它看起来像这样:
~/.gemspec_template
Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "pry"
end
从那里,我只是 运行:
bundle init --gemspec=~/.gemspec_template
我得到一个 Gemfile
看起来像:
# Generated from /Users/anthonyross/.gemspec_template
source 'https://rubygems.org'
group :development do
gem "bundler", "~> 1.7"
gem "rake", "~> 10.0"
gem "pry", ">= 0"
end