Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
add child sources to Index
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed May 18, 2011
1 parent 6e2ceab commit 84fdb60
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
7 changes: 3 additions & 4 deletions lib/bundler/definition.rb
Expand Up @@ -160,7 +160,7 @@ def resolve
def index
@index ||= Index.build do |idx|
@sources.each do |s|
idx.use s.specs
idx.add_source s.specs
end
end
end
Expand All @@ -169,9 +169,8 @@ def index
# spec, even if (say) a git gem is not checked out.
def rubygems_index
@rubygems_index ||= Index.build do |idx|
@sources.find_all{|s| s.is_a?(Source::Rubygems) }.each do |s|
idx.use s.specs
end
rubygems = @sources.find{|s| s.is_a?(Source::Rubygems) }
idx.add_source(rubygems)
end
end

Expand Down
21 changes: 15 additions & 6 deletions lib/bundler/index.rb
Expand Up @@ -33,7 +33,17 @@ def empty?
true
end

# Search this index's specs, and any source indexes that this index knows
# about, returning all of the results.
def search(query)
results = local_search(query)
@sources.each do |source|
results << source.search(query)
end
results
end

def local_search(query)
case query
when Gem::Specification, RemoteSpecification, LazySpecification then search_by_spec(query)
when String then specs_by_name(query)
Expand Down Expand Up @@ -69,12 +79,6 @@ def search_by_dependency(dependency, base = nil)
end
end

def sources
specs.values.map do |specs|
specs.map{|s| s.source }
end.flatten.uniq
end

def source_types
sources.map{|s| s.class }.uniq
end
Expand Down Expand Up @@ -113,6 +117,11 @@ def ==(o)
end
end

def add_source(source)
raise ArgumentError, "Source must be an index, not #{source.class}" unless source.is_a?(Index)
@sources << source
end

private

def search_by_spec(spec)
Expand Down

0 comments on commit 84fdb60

Please sign in to comment.