1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Simplify argument processing logic in gem list & gem search

Make it more explicit that if not specific arguments are given, the
value of `-n` is used.

ed811ddc00
This commit is contained in:
David Rodríguez 2022-01-17 14:02:58 +01:00 committed by git
parent e4f8d5b2f5
commit 8b6a02de2f

View file

@ -58,10 +58,10 @@ module Gem::QueryUtils
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?
Array(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?