Module: Gem::QueryUtils
- Includes:
- LocalRemoteOptions, Text, VersionOption
- Included in:
- Commands::InfoCommand, Commands::ListCommand, Commands::QueryCommand, Commands::SearchCommand
- Defined in:
- lib/rubygems/query_utils.rb
Instance Method Summary collapse
Methods included from VersionOption
#add_platform_option, #add_prerelease_option, #add_version_option, #get_platform_from_requirements
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
Instance Method Details
#add_query_options ⇒ Object
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 |
# File 'lib/rubygems/query_utils.rb', line 14 def 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('-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 |
#defaults_str ⇒ Object
:nodoc:
56 57 58 |
# File 'lib/rubygems/query_utils.rb', line 56 def defaults_str # :nodoc: "--local --name-matches // --no-details --versions --no-installed" end |
#execute ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rubygems/query_utils.rb', line 60 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 |