Class: Gem::Commands::RecentUpdatesCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::RecentUpdatesCommand
- Defined in:
- lib/rubygems/commands/recent-updates_command.rb
Instance Method Summary collapse
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ RecentUpdatesCommand
constructor
A new instance of RecentUpdatesCommand.
Constructor Details
#initialize ⇒ RecentUpdatesCommand
Returns a new instance of RecentUpdatesCommand.
5 6 7 8 9 10 11 |
# File 'lib/rubygems/commands/recent-updates_command.rb', line 5 def initialize super 'recent-updates', "Display the recent histories of recently updated gems" add_option('--since TIME', Float, 'Number of days back to look') do |value, | [:days] = value end end |
Instance Method Details
#description ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/rubygems/commands/recent-updates_command.rb', line 13 def description # :nodoc: """Displays the new portions of the history files of recently updated gems.""" end |
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubygems/commands/recent-updates_command.rb', line 17 def execute days = [:days] || 7 since = Time.now - days * 24 * 60 * 60 names = Gem.source_index.map do |name, spec| mtime = Dir["#{spec.full_gem_path}/**/*.*"].map { |file| File.mtime(file) }.min spec if mtime > since end.compact run_pager changes = names.map do |spec| name, version = spec.name, spec.version dep = Gem::Dependency.new name, Gem::Requirement.default specs = Gem.source_index.search dep prev = specs.select { |s| s.version < version }.sort.last next unless prev "#{Term::ANSIColor::red}#{name} #{version.version}#{Term::ANSIColor::black}:\n" + change_summary(spec, prev) + "\n" end.compact if changes.any? puts "Changes since #{since}:\n\n" puts changes.join("\n") else puts "No changes since #{since}." end end |