Commit ee9b229d authored by Samuel E. Giddins's avatar Samuel E. Giddins

[UI] Adapt to the removal of the Set::Statistics class

parent 76c22f49
......@@ -15,7 +15,7 @@ gem 'json', '1.7.7'
group :development do
cp_gem 'claide', 'CLAide'
cp_gem 'cocoapods-core', 'Core'
cp_gem 'cocoapods-core', 'Core', 'seg-delete-statistics'
cp_gem 'cocoapods-downloader', 'cocoapods-downloader'
cp_gem 'cocoapods-plugins', 'cocoapods-plugins'
cp_gem 'cocoapods-trunk', 'cocoapods-trunk'
......
......@@ -7,8 +7,8 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision: 49a91acc2b1b9812352fa3605141215fbcc1e466
branch: master
revision: 800948c15b79203c0642135a91ec29354bee3fb7
branch: seg-delete-statistics
specs:
cocoapods-core (0.35.0)
activesupport (>= 3.2.15)
......
......@@ -34,41 +34,6 @@ module Pod
end
#-----------------------------------------------------------------------#
class New < List
self.summary = 'Lists pods introduced in the master spec-repo since the last check'
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.aggregate.all_sets
statistics_provider = Config.instance.spec_statistics_provider
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
end
end
end
end
......@@ -84,11 +84,10 @@ module Pod
sets.reject! { |set| !set.specification.available_platforms.map(&:name).include?(:osx) }
end
statistics_provider = Config.instance.spec_statistics_provider
sets.each do |set|
begin
if @stats
UI.pod(set, :stats, statistics_provider)
UI.pod(set, :stats)
else
UI.pod(set, :normal)
end
......
......@@ -225,31 +225,12 @@ module Pod
@default_test_podfile_path ||= templates_dir + 'Podfile.test'
end
# @return [Pathname] The file to use a cache of the statistics provider.
#
def statistics_cache_file
cache_root + 'statistics.yml'
end
# @return [Pathname] The file to use to cache the search data.
#
def search_index_file
cache_root + 'search_index.yaml'
end
public
#-------------------------------------------------------------------------#
# @!group Dependency Injection
# @return [Specification::Set::Statistics] The statistic provider to use
# for specifications.
#
def spec_statistics_provider
Specification::Set::Statistics.new(statistics_cache_file)
end
private
#-------------------------------------------------------------------------#
......
......@@ -156,11 +156,11 @@ module Pod
# Prints the textual representation of a given set.
#
def pod(set, mode = :normal, statistics_provider = nil)
def pod(set, mode = :normal)
if mode == :name_and_version
puts_indented "#{set.name} #{set.versions.first.version}"
else
pod = Specification::Set::Presenter.new(set, statistics_provider)
pod = Specification::Set::Presenter.new(set)
title = "\n-> #{pod.name} (#{pod.version})"
if pod.spec.deprecated?
title += " #{pod.deprecation_description}"
......@@ -174,17 +174,16 @@ module Pod
puts_indented "pod '#{pod.name}', '~> #{pod.version}'"
labeled('Homepage', pod.homepage)
labeled('Source', pod.source_url)
labeled('Versions', pod.verions_by_source)
labeled('Versions', pod.versions_by_source)
if mode == :stats
labeled('Pushed', pod.github_last_activity)
labeled('Authors', pod.authors) if pod.authors =~ /,/
labeled('Author', pod.authors) if pod.authors !~ /,/
labeled('License', pod.license)
labeled('Platform', pod.platform)
labeled('Watchers', pod.github_watchers)
labeled('Stars', pod.github_stargazers)
labeled('Forks', pod.github_forks)
end
labeled('Sub specs', pod.subspecs)
labeled('Subspecs', pod.subspecs)
end
end
end
......
......@@ -17,21 +17,6 @@ module Pod
].each { |regex| out.should =~ regex }
end
it 'returns the new pods' do
sets = SourcesManager.aggregate.all_sets
jsonkit_set = sets.find { |s| s.name == 'JSONKit' }
dates = {
'BananaLib' => Time.now,
'JSONKit' => Time.parse('01/01/1970'),
'Pod+With+Plus+Signs' => Time.parse('01/01/1970'),
}
Specification::Set::Statistics.any_instance.stubs(:creation_dates).returns(dates)
out = run_command('list', 'new')
out.should.include('BananaLib')
out.should.not.include('JSONKit')
out.should.not.include('Pod+With+Plus+Signs')
end
it 'presents the known pods with versions' do
sets = SourcesManager.aggregate.all_sets
jsonkit_set = sets.find { |s| s.name == 'JSONKit' }
......
......@@ -41,17 +41,15 @@ module Pod
end
it 'presents the stats of a specification set' do
Specification::Set::Presenter.any_instance.expects(:github_last_activity).returns('more than a year ago')
Specification::Set::Presenter.any_instance.expects(:github_watchers).returns('318')
Specification::Set::Presenter.any_instance.expects(:github_stargazers).returns('318')
Specification::Set::Presenter.any_instance.expects(:github_forks).returns('42')
UI.pod(@set, :stats)
output = UI.output
output.should.include? 'Author: Robbie Hanson'
output.should.include? 'License: BSD'
output.should.include? 'Platform: iOS 5.0 - OS X 10.7'
output.should.include? 'Watchers: 318'
output.should.include? 'Stars: 318'
output.should.include? 'Forks: 42'
output.should.include? 'Pushed: more than a year ago'
end
it 'should print at least one subspec' do
......
......@@ -120,10 +120,6 @@ module Pod
end
end
it 'returns the statistics cache file' do
@sut.statistics_cache_file.to_s.should.end_with?('statistics.yml')
end
it 'returns the search index file' do
@sut.search_index_file.to_s.should.end_with?('search_index.yaml')
end
......@@ -153,17 +149,6 @@ module Pod
#-------------------------------------------------------------------------#
describe 'Dependency Injection' do
it 'returns the specification statistics provider' do
stats_provider = @sut.spec_statistics_provider
stats_provider.cache_file.should == @sut.cache_root + 'statistics.yml'
end
end
#-------------------------------------------------------------------------#
describe 'Private helpers' do
it 'returns the path of the user settings file' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment