From 6794f8cf928ab8c009b301ec49a5a81e97e6eb2f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 2 Feb 2022 16:57:34 +0900 Subject: Merge pull request #5482 from hsbt/rubygems-3-3-bundler-2-3 Merge RubyGems 3.3.x and Bundler 2.3.x --- lib/rubygems/query_utils.rb | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'lib/rubygems/query_utils.rb') diff --git a/lib/rubygems/query_utils.rb b/lib/rubygems/query_utils.rb index 0acd5bf9c8..f4cfea3087 100644 --- a/lib/rubygems/query_utils.rb +++ b/lib/rubygems/query_utils.rb @@ -54,14 +54,14 @@ module Gem::QueryUtils end def defaults_str # :nodoc: - "--local --name-matches // --no-details --versions --no-installed" + "--local --no-details --versions --no-installed" end def execute - gem_names = Array(options[:name]) - - if !args.empty? - gem_names = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i } + gem_names = if args.empty? + [options[:name]] + else + options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i } end terminate_interaction(check_installed_gems(gem_names)) if check_installed_gems? @@ -96,7 +96,7 @@ module Gem::QueryUtils end def gem_name? - !options[:name].source.empty? + !options[:name].nil? end def prerelease @@ -129,12 +129,10 @@ module Gem::QueryUtils display_header("LOCAL") specs = Gem::Specification.find_all do |s| - s.name =~ name and req =~ s.version - end + name_matches = name ? s.name =~ name : true + version_matches = show_prereleases? || !s.version.prerelease? - dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req } - specs.select! do |s| - dep.match?(s.name, s.version, show_prereleases?) + name_matches and version_matches end spec_tuples = specs.map do |spec| @@ -149,13 +147,13 @@ module Gem::QueryUtils fetcher = Gem::SpecFetcher.fetcher - spec_tuples = if name.respond_to?(:source) && name.source.empty? - fetcher.detect(specs_type) { true } - else - fetcher.detect(specs_type) do |name_tuple| - name === name_tuple.name - end - end + spec_tuples = if name.nil? + fetcher.detect(specs_type) { true } + else + fetcher.detect(specs_type) do |name_tuple| + name === name_tuple.name + end + end output_query_results(spec_tuples) end -- cgit v1.2.3