Class: Gem::Commands::LocateCommand
- Inherits:
-
QueryCommand
- Object
- QueryCommand
- Gem::Commands::LocateCommand
- Defined in:
- lib/commands/locate.rb
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#defaults_str ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ LocateCommand
constructor
A new instance of LocateCommand.
-
#usage ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ LocateCommand
Returns a new instance of LocateCommand.
2 3 4 5 6 |
# File 'lib/commands/locate.rb', line 2 def initialize super 'locate', 'Find all gems whose name, summary, or description match STRING' %w(-p -u).each{|com| remove_option com } end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/commands/locate.rb', line 8 def arguments # :nodoc: "STRING fragment of gem name,summary, or description to search for" end |
#defaults_str ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/commands/locate.rb', line 12 def defaults_str # :nodoc: "--local" end |
#execute ⇒ Object
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 66 67 68 |
# File 'lib/commands/locate.rb', line 20 def execute string = get_one_optional_argument [:name] = /#{string}/i exit_code = 0 name = [:name] prerelease = [:prerelease] if [:installed] then if name.source.empty? then alert_error "You must specify a gem name" exit_code |= 4 elsif installed? name, [:version] then say "true" else say "false" exit_code |= 1 end raise Gem::SystemExitException, exit_code end dep = Gem::Dependency.new name, Gem::Requirement.default if local? then if prerelease and not both? then alert_warning "prereleases are always shown locally" end if ui.outs.tty? or both? then say say "*** LOCAL GEMS ***" say end specs = Gem.source_index.locate dep spec_tuples = specs.map do |spec| [[spec.name, spec.version, spec.original_platform, spec], :local] end output_query_results spec_tuples [:local] = [:domain] = nil end if remote? then super end end |
#usage ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/commands/locate.rb', line 16 def usage # :nodoc: "#{program_name} [STRING]" end |