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

[SourcesManager] Cleanup

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