How can I make 'bundle init' include gems by default?

When I run bundle initto start a new project, I get a standard Gemfile:

# A sample Gemfile
source "https://rubygems.org"

# gem "rails"

How can I customize this?

My goal is to have a few gemsthat I use with almost every project included by default.

I see in bundle init documentation that can be used with the option --gemspec=FILE, but is there a way to set the default value of the version that appears when using bundle init?

+4
source share
2 answers

. , , :

~/.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
+3
bundle init

Gemfile

$ bundle init [--gemspec=FILE]

:

--gemspec: .gemspec Gemfile Init Gemfile . Gemfile gemspec, -gemspec , gemspec, Gemfile.

, bundle init, - Gemfile gemspec.

, gemspec, ' .

$ bundle init --gemspec=~/.default

#note the lack of a space in the alias name
$ alias bundleinit='bundle init --gemspec=~/.default' 

$ bundleinit
+3

Source: https://habr.com/ru/post/1606494/


All Articles