mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Add require parameter to bundle add
`
Test and ensure "false" is handled
Don't use yield_self to operate on autorequire
Remove duplicate autorequire
Add banner to require option
Don't use json to break down require params
Pass linter
a4f2f8ac17
This commit is contained in:
parent
26303c31f0
commit
1b12ebb94e
3 changed files with 21 additions and 1 deletions
|
@ -367,6 +367,7 @@ module Bundler
|
|||
method_option "version", :aliases => "-v", :type => :string
|
||||
method_option "group", :aliases => "-g", :type => :string
|
||||
method_option "source", :aliases => "-s", :type => :string
|
||||
method_option "require", :aliases => "-r", :type => :string, :banner => "Adds require path to gem. Provide false, or a path as a string."
|
||||
method_option "git", :type => :string
|
||||
method_option "branch", :type => :string
|
||||
method_option "skip-install", :type => :boolean, :banner =>
|
||||
|
|
|
@ -113,8 +113,9 @@ module Bundler
|
|||
source = ", :source => \"#{d.source}\"" unless d.source.nil?
|
||||
git = ", :git => \"#{d.git}\"" unless d.git.nil?
|
||||
branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
|
||||
require_path = ", :require => #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
|
||||
|
||||
%(gem #{name}#{requirement}#{group}#{source}#{git}#{branch})
|
||||
%(gem #{name}#{requirement}#{group}#{source}#{git}#{branch}#{require_path})
|
||||
end.join("\n")
|
||||
end
|
||||
|
||||
|
@ -269,5 +270,11 @@ module Bundler
|
|||
def show_warning(message)
|
||||
Bundler.ui.info Bundler.ui.add_color(message, :yellow)
|
||||
end
|
||||
|
||||
def convert_autorequire(autorequire)
|
||||
autorequire = autorequire.first
|
||||
return autorequire if autorequire == "false"
|
||||
autorequire.inspect
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,6 +68,18 @@ RSpec.describe "bundle add" do
|
|||
end
|
||||
end
|
||||
|
||||
describe "with --require" do
|
||||
it "adds the require param for the gem" do
|
||||
bundle "add 'foo' --require=foo/engine"
|
||||
expect(bundled_app_gemfile.read).to match(%r{gem "foo",(?: .*,) :require => "foo\/engine"})
|
||||
end
|
||||
|
||||
it "converts false to a boolean" do
|
||||
bundle "add 'foo' --require=false"
|
||||
expect(bundled_app_gemfile.read).to match(/gem "foo",(?: .*,) :require => false/)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with --group" do
|
||||
it "adds dependency for the specified group" do
|
||||
bundle "add 'foo' --group='development'"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue