[Source] list the name of the repos.

This commit is contained in:
Fabio Pelosin
2012-09-19 00:36:08 +02:00
parent ffe952812f
commit 329f29ba0c
2 changed files with 21 additions and 7 deletions

View File

@@ -2,14 +2,20 @@ module Pod
class Source
class Aggregate
def all
@sources ||= begin
repos_dir = Config.instance.repos_dir
unless repos_dir.exist?
raise Informative, "No spec repos found in `#{repos_dir}'. " \
"To fetch the `master' repo run: $ pod setup"
end
repos_dir.children.select(&:directory?).map { |repo| Source.new(repo) }
@sources ||= dirs.map { |repo| Source.new(repo) }
end
def dirs
repos_dir = Config.instance.repos_dir
unless repos_dir.exist?
raise Informative, "No spec repos found in `#{repos_dir}'. " \
"To fetch the `master' repo run: $ pod setup"
end
repos_dir.children.select(&:directory?)
end
def names
dirs.map { |repo| repo.basename.to_s }.sort
end
def all_sets
@@ -48,6 +54,10 @@ module Pod
Aggregate.new.search_by_name(name, full_text_search)
end
def self.names
Aggregate.new.names
end
attr_reader :repo
def initialize(repo)

View File

@@ -36,4 +36,8 @@ describe "Pod::Source" do
Pod::Source.search(Pod::Dependency.new('RestKit/DoesNotExist'))
}.should.raise Pod::Informative
end
it "return the names of the repos" do
Pod::Source.names.should == %w| repo1 repo2 |
end
end