summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Dalessio <mike.dalessio@gmail.com>2022-09-03 13:30:07 -0400
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2022-09-05 11:43:14 +0900
commit45fe7f757522ed7d1d3ec754da59d41d45dd6bab (patch)
treeaf6ca87db0b7f58269f4db1223c30871e30f6de2
parentf7cf641469161c3770b58f79e08e312512212aa8 (diff)
[rubygems/rubygems] Feature: `bundle add` supports `--path` option
https://github.com/rubygems/rubygems/commit/32bee01fbe
-rw-r--r--lib/bundler/cli.rb1
-rw-r--r--lib/bundler/dependency.rb3
-rw-r--r--lib/bundler/injector.rb3
-rw-r--r--lib/bundler/man/bundle-add.16
-rw-r--r--lib/bundler/man/bundle-add.1.ronn5
-rw-r--r--spec/bundler/commands/add_spec.rb9
6 files changed, 23 insertions, 4 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 5bf0f4fa3a..4f969b17bf 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -372,6 +372,7 @@ module Bundler
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 "path", :type => :string
method_option "git", :type => :string
method_option "github", :type => :string
method_option "branch", :type => :string
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb
index 49ce23ec88..7607b4695c 100644
--- a/lib/bundler/dependency.rb
+++ b/lib/bundler/dependency.rb
@@ -7,7 +7,7 @@ require_relative "rubygems_ext"
module Bundler
class Dependency < Gem::Dependency
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
PLATFORM_MAP = {
@@ -102,6 +102,7 @@ module Bundler
@autorequire = nil
@groups = Array(options["group"] || :default).map(&:to_sym)
@source = options["source"]
+ @path = options["path"]
@git = options["git"]
@github = options["github"]
@branch = options["branch"]
diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb
index f6550abe88..82d5bd5880 100644
--- a/lib/bundler/injector.rb
+++ b/lib/bundler/injector.rb
@@ -115,13 +115,14 @@ module Bundler
end
source = ", :source => \"#{d.source}\"" unless d.source.nil?
+ path = ", :path => \"#{d.path}\"" unless d.path.nil?
git = ", :git => \"#{d.git}\"" unless d.git.nil?
github = ", :github => \"#{d.github}\"" unless d.github.nil?
branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
ref = ", :ref => \"#{d.ref}\"" unless d.ref.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
diff --git a/lib/bundler/man/bundle-add.1 b/lib/bundler/man/bundle-add.1
index 20430a78a0..62177095d0 100644
--- a/lib/bundler/man/bundle-add.1
+++ b/lib/bundler/man/bundle-add.1
@@ -7,7 +7,7 @@
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
.
.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"
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\.
.
.TP
+\fB\-\-path\fR
+Specify the file system path for the added gem\.
+.
+.TP
\fB\-\-git\fR
Specify the git source for the added gem\.
.
diff --git a/lib/bundler/man/bundle-add.1.ronn b/lib/bundler/man/bundle-add.1.ronn
index 8eead9c569..37c92e5fcd 100644
--- a/lib/bundler/man/bundle-add.1.ronn
+++ b/lib/bundler/man/bundle-add.1.ronn
@@ -3,7 +3,7 @@ bundle-add(1) -- Add gem to the Gemfile and run bundle install
## 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
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`:
Adds require path to gem. Provide false, or a path as a string.
+* `--path`:
+ Specify the file system path for the added gem.
+
* `--git`:
Specify the git source for the added gem.
diff --git a/spec/bundler/commands/add_spec.rb b/spec/bundler/commands/add_spec.rb
index 96ea238063..36d7616949 100644
--- a/spec/bundler/commands/add_spec.rb
+++ b/spec/bundler/commands/add_spec.rb
@@ -103,6 +103,15 @@ RSpec.describe "bundle add" do
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
it "adds dependency with specified git source" do
bundle "add foo --git=#{lib_path("foo-2.0")}"