summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/query_command.rb
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-24 15:28:23 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-24 15:28:23 +0000
commit996b1bfa95347e5171c3f7ab32b6740656ed7a8b (patch)
treebe0310be446bf313f16a12a3a3b56c30b4900cbd /lib/rubygems/commands/query_command.rb
parentce8729feb61d507805d965c5479f343e3701c659 (diff)
merge revision(s) 53707,53708,53709,53712,53777,53781: [Backport #12326]
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.5.2. It supports to enable frozen string literal and add `--norc` option for disable to `.gemrc` configuration. See 2.5.2 release notes for other fixes and enhancements. https://github.com/rubygems/rubygems/blob/a8aa3bac723f045c52471c7b9328310a048561e0/History.txt#L3 * lib/rubygems/specification.rb: `coding` is affect only first line except shebang. * lib/rubygems/package.rb, lib/rubygems/package/*: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@56003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/query_command.rb')
-rw-r--r--lib/rubygems/commands/query_command.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index 4782eb98ef..d6196b44ed 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/spec_fetcher'
@@ -50,6 +50,12 @@ class Gem::Commands::QueryCommand < Gem::Command
options[:all] = value
end
+ add_option('-e', '--exact',
+ 'Name of gem(s) to query on matches the',
+ 'provided STRING') do |value, options|
+ options[:exact] = value
+ end
+
add_option( '--[no-]prerelease',
'Display prerelease versions') do |value, options|
options[:prerelease] = value
@@ -79,7 +85,8 @@ is too hard to use.
elsif !options[:name].source.empty?
name = Array(options[:name])
else
- name = options[:args].to_a.map{|arg| /#{arg}/i }
+ args = options[:args].to_a
+ name = options[:exact] ? args : args.map{|arg| /#{arg}/i }
end
prerelease = options[:prerelease]
@@ -162,7 +169,7 @@ is too hard to use.
:latest
end
- if name.source.empty?
+ if name.respond_to?(:source) && name.source.empty?
spec_tuples = fetcher.detect(type) { true }
else
spec_tuples = fetcher.detect(type) do |name_tuple|
@@ -277,7 +284,7 @@ is too hard to use.
end
def spec_authors entry, spec
- authors = "Author#{spec.authors.length > 1 ? 's' : ''}: "
+ authors = "Author#{spec.authors.length > 1 ? 's' : ''}: ".dup
authors << spec.authors.join(', ')
entry << format_text(authors, 68, 4)
end
@@ -291,7 +298,7 @@ is too hard to use.
def spec_license entry, spec
return if spec.license.nil? or spec.license.empty?
- licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: "
+ licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: ".dup
licenses << spec.licenses.join(', ')
entry << "\n" << format_text(licenses, 68, 4)
end
@@ -341,4 +348,3 @@ is too hard to use.
end
end
-