PageRenderTime 71ms CodeModel.GetById 40ms app.highlight 6ms RepoModel.GetById 14ms app.codeStats 0ms

/tools/Ruby/lib/ruby/site_ruby/1.8/rubygems/commands/outdated_command.rb

http://github.com/agross/netopenspace
Ruby | 35 lines | 24 code | 10 blank | 1 comment | 1 complexity | 8af91758d40f086ac9337b0eac28048e MD5 | raw file
 1require 'rubygems/command'
 2require 'rubygems/local_remote_options'
 3require 'rubygems/spec_fetcher'
 4require 'rubygems/version_option'
 5
 6class Gem::Commands::OutdatedCommand < Gem::Command
 7
 8  include Gem::LocalRemoteOptions
 9  include Gem::VersionOption
10
11  def initialize
12    super 'outdated', 'Display all gems that need updates'
13
14    add_local_remote_options
15    add_platform_option
16  end
17
18  def execute
19    # FIX: this should be able to be Gem.source_index but our test fails :(
20    locals = Gem::SourceIndex.new Gem::SourceIndex.installed_spec_directories
21
22    locals.outdated.sort.each do |name|
23      local   = locals.find_name(name).last
24      dep     = Gem::Dependency.new local.name, ">= #{local.version}"
25      remotes = Gem::SpecFetcher.fetcher.fetch dep
26
27      next if remotes.empty?
28
29      remote = remotes.last.first
30      say "#{local.name} (#{local.version} < #{remote.version})"
31    end
32  end
33
34end
35