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' ...@@ -15,7 +15,7 @@ gem 'json', '1.7.7'
group :development do group :development do
cp_gem 'claide', 'CLAide' 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-downloader', 'cocoapods-downloader'
cp_gem 'cocoapods-plugins', 'cocoapods-plugins' cp_gem 'cocoapods-plugins', 'cocoapods-plugins'
cp_gem 'cocoapods-trunk', 'cocoapods-trunk' cp_gem 'cocoapods-trunk', 'cocoapods-trunk'
......
...@@ -7,8 +7,8 @@ GIT ...@@ -7,8 +7,8 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Core.git remote: https://github.com/CocoaPods/Core.git
revision: 49a91acc2b1b9812352fa3605141215fbcc1e466 revision: 800948c15b79203c0642135a91ec29354bee3fb7
branch: master branch: seg-delete-statistics
specs: specs:
cocoapods-core (0.35.0) cocoapods-core (0.35.0)
activesupport (>= 3.2.15) activesupport (>= 3.2.15)
......
...@@ -34,41 +34,6 @@ module Pod ...@@ -34,41 +34,6 @@ module Pod
end 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 end
end end
...@@ -84,11 +84,10 @@ module Pod ...@@ -84,11 +84,10 @@ module Pod
sets.reject! { |set| !set.specification.available_platforms.map(&:name).include?(:osx) } sets.reject! { |set| !set.specification.available_platforms.map(&:name).include?(:osx) }
end end
statistics_provider = Config.instance.spec_statistics_provider
sets.each do |set| sets.each do |set|
begin begin
if @stats if @stats
UI.pod(set, :stats, statistics_provider) UI.pod(set, :stats)
else else
UI.pod(set, :normal) UI.pod(set, :normal)
end end
......
...@@ -225,31 +225,12 @@ module Pod ...@@ -225,31 +225,12 @@ module Pod
@default_test_podfile_path ||= templates_dir + 'Podfile.test' @default_test_podfile_path ||= templates_dir + 'Podfile.test'
end 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. # @return [Pathname] The file to use to cache the search data.
# #
def search_index_file def search_index_file
cache_root + 'search_index.yaml' cache_root + 'search_index.yaml'
end 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 private
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
...@@ -156,11 +156,11 @@ module Pod ...@@ -156,11 +156,11 @@ module Pod
# Prints the textual representation of a given set. # 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 if mode == :name_and_version
puts_indented "#{set.name} #{set.versions.first.version}" puts_indented "#{set.name} #{set.versions.first.version}"
else else
pod = Specification::Set::Presenter.new(set, statistics_provider) pod = Specification::Set::Presenter.new(set)
title = "\n-> #{pod.name} (#{pod.version})" title = "\n-> #{pod.name} (#{pod.version})"
if pod.spec.deprecated? if pod.spec.deprecated?
title += " #{pod.deprecation_description}" title += " #{pod.deprecation_description}"
...@@ -174,17 +174,16 @@ module Pod ...@@ -174,17 +174,16 @@ module Pod
puts_indented "pod '#{pod.name}', '~> #{pod.version}'" puts_indented "pod '#{pod.name}', '~> #{pod.version}'"
labeled('Homepage', pod.homepage) labeled('Homepage', pod.homepage)
labeled('Source', pod.source_url) labeled('Source', pod.source_url)
labeled('Versions', pod.verions_by_source) labeled('Versions', pod.versions_by_source)
if mode == :stats if mode == :stats
labeled('Pushed', pod.github_last_activity)
labeled('Authors', pod.authors) if pod.authors =~ /,/ labeled('Authors', pod.authors) if pod.authors =~ /,/
labeled('Author', pod.authors) if pod.authors !~ /,/ labeled('Author', pod.authors) if pod.authors !~ /,/
labeled('License', pod.license) labeled('License', pod.license)
labeled('Platform', pod.platform) labeled('Platform', pod.platform)
labeled('Watchers', pod.github_watchers) labeled('Stars', pod.github_stargazers)
labeled('Forks', pod.github_forks) labeled('Forks', pod.github_forks)
end end
labeled('Sub specs', pod.subspecs) labeled('Subspecs', pod.subspecs)
end end
end end
end end
......
...@@ -17,21 +17,6 @@ module Pod ...@@ -17,21 +17,6 @@ module Pod
].each { |regex| out.should =~ regex } ].each { |regex| out.should =~ regex }
end 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 it 'presents the known pods with versions' do
sets = SourcesManager.aggregate.all_sets sets = SourcesManager.aggregate.all_sets
jsonkit_set = sets.find { |s| s.name == 'JSONKit' } jsonkit_set = sets.find { |s| s.name == 'JSONKit' }
......
...@@ -41,17 +41,15 @@ module Pod ...@@ -41,17 +41,15 @@ module Pod
end end
it 'presents the stats of a specification set' do 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_stargazers).returns('318')
Specification::Set::Presenter.any_instance.expects(:github_watchers).returns('318')
Specification::Set::Presenter.any_instance.expects(:github_forks).returns('42') Specification::Set::Presenter.any_instance.expects(:github_forks).returns('42')
UI.pod(@set, :stats) UI.pod(@set, :stats)
output = UI.output output = UI.output
output.should.include? 'Author: Robbie Hanson' output.should.include? 'Author: Robbie Hanson'
output.should.include? 'License: BSD' output.should.include? 'License: BSD'
output.should.include? 'Platform: iOS 5.0 - OS X 10.7' 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? 'Forks: 42'
output.should.include? 'Pushed: more than a year ago'
end end
it 'should print at least one subspec' do it 'should print at least one subspec' do
......
...@@ -120,10 +120,6 @@ module Pod ...@@ -120,10 +120,6 @@ module Pod
end end
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 it 'returns the search index file' do
@sut.search_index_file.to_s.should.end_with?('search_index.yaml') @sut.search_index_file.to_s.should.end_with?('search_index.yaml')
end end
...@@ -153,17 +149,6 @@ module Pod ...@@ -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 describe 'Private helpers' do
it 'returns the path of the user settings file' 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