summaryrefslogtreecommitdiff
path: root/lib/bundler/cli
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-04-07 03:35:05 +0000
committerThe Bundler Bot <bot@bundler.io>2017-04-07 03:35:05 +0000
commit32fb8327328789bdc911dccda4a59e99956c558c (patch)
tree92e0de674fdd0a70d844fd268ad7f2c881a67d5c /lib/bundler/cli
parent7358d857d32ce07c79b874e60441b971ff4c0f24 (diff)
parent1754e5019fe7f97db6d24f11bba8768d1dca7772 (diff)
downloadbundler-32fb8327328789bdc911dccda4a59e99956c558c.tar.gz
Auto merge of #5456 - Shekharrajak:5452_bundle_inject_options, r=colby-swandale
`bundle inject` with source and group options Fixes https://github.com/bundler/bundler/issues/5452 Eg ``` $ bundle inject "bootstrap" ">0" --source=https://rubygems.org --group=development Fetching gem metadata from https://rubygems.org/............ Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Fetching gem metadata from https://rubygems.org/............. Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Added to Gemfile: bootstrap (> 0), group => [:development], :source => 'https://rubygems.org' ``` In GemFile ``` gem 'bootstrap', '> 0', :group => [:development], :source => 'https://rubygems.org' ``` ### Multiple group : ``` $ dbundle inject "bootstrap" ">0" --source=https://rubygems.org --group=development,production Fetching gem metadata from https://rubygems.org/............ Added to Gemfile: gem 'bootstrap', '> 0', :group => [:development, :production], :source => 'https://rubygems.org' ``` In gemfile ``` # Added at 2017-03-24 11:40:51 +0530 by shekharrajak: gem 'bootstrap', '> 0', :group => [:development, :production], :source => 'https://rubygems.org' ```
Diffstat (limited to 'lib/bundler/cli')
-rw-r--r--lib/bundler/cli/inject.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/bundler/cli/inject.rb b/lib/bundler/cli/inject.rb
index cf35e4985b..b17292643f 100644
--- a/lib/bundler/cli/inject.rb
+++ b/lib/bundler/cli/inject.rb
@@ -6,7 +6,7 @@ module Bundler
@options = options
@name = name
@version = version || last_version_number
- @group = options[:group]
+ @group = options[:group].split(",") unless options[:group].nil?
@source = options[:source]
@gems = []
end
@@ -31,7 +31,13 @@ module Bundler
if added.any?
Bundler.ui.confirm "Added to Gemfile:"
- Bundler.ui.confirm added.map {|g| " #{g}" }.join("\n")
+ Bundler.ui.confirm(added.map do |d|
+ name = "'#{d.name}'"
+ requirement = ", '#{d.requirement}'"
+ group = ", :group => #{d.groups.inspect}" if d.groups != Array(:default)
+ source = ", :source => '#{d.source}'" unless d.source.nil?
+ %(gem #{name}#{requirement}#{group}#{source})
+ end.join("\n"))
else
Bundler.ui.confirm "All gems were already present in the Gemfile"
end