PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/agross/netopenspace
Ruby | 27 lines | 23 code | 4 blank | 0 comment | 2 complexity | 90314b94478b94d5183dbf3e1e8ad3e1 MD5 | raw file
 1require 'rubygems/command'
 2
 3class Gem::Commands::StaleCommand < Gem::Command
 4  def initialize
 5    super('stale', 'List gems along with access times')
 6  end
 7
 8  def usage # :nodoc:
 9    "#{program_name}"
10  end
11
12  def execute
13    gem_to_atime = {}
14    Gem.source_index.each do |name, spec|
15      Dir["#{spec.full_gem_path}/**/*.*"].each do |file|
16        next if File.directory?(file)
17        stat = File.stat(file)
18        gem_to_atime[name] ||= stat.atime
19        gem_to_atime[name] = stat.atime if gem_to_atime[name] < stat.atime
20      end
21    end
22
23    gem_to_atime.sort_by { |_, atime| atime }.each do |name, atime|
24      say "#{name} at #{atime.strftime '%c'}"
25    end
26  end
27end