module Gem::QueryUtils

Public Instance Methods

add_query_options ()
# File lib/rubygems/query_utils.rb, line 13
def add_query_options
  add_option("-i", "--[no-]installed",
             "Check for installed gem") do |value, options|
    options[:installed] = value
  end

  add_option("-I", "Equivalent to --no-installed") do |_value, options|
    options[:installed] = false
  end

  add_version_option command, "for use with --installed"

  add_option("-d", "--[no-]details",
             "Display detailed information of gem(s)") do |value, options|
    options[:details] = value
  end

  add_option("--[no-]versions",
             "Display only gem names") do |value, options|
    options[:versions] = value
    options[:details] = false unless value
  end

  add_option("-a", "--all",
             "Display all gem versions") do |value, options|
    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
  end

  add_local_remote_options
end
execute ()
# File lib/rubygems/query_utils.rb, line 59
def execute
  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?

  gem_names.each {|n| show_gems(n) }
end