Class: Gem::Commands::StaleCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::StaleCommand
- Defined in:
- lib/rubygems/commands/stale_command.rb
Instance Attribute Summary
Attributes inherited from Gem::Command
#command, #defaults, #options, #program_name, #summary
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize ⇒ StaleCommand
constructor
A new instance of StaleCommand.
-
#usage ⇒ Object
:nodoc:.
Methods inherited from Gem::Command
add_common_option, #add_extra_args, #add_option, add_specific_extra_args, #arguments, #begins?, build_args, build_args=, common_options, #defaults_str, #description, extra_args, extra_args=, #get_all_gem_names, #get_one_gem_name, #get_one_optional_argument, #handle_options, #handles?, #invoke, #merge_options, #remove_option, #show_help, #show_lookup_failure, specific_extra_args, specific_extra_args_hash, #when_invoked
Methods included from UserInteraction
#alert, #alert_error, #alert_warning, #ask, #ask_for_password, #ask_yes_no, #choose_from_list, #say, #terminate_interaction
Methods included from DefaultUserInteraction
ui, #ui, ui=, #ui=, use_ui, #use_ui
Constructor Details
#initialize ⇒ StaleCommand
Returns a new instance of StaleCommand.
4 5 6 |
# File 'lib/rubygems/commands/stale_command.rb', line 4 def initialize super('stale', 'List gems along with access times') end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubygems/commands/stale_command.rb', line 12 def execute gem_to_atime = {} Gem::Specification.each do |spec| name = spec.full_name Dir["#{spec.full_gem_path}/**/*.*"].each do |file| next if File.directory?(file) stat = File.stat(file) gem_to_atime[name] ||= stat.atime gem_to_atime[name] = stat.atime if gem_to_atime[name] < stat.atime end end gem_to_atime.sort_by { |_, atime| atime }.each do |name, atime| say "#{name} at #{atime.strftime '%c'}" end end |
#usage ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/rubygems/commands/stale_command.rb', line 8 def usage # :nodoc: "#{program_name}" end |