Class: Gem::Commands::QueryCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::QueryCommand
- Includes:
- LocalRemoteOptions, Text, VersionOption
- Defined in:
- lib/rubygems/commands/query_command.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Gem::Command
#command, #defaults, #options, #program_name, #summary
Instance Method Summary collapse
-
#defaults_str ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize(name = 'query', summary = 'Query gem information in local or remote repositories') ⇒ QueryCommand
constructor
A new instance of QueryCommand.
Methods included from VersionOption
#add_platform_option, #add_prerelease_option, #add_version_option
Methods included from LocalRemoteOptions
#accept_uri_http, #add_bulk_threshold_option, #add_clear_sources_option, #add_local_remote_options, #add_proxy_option, #add_source_option, #add_update_sources_option, #both?, #local?, #remote?
Methods included from Text
#clean_text, #format_text, #levenshtein_distance, #min3, #truncate_text
Methods inherited from Gem::Command
add_common_option, #add_extra_args, #add_option, add_specific_extra_args, #arguments, #begins?, build_args, build_args=, #check_deprecated_options, common_options, #deprecate_option, extra_args, extra_args=, #get_all_gem_names, #get_all_gem_names_and_versions, #get_one_gem_name, #get_one_optional_argument, #handle_options, #handles?, #invoke, #invoke_with_build_args, #merge_options, #remove_option, #show_help, #show_lookup_failure, specific_extra_args, specific_extra_args_hash, #usage, #when_invoked
Methods included from UserInteraction
#alert, #alert_error, #alert_warning, #ask, #ask_for_password, #ask_yes_no, #choose_from_list, #say, #terminate_interaction, #verbose
Methods included from DefaultUserInteraction
ui, #ui, ui=, #ui=, use_ui, #use_ui
Constructor Details
#initialize(name = 'query', summary = 'Query gem information in local or remote repositories') ⇒ QueryCommand
Returns a new instance of QueryCommand.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rubygems/commands/query_command.rb', line 14 def initialize(name = 'query', summary = 'Query gem information in local or remote repositories') super name, summary, :name => //, :domain => :local, :details => false, :versions => true, :installed => nil, :version => Gem::Requirement.default add_option('-i', '--[no-]installed', 'Check for installed gem') do |value, | [:installed] = value end add_option('-I', 'Equivalent to --no-installed') do |value, | [:installed] = false end add_version_option command, "for use with --installed" add_option('-n', '--name-matches REGEXP', 'Name of gem(s) to query on matches the', 'provided REGEXP') do |value, | [:name] = /#{value}/i end add_option('-d', '--[no-]details', 'Display detailed information of gem(s)') do |value, | [:details] = value end add_option('--[no-]versions', 'Display only gem names') do |value, | [:versions] = value [:details] = false unless value end add_option('-a', '--all', 'Display all gem versions') do |value, | [:all] = value end add_option('-e', '--exact', 'Name of gem(s) to query on matches the', 'provided STRING') do |value, | [:exact] = value end add_option('--[no-]prerelease', 'Display prerelease versions') do |value, | [:prerelease] = value end end |
Instance Method Details
#defaults_str ⇒ Object
:nodoc:
67 68 69 |
# File 'lib/rubygems/commands/query_command.rb', line 67 def defaults_str # :nodoc: "--local --name-matches // --no-details --versions --no-installed" end |
#description ⇒ Object
:nodoc:
71 72 73 74 75 76 77 78 |
# File 'lib/rubygems/commands/query_command.rb', line 71 def description # :nodoc: <<-EOF The query command is the basis for the list and search commands. You should really use the list and search commands instead. This command is too hard to use. EOF end |
#execute ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rubygems/commands/query_command.rb', line 80 def execute gem_names = Array([:name]) if !args.empty? gem_names = [: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? gem_names.each { |n| show_gems(n) } end |