Class: LibGems::Commands::StaleCommand
- Inherits:
-
LibGems::Command
- Object
- LibGems::Command
- LibGems::Commands::StaleCommand
- Defined in:
- lib/libgems/commands/stale_command.rb
Instance Attribute Summary
Attributes inherited from LibGems::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 LibGems::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
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/libgems/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 |
# File 'lib/libgems/commands/stale_command.rb', line 12 def execute gem_to_atime = {} LibGems.source_index.each do |name, spec| 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/libgems/commands/stale_command.rb', line 8 def usage # :nodoc: "#{program_name}" end |