summaryrefslogtreecommitdiff
path: root/lib/bundler/cli
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2023-12-11 13:05:42 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-12-13 13:02:22 +0900
commit1a7aa5560f1a9967e320f71b7e8e8ee748151168 (patch)
treea7709715ddc1f4bafe3290186aa40f71766836d3 /lib/bundler/cli
parent70428247c673987c6613396f55a8ab5651d27fe4 (diff)
[rubygems/rubygems] Refactor `bundle info`
https://github.com/rubygems/rubygems/commit/0e919eaa87
Diffstat (limited to 'lib/bundler/cli')
-rw-r--r--lib/bundler/cli/common.rb9
-rw-r--r--lib/bundler/cli/info.rb11
2 files changed, 11 insertions, 9 deletions
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb
index d654406f65..0cf85c1d8d 100644
--- a/lib/bundler/cli/common.rb
+++ b/lib/bundler/cli/common.rb
@@ -57,6 +57,9 @@ module Bundler
specs << spec if regexp && spec.name =~ regexp
end
+ default_spec = default_gem_spec(name)
+ specs << default_spec if default_spec
+
case specs.count
when 0
dep_in_other_group = Bundler.definition.current_dependencies.find {|dep|dep.name == name }
@@ -75,6 +78,12 @@ module Bundler
raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
end
+ def self.default_gem_spec(name)
+ return unless Gem::Specification.respond_to?(:find_all_by_name)
+ gem_spec = Gem::Specification.find_all_by_name(name).last
+ gem_spec if gem_spec&.default_gem?
+ end
+
def self.ask_for_spec_from(specs)
specs.each_with_index do |spec, index|
Bundler.ui.info "#{index.succ} : #{spec.name}", true
diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb
index ddceb17e3f..8f34956aca 100644
--- a/lib/bundler/cli/info.rb
+++ b/lib/bundler/cli/info.rb
@@ -25,15 +25,8 @@ module Bundler
private
- def spec_for_gem(gem_name)
- spec = Bundler.definition.specs.find {|s| s.name == gem_name }
- spec || default_gem_spec(gem_name) || Bundler::CLI::Common.select_spec(gem_name, :regex_match)
- end
-
- def default_gem_spec(gem_name)
- return unless Gem::Specification.respond_to?(:find_all_by_name)
- gem_spec = Gem::Specification.find_all_by_name(gem_name).last
- gem_spec if gem_spec&.default_gem?
+ def spec_for_gem(name)
+ Bundler::CLI::Common.select_spec(name, :regex_match)
end
def print_gem_version(spec)