diff options
author | Carl Lerche <carllerche@mac.com> | 2010-06-01 17:05:12 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-06-01 21:46:33 -0700 |
commit | 0ffe385f5889d3cb45dfd1d7cb4d95ad8e786df3 (patch) | |
tree | 7e157fe863656854ac5836bcb06989c4c729ff98 /lib/bundler/definition.rb | |
parent | 33f8e7d73077d4f8b57387ec44887d0a7f70594f (diff) | |
download | bundler-0ffe385f5889d3cb45dfd1d7cb4d95ad8e786df3.tar.gz |
wip
Diffstat (limited to 'lib/bundler/definition.rb')
-rw-r--r-- | lib/bundler/definition.rb | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index c2de990b..b332f26c 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -3,7 +3,7 @@ require "digest/sha1" # TODO: In the 0.10 release, there shouldn't be a locked subclass of Definition module Bundler class Definition - attr_reader :dependencies, :sources, :locked_specs, :platforms + attr_reader :dependencies, :sources, :platforms def self.build(gemfile, lockfile) gemfile = Pathname.new(gemfile).expand_path @@ -48,7 +48,7 @@ module Bundler source.unlock! if source.respond_to?(:unlock!) # Add all the spec names that are part of the source to unlock - @unlock.concat locked_specs. + @unlock.concat @locked_specs. select { |s| s.source == source }. map { |s| s.name } @@ -84,17 +84,6 @@ module Bundler sources.length == 1 && sources.first.remotes.empty? end - # TODO: OMG LOL - def resolver_dependencies - @resolver_dependencies ||= begin - deps = locked_specs_as_deps - dependencies.each do |dep| - deps << dep unless deps.any? { |d| d.name == dep.name } - end - deps - end - end - def groups dependencies.map { |d| d.groups }.flatten.uniq end @@ -172,21 +161,16 @@ module Bundler # # This allows us to add on the *new* requirements in the Gemfile and make # sure that the changes result in a conservative update to the Gemfile.lock. - def locked_specs_as_deps + def locked_specs deps = [] + @dependencies.each do |dep| if in_locked_deps?(dep) || satisfies_locked_spec?(dep) deps << dep end end - @locked_specs.for(deps, @unlock).map do |s| - dep = Gem::Dependency.new(s.name, s.version) - @locked_deps.each do |d| - dep.source = d.source if d.name == dep.name - end - dep - end + @locked_specs.for(deps, @unlock) end def in_locked_deps?(dep) @@ -201,25 +185,30 @@ module Bundler def resolve(type, idx) source_requirements = {} - resolver_dependencies.each do |dep| + dependencies.each do |dep| next unless dep.source source_requirements[dep.name] = dep.source.send(type) end # Run a resolve against the locally available gems - Resolver.resolve(resolver_dependencies, idx, source_requirements) + specs = Resolver.resolve(dependencies, idx, source_requirements, locked_specs) + specs.each do |spec| + next unless spec.is_a?(LazySpecification) + spec.__materialize__(spec.source.send(type)) + end + specs end def resolve_remote_specs # An ambiguous dependency is any dependency that does not have # a requirement on an explicit version. If there are any, then # we must do a remote resolve. - if resolver_dependencies.any? { |d| ambiguous?(d) } + if dependencies.any? { |d| ambiguous?(d) } return resolve(:specs, remote_index) end # Simple logic for now. Can improve later. - if specs.length == resolver_dependencies.length + if specs.length == dependencies.length return specs else return resolve(:specs, remote_index) |