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

Commit

Permalink
add a dependency list attr to Source::Rubygems
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed May 18, 2011
1 parent 0235ed7 commit 6e2ceab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 3 additions & 1 deletion lib/bundler/definition.rb
Expand Up @@ -160,11 +160,13 @@ def resolve
def index
@index ||= Index.build do |idx|
@sources.each do |s|
idx.use s.specs(@dependencies)
idx.use s.specs
end
end
end

# used when frozen is enabled so we can find the bundler
# 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|
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/dsl.rb
Expand Up @@ -112,8 +112,8 @@ def git(uri, options = {}, source_options = {}, &blk)
end

def to_definition(lockfile, unlock)
@sources << @rubygems_source
@sources.uniq!
@rubygems_source.dependencies = @dependencies
@sources << @rubygems_source unless @sources.include?(@rubygems_source)
Definition.new(lockfile, @dependencies, @sources, unlock)
end

Expand Down
17 changes: 8 additions & 9 deletions lib/bundler/source.rb
Expand Up @@ -11,6 +11,7 @@ module Source
# TODO: Refactor this class
class Rubygems
attr_reader :remotes, :caches
attr_accessor :dependencies

def initialize(options = {})
@options = options
Expand Down Expand Up @@ -65,8 +66,8 @@ def to_s
end
alias_method :name, :to_s

def specs(dependencies = nil)
@specs ||= fetch_specs(dependencies)
def specs
@specs ||= fetch_specs
end

def fetch(spec)
Expand Down Expand Up @@ -154,11 +155,11 @@ def normalize_uri(uri)
uri
end

def fetch_specs(dependencies = nil)
def fetch_specs
Index.build do |idx|
idx.use installed_specs
idx.use cached_specs if @allow_cached || @allow_remote
idx.use remote_specs(dependencies) if @allow_remote
idx.use remote_specs if @allow_remote
end
end

Expand Down Expand Up @@ -214,18 +215,16 @@ def cached_specs
idx
end

def remote_specs(dependencies = nil)
def remote_specs
@remote_specs ||= begin
idx = Index.new
old = Bundler.rubygems.sources

remotes.each do |uri|

@fetchers[uri] = Bundler::Fetcher.new(uri)
gem_names =
if dependencies
dependencies.map {|d| d.name }
end
gem_names = dependencies && dependencies.map{|d| d.name }

@fetchers[uri].fetch_remote_specs(gem_names) do |n,v|
v.each do |name, version, platform|
next if name == 'bundler'
Expand Down

0 comments on commit 6e2ceab

Please sign in to comment.