Permalink
Browse files

checkpoint

  • Loading branch information...
1 parent cac2574 commit 8709a13333ade7834378931f07fdd711917a56ec osheroff committed Jan 22, 2012
Showing with 22 additions and 17 deletions.
  1. +14 −16 lib/bundler/definition.rb
  2. +8 −1 lib/bundler/dsl.rb
View
@@ -29,11 +29,12 @@ def self.build(gemfile, lockfile, unlock)
specs, then we can try to resolve locally.
=end
- def initialize(lockfile, dependencies, sources, unlock)
+ def initialize(lockfile, dependencies, sources, unlock, local_overrides = nil)
@dependencies, @sources, @unlock = dependencies, sources, unlock
@remote = false
@specs = nil
@lockfile_contents = ""
+ @local_overrides = local_overrides
if lockfile && File.exists?(lockfile)
@lockfile_contents = Bundler.read_file(lockfile)
@@ -151,27 +152,24 @@ def resolve_specs(with_local_override)
source_requirements[dep.name] = dep.source.specs
end
- if with_local_override
- path = nil
- local_overrides = Index.build do |local|
- path = Bundler::Source::Path.new("name" => "bundler_test_gem", "path" => "~/src/bundler_test_gem")
- local.add_source path.specs
+ override_index = Index.new
+
+ if with_local_override && @local_overrides
+ @local_overrides && @local_overrides.each do |s|
+ override_index.add_source s.specs
end
- #source_requirements["bundler_test_gem"] = nil
end
- local_resolve = Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, local_overrides)
+ local_resolve = Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, override_index)
# for all of the local-override gems that were resolved, pop them out of the lockfile-resolved list
# so that we don't duplicate gems
- if local_overrides
- local_resolve.to_a.each do |s|
- if local_overrides[s.name].any?
- if (res = local_resolve[s.name]) && res.first.source.class == Bundler::Source::Path
- last_resolve.delete(s.name)
- else
- Bundler.ui.warn("Couln't use local copy of #{s.name}, perhaps it's out of date?")
- end
+ local_resolve.to_a.each do |s|
+ if override_index[s.name].any?
+ if last_resolve[s.name]
+ last_resolve.delete(s.name)
+ else
+ Bundler.ui.warn("Couln't use #{s.name} from #{s.source.path}, perhaps it's out of date?")
end
end
end
View
@@ -14,6 +14,7 @@ def initialize
@rubygems_source = Source::Rubygems.new
@source = nil
@sources = []
+ @local_overrides = []
@dependencies = []
@groups = []
@platforms = []
@@ -108,6 +109,12 @@ def source(source, options = {})
@source = nil
end
+ def local(name, path)
+ if File.directory?(File.expand_path(path, Bundler.root))
+ @local_overrides << Bundler::Source::Path.new("name" => name, "path" => path)
+ end
+ end
+
def path(path, options = {}, source_options = {}, &blk)
source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk
end
@@ -129,7 +136,7 @@ def git(uri, options = {}, source_options = {}, &blk)
def to_definition(lockfile, unlock)
@sources << @rubygems_source unless @sources.include?(@rubygems_source)
- Definition.new(lockfile, @dependencies, @sources, unlock)
+ Definition.new(lockfile, @dependencies, @sources, unlock, @local_overrides)
end
def group(*args, &blk)

0 comments on commit 8709a13

Please sign in to comment.