Class: Gem::Commands::GrepCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/rubygems/commands/grep_command.rb

Defined Under Namespace

Classes: CapturedUI

Instance Method Summary collapse

Constructor Details

#initializeGrepCommand

Returns a new instance of GrepCommand.



15
16
17
# File 'lib/rubygems/commands/grep_command.rb', line 15

def initialize
  super('grep', description)
end

Instance Method Details

#descriptionObject



11
12
13
# File 'lib/rubygems/commands/grep_command.rb', line 11

def description
  'Grep the gem for a given name or grep the file for a given require path'
end

#executeObject



19
20
21
22
23
24
25
26
# File 'lib/rubygems/commands/grep_command.rb', line 19

def execute
  if options[:build_args].empty?
    alert_error('No pattern specified')
    terminate_interaction(1)
  end

  exec(*grep_command(options[:args], options[:build_args]))
end

#grep_command(path_args, grep_args) ⇒ Object



28
29
30
# File 'lib/rubygems/commands/grep_command.rb', line 28

def grep_command path_args, grep_args
  [grep_name, *grep_args, *grep_default_args, capture_path(*path_args)]
end