mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Feature: bundle add
supports --path
option
https://github.com/rubygems/rubygems/commit/32bee01fbe
This commit is contained in:
parent
f7cf641469
commit
45fe7f7575
6 changed files with 23 additions and 4 deletions
|
@ -372,6 +372,7 @@ module Bundler
|
||||||
method_option "group", :aliases => "-g", :type => :string
|
method_option "group", :aliases => "-g", :type => :string
|
||||||
method_option "source", :aliases => "-s", :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 "require", :aliases => "-r", :type => :string, :banner => "Adds require path to gem. Provide false, or a path as a string."
|
||||||
|
method_option "path", :type => :string
|
||||||
method_option "git", :type => :string
|
method_option "git", :type => :string
|
||||||
method_option "github", :type => :string
|
method_option "github", :type => :string
|
||||||
method_option "branch", :type => :string
|
method_option "branch", :type => :string
|
||||||
|
|
|
@ -7,7 +7,7 @@ require_relative "rubygems_ext"
|
||||||
module Bundler
|
module Bundler
|
||||||
class Dependency < Gem::Dependency
|
class Dependency < Gem::Dependency
|
||||||
attr_reader :autorequire
|
attr_reader :autorequire
|
||||||
attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref, :force_ruby_platform
|
attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :force_ruby_platform
|
||||||
|
|
||||||
# rubocop:disable Naming/VariableNumber
|
# rubocop:disable Naming/VariableNumber
|
||||||
PLATFORM_MAP = {
|
PLATFORM_MAP = {
|
||||||
|
@ -102,6 +102,7 @@ module Bundler
|
||||||
@autorequire = nil
|
@autorequire = nil
|
||||||
@groups = Array(options["group"] || :default).map(&:to_sym)
|
@groups = Array(options["group"] || :default).map(&:to_sym)
|
||||||
@source = options["source"]
|
@source = options["source"]
|
||||||
|
@path = options["path"]
|
||||||
@git = options["git"]
|
@git = options["git"]
|
||||||
@github = options["github"]
|
@github = options["github"]
|
||||||
@branch = options["branch"]
|
@branch = options["branch"]
|
||||||
|
|
|
@ -115,13 +115,14 @@ module Bundler
|
||||||
end
|
end
|
||||||
|
|
||||||
source = ", :source => \"#{d.source}\"" unless d.source.nil?
|
source = ", :source => \"#{d.source}\"" unless d.source.nil?
|
||||||
|
path = ", :path => \"#{d.path}\"" unless d.path.nil?
|
||||||
git = ", :git => \"#{d.git}\"" unless d.git.nil?
|
git = ", :git => \"#{d.git}\"" unless d.git.nil?
|
||||||
github = ", :github => \"#{d.github}\"" unless d.github.nil?
|
github = ", :github => \"#{d.github}\"" unless d.github.nil?
|
||||||
branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
|
branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
|
||||||
ref = ", :ref => \"#{d.ref}\"" unless d.ref.nil?
|
ref = ", :ref => \"#{d.ref}\"" unless d.ref.nil?
|
||||||
require_path = ", :require => #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
|
require_path = ", :require => #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
|
||||||
|
|
||||||
%(gem #{name}#{requirement}#{group}#{source}#{git}#{github}#{branch}#{ref}#{require_path})
|
%(gem #{name}#{requirement}#{group}#{source}#{path}#{git}#{github}#{branch}#{ref}#{require_path})
|
||||||
end.join("\n")
|
end.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
|
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
|
||||||
.
|
.
|
||||||
.SH "SYNOPSIS"
|
.SH "SYNOPSIS"
|
||||||
\fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-git=GIT] [\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
|
\fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-path=PATH] [\-\-git=GIT] [\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
|
||||||
.
|
.
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
Adds the named gem to the Gemfile and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
|
Adds the named gem to the Gemfile and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
|
||||||
|
@ -49,6 +49,10 @@ Specify the source for the added gem\.
|
||||||
Adds require path to gem\. Provide false, or a path as a string\.
|
Adds require path to gem\. Provide false, or a path as a string\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-path\fR
|
||||||
|
Specify the file system path for the added gem\.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
\fB\-\-git\fR
|
\fB\-\-git\fR
|
||||||
Specify the git source for the added gem\.
|
Specify the git source for the added gem\.
|
||||||
.
|
.
|
||||||
|
|
|
@ -3,7 +3,7 @@ bundle-add(1) -- Add gem to the Gemfile and run bundle install
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
|
|
||||||
`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--git=GIT] [--github=GITHUB] [--branch=BRANCH] [--ref=REF] [--skip-install] [--strict] [--optimistic]
|
`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--path=PATH] [--git=GIT] [--github=GITHUB] [--branch=BRANCH] [--ref=REF] [--skip-install] [--strict] [--optimistic]
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
Adds the named gem to the Gemfile and run `bundle install`. `bundle install` can be avoided by using the flag `--skip-install`.
|
Adds the named gem to the Gemfile and run `bundle install`. `bundle install` can be avoided by using the flag `--skip-install`.
|
||||||
|
@ -33,6 +33,9 @@ bundle add rails --group "development, test"
|
||||||
* `--require`, `-r`:
|
* `--require`, `-r`:
|
||||||
Adds require path to gem. Provide false, or a path as a string.
|
Adds require path to gem. Provide false, or a path as a string.
|
||||||
|
|
||||||
|
* `--path`:
|
||||||
|
Specify the file system path for the added gem.
|
||||||
|
|
||||||
* `--git`:
|
* `--git`:
|
||||||
Specify the git source for the added gem.
|
Specify the git source for the added gem.
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,15 @@ RSpec.describe "bundle add" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "with --path" do
|
||||||
|
it "adds dependency with specified path" do
|
||||||
|
bundle "add 'foo' --path='#{lib_path("foo-2.0")}'"
|
||||||
|
|
||||||
|
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :path => "#{lib_path("foo-2.0")}"/)
|
||||||
|
expect(the_bundle).to include_gems "foo 2.0"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "with --git" do
|
describe "with --git" do
|
||||||
it "adds dependency with specified git source" do
|
it "adds dependency with specified git source" do
|
||||||
bundle "add foo --git=#{lib_path("foo-2.0")}"
|
bundle "add foo --git=#{lib_path("foo-2.0")}"
|
||||||
|
|
Loading…
Reference in a new issue