Class: Gem::Commands::OutdatedCommand

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

Instance Method Summary collapse

Constructor Details

#initialize(name = 'outdated', summary = 'Display all gems (containing STRING) that need updates') ⇒ OutdatedCommand

Returns a new instance of OutdatedCommand.



5
6
7
8
# File 'lib/rubygems/commands/outdated_command.rb', line 5

def initialize(name = 'outdated',
               summary = 'Display all gems (containing STRING) that need updates')
  super name, summary, :name => //
end

Instance Method Details

#argumentsObject

:nodoc:



10
11
12
# File 'lib/rubygems/commands/outdated_command.rb', line 10

def arguments # :nodoc:
  "STRING        fragment of gem name to search for"
end

#executeObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rubygems/commands/outdated_command.rb', line 18

def execute
  string = get_one_optional_argument
  name = /#{string}/i

  dep = dependency(name)

  outdated(dep).sort.each do |name|
    local = self.source_index(dep).find_name(name).last

    remote_dep = Gem::Dependency.new local.name, ">= #{local.version}"
    remotes = Gem::SpecFetcher.fetcher.fetch remote_dep
    remote = remotes.last.first

    say "#{local.name} (#{local.version} < #{remote.version})"
  end
end

#usageObject

:nodoc:



14
15
16
# File 'lib/rubygems/commands/outdated_command.rb', line 14

def usage # :nodoc:
  "#{program_name} [STRING]"
end