Class: Pod::Command::List::New

Inherits:
Pod::Command::List show all
Defined in:
lib/cocoapods/command/list.rb

Overview

———————————————————————–#

Instance Method Summary collapse

Methods inherited from Pod::Command::List

#initialize, options, #update_if_necessary!

Methods included from Executable

#executable, execute_command

Methods inherited from Pod::Command

#initialize, options, parse, report_error, run

Methods included from Pod::Config::Mixin

#config

Constructor Details

This class inherits a constructor from Pod::Command::List

Instance Method Details

#runObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cocoapods/command/list.rb', line 44

def run
  update_if_necessary!

  days = [1,2,3,5,8]
  dates, groups = {}, {}
  days.each {|d| dates[d] = Time.now - 60 * 60 * 24 * d}
  sets = SourcesManager.all_sets
  statistics_provider = Specification::Set::Statistics.new(STATISTICS_CACHE_FILE)
  creation_dates = statistics_provider.creation_dates(sets)

  sets.each do |set|
    set_date = creation_dates[set.name]
    days.each do |d|
      if set_date >= dates[d]
        groups[d] = [] unless groups[d]
        groups[d] << set
        break
      end
    end
  end
  days.reverse.each do |d|
    sets = groups[d]
    next unless sets
    UI.section("\nPods added in the last #{"day".pluralize(d)}".yellow) do
      sorted = sets.sort_by {|s| creation_dates[s.name]}
      mode = @stats ? :stats : :name
      sorted.each { |set| UI.pod(set, mode, statistics_provider) }
    end
  end
end