Commit 76a369ae authored by Fabio Pelosin's avatar Fabio Pelosin

[SourcesManager] Cleanup

parent 6d3821be
...@@ -23,7 +23,7 @@ module Pod ...@@ -23,7 +23,7 @@ module Pod
def run def run
update_if_necessary! update_if_necessary!
sets = SourcesManager.all_sets sets = SourcesManager.aggregate.all_sets
sets.each { |set| UI.pod(set, :name_and_version) } sets.each { |set| UI.pod(set, :name_and_version) }
UI.puts "\n#{sets.count} pods were found" UI.puts "\n#{sets.count} pods were found"
end end
...@@ -47,7 +47,7 @@ module Pod ...@@ -47,7 +47,7 @@ module Pod
days = [1, 2, 3, 5, 8] days = [1, 2, 3, 5, 8]
dates, groups = {}, {} dates, groups = {}, {}
days.each { |d| dates[d] = Time.now - 60 * 60 * 24 * d } days.each { |d| dates[d] = Time.now - 60 * 60 * 24 * d }
sets = SourcesManager.all_sets sets = SourcesManager.aggregate.all_sets
statistics_provider = Config.instance.spec_statistics_provider statistics_provider = Config.instance.spec_statistics_provider
creation_dates = statistics_provider.creation_dates(sets) creation_dates = statistics_provider.creation_dates(sets)
......
...@@ -5,19 +5,11 @@ module Pod ...@@ -5,19 +5,11 @@ module Pod
class << self class << self
include Config::Mixin include Config::Mixin
# @return [Source::Aggregate] The aggregate of the sources with the given # @return [Source::Aggregate] The aggregate of all the sources with the
# Pods. # known Pods.
# #
# @param [Array<#to_s>] source_names def aggregate
# The names of the sources. If not given all the sources will be dirs = config.repos_dir.children.select(&:directory?)
# returned.
#
def aggregate(source_names = nil)
if source_names
dirs = source_names.map { |name| source_dir(name) }
else
dirs = config.repos_dir.children.select(&:directory?)
end
Source::Aggregate.new(dirs) Source::Aggregate.new(dirs)
end end
...@@ -45,13 +37,6 @@ module Pod ...@@ -45,13 +37,6 @@ module Pod
sources(['master']) sources(['master'])
end end
# @return [Array<Specification::Set>] the list of all the specification
# sets know to this installation of CocoaPods.
#
def all_sets
aggregate.all_sets
end
# Search all the sources to match the set for the given dependency. # Search all the sources to match the set for the given dependency.
# #
# @return [Set, nil] a set for a given dependency including all the # @return [Set, nil] a set for a given dependency including all the
...@@ -152,10 +137,7 @@ module Pod ...@@ -152,10 +137,7 @@ module Pod
Config.instance.search_index_file Config.instance.search_index_file
end end
public
# @!group Updating Sources # @!group Updating Sources
#-----------------------------------------------------------------------#
extend Executable extend Executable
executable :git executable :git
...@@ -293,10 +275,7 @@ module Pod ...@@ -293,10 +275,7 @@ module Pod
end end
end end
public
# @!group Master repo # @!group Master repo
#-----------------------------------------------------------------------#
# @return [Pathname] The path of the master repo. # @return [Pathname] The path of the master repo.
# #
...@@ -313,11 +292,6 @@ module Pod ...@@ -313,11 +292,6 @@ module Pod
master_repo_dir.exist? && repo_compatible?(master_repo_dir) master_repo_dir.exist? && repo_compatible?(master_repo_dir)
end end
public
# @!group Source repos
#-----------------------------------------------------------------------#
private private
# @return [Bool] Whether the given path is writable by the current user. # @return [Bool] Whether the given path is writable by the current user.
...@@ -360,8 +334,7 @@ module Pod ...@@ -360,8 +334,7 @@ module Pod
# The name of the source. # The name of the source.
# #
def source_dir(name) def source_dir(name)
dir = config.repos_dir + name if dir = config.repos_dir + name
if dir
dir dir
else else
raise Informative, "Unable to find the `#{name}` repo." raise Informative, "Unable to find the `#{name}` repo."
......
...@@ -18,7 +18,7 @@ module Pod ...@@ -18,7 +18,7 @@ module Pod
end end
it 'returns the new pods' do it 'returns the new pods' do
sets = SourcesManager.all_sets sets = SourcesManager.aggregate.all_sets
jsonkit_set = sets.find { |s| s.name == 'JSONKit' } jsonkit_set = sets.find { |s| s.name == 'JSONKit' }
dates = { dates = {
'BananaLib' => Time.now, 'BananaLib' => Time.now,
...@@ -30,7 +30,7 @@ module Pod ...@@ -30,7 +30,7 @@ module Pod
end end
it 'presents the known pods with versions' do it 'presents the known pods with versions' do
sets = SourcesManager.all_sets sets = SourcesManager.aggregate.all_sets
jsonkit_set = sets.find { |s| s.name == 'JSONKit' } jsonkit_set = sets.find { |s| s.name == 'JSONKit' }
out = run_command('list') out = run_command('list')
......
...@@ -48,10 +48,6 @@ module Pod ...@@ -48,10 +48,6 @@ module Pod
SourcesManager.all.map(&:name).should == %w[master test_repo] SourcesManager.all.map(&:name).should == %w[master test_repo]
end end
it "returns all the sets" do
SourcesManager.all_sets.map(&:name).should.include?('BananaLib')
end
it "searches for the set of a dependency" do it "searches for the set of a dependency" do
set = SourcesManager.search(Dependency.new('BananaLib')) set = SourcesManager.search(Dependency.new('BananaLib'))
set.class.should == Specification::Set set.class.should == Specification::Set
......
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