aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/cli.rb4
-rw-r--r--lib/bundler/cli/binstubs.rb2
-rw-r--r--lib/bundler/cli/lock.rb5
-rw-r--r--lib/bundler/definition.rb59
-rw-r--r--lib/bundler/dsl.rb14
-rw-r--r--lib/bundler/endpoint_specification.rb4
-rw-r--r--lib/bundler/env.rb4
-rw-r--r--lib/bundler/fetcher.rb2
-rw-r--r--lib/bundler/fetcher/compact_index.rb4
-rw-r--r--lib/bundler/fetcher/dependency.rb4
-rw-r--r--lib/bundler/index.rb57
-rw-r--r--lib/bundler/inline.rb17
-rw-r--r--lib/bundler/remote_specification.rb10
-rw-r--r--lib/bundler/resolver.rb50
-rw-r--r--lib/bundler/rubygems_integration.rb4
-rw-r--r--lib/bundler/runtime.rb15
-rw-r--r--lib/bundler/source.rb5
-rw-r--r--lib/bundler/source/gemspec.rb13
-rw-r--r--lib/bundler/source/path.rb8
-rw-r--r--lib/bundler/source/rubygems.rb1
-rw-r--r--lib/bundler/source_list.rb6
-rw-r--r--lib/bundler/version.rb2
22 files changed, 174 insertions, 116 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 3e5b7e00..757643d2 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -233,6 +233,8 @@ module Bundler
"Overwrite existing binstubs if they exist"
method_option "path", :type => :string, :lazy_default => "bin", :banner =>
"Binstub destination directory (default bin)"
+ method_option "standalone", :type => :array, :lazy_default => [], :banner =>
+ "Make binstubs that can work without the Bundler runtime"
def binstubs(*gems)
require "bundler/cli/binstubs"
Binstubs.new(options, gems).run
@@ -427,6 +429,8 @@ module Bundler
"the path the lockfile should be written to"
method_option "full-index", :type => :boolean, :default => false, :banner =>
"Fall back to using the single-file index of all gems"
+ method_option "add-platform", :type => :array, :default => [], :banner =>
+ "add a new platform to the lockfile"
def lock
require "bundler/cli/lock"
Lock.new(options).run
diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb
index 8452ca3b..e8982e90 100644
--- a/lib/bundler/cli/binstubs.rb
+++ b/lib/bundler/cli/binstubs.rb
@@ -29,6 +29,8 @@ module Bundler
if spec.name == "bundler"
Bundler.ui.warn "Sorry, Bundler can only be run via Rubygems."
+ elsif options[:standalone]
+ installer.generate_standalone_bundler_executable_stubs(spec)
else
installer.generate_bundler_executable_stubs(spec, :force => options[:force], :binstubs_cmd => true)
end
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb
index e95e9ff6..ba9a3265 100644
--- a/lib/bundler/cli/lock.rb
+++ b/lib/bundler/cli/lock.rb
@@ -26,6 +26,11 @@ module Bundler
definition = Bundler.definition(true)
end
+ options["add-platform"].each do |platform|
+ platform = Gem::Platform.new(platform)
+ definition.add_platform(platform)
+ end
+
definition.resolve_remotely! unless options[:local]
if print
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 294d6567..02f8ee09 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -87,8 +87,7 @@ module Bundler
@unlock[:sources] ||= []
current_platform = Bundler.rubygems.platforms.map {|p| generic(p) }.compact.last
- @new_platform = !@platforms.include?(current_platform)
- @platforms |= [current_platform]
+ add_platform(current_platform)
@path_changes = converge_paths
eager_unlock = expand_dependencies(@unlock[:gems])
@@ -137,8 +136,17 @@ module Bundler
# @return [Bundler::SpecSet]
def specs
@specs ||= begin
- specs = resolve.materialize(Bundler.settings[:cache_all_platforms] ? dependencies : requested_dependencies)
-
+ begin
+ specs = resolve.materialize(Bundler.settings[:cache_all_platforms] ? dependencies : requested_dependencies)
+ rescue GemNotFound => e # Handle yanked gem
+ gem_name, gem_version = extract_gem_info(e)
+ locked_gem = @locked_specs[gem_name].last
+ raise if locked_gem.nil? || locked_gem.version.to_s != gem_version
+ raise GemNotFound, "Your bundle is locked to #{locked_gem}, but that version could not " \
+ "be found in any of the sources listed in your Gemfile. If you haven't changed sources, " \
+ "that means the author of #{locked_gem} has removed it. You'll need to update your bundle " \
+ "to a different version of #{locked_gem} that hasn't been removed in order to install."
+ end
unless specs["bundler"].any?
local = Bundler.settings[:frozen] ? rubygems_index : index
bundler = local.search(Gem::Dependency.new("bundler", VERSION)).last
@@ -216,7 +224,7 @@ module Bundler
source.dependency_names = dependency_names.dup
idx.add_source source.specs
dependency_names -= pinned_spec_names(source.specs)
- dependency_names.push(*source.unmet_deps).uniq!
+ dependency_names.concat(source.unmet_deps).uniq!
end
end
end
@@ -358,10 +366,20 @@ module Bundler
changed = []
gemfile_sources = sources.lock_sources
- if @locked_sources != gemfile_sources
- new_sources = gemfile_sources - @locked_sources
- deleted_sources = @locked_sources - gemfile_sources
+ new_sources = gemfile_sources - @locked_sources
+ deleted_sources = @locked_sources - gemfile_sources
+
+ new_deps = @dependencies - @locked_deps
+ deleted_deps = @locked_deps - @dependencies
+
+ # Check if it is possible that the source is only changed thing
+ if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
+ new_sources.reject! {|source| source.is_a_path? && source.path.exist? }
+ deleted_sources.reject! {|source| source.is_a_path? && source.path.exist? }
+ end
+
+ if @locked_sources != gemfile_sources
if new_sources.any?
added.concat new_sources.map {|source| "* source: #{source}" }
end
@@ -371,11 +389,7 @@ module Bundler
end
end
- new_deps = @dependencies - @locked_deps
- deleted_deps = @locked_deps - @dependencies
-
added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
-
if deleted_deps.any?
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" }
end
@@ -424,6 +438,11 @@ module Bundler
end
end
+ def add_platform(platform)
+ @new_platform ||= !@platforms.include?(platform)
+ @platforms |= [platform]
+ end
+
attr_reader :sources
private :sources
@@ -529,7 +548,15 @@ module Bundler
def converge_dependencies
(@dependencies + @locked_deps).each do |dep|
- dep.source = sources.get(dep.source) if dep.source
+ locked_source = @locked_deps.select {|d| d.name == dep.name }.last
+ # This is to make sure that if bundler is installing in deployment mode and
+ # after locked_source and sources don't match, we still use locked_source.
+ if Bundler.settings[:frozen] && !locked_source.nil? &&
+ locked_source.respond_to?(:source) && locked_source.source.instance_of?(Source::Path) && locked_source.source.path.exist?
+ dep.source = locked_source.source
+ elsif dep.source
+ dep.source = sources.get(dep.source)
+ end
end
Set.new(@dependencies) != Set.new(@locked_deps)
end
@@ -690,5 +717,11 @@ module Bundler
end
current == proposed
end
+
+ def extract_gem_info(error)
+ # This method will extract the error message like "Could not find foo-1.2.3 in any of the sources"
+ # to an array. The first element will be the gem name (e.g. foo), the second will be the version number.
+ error.message.scan(/Could not find (\w+)-(\d+(?:\.\d+)+)/).flatten
+ end
end
end
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index dacfeaa2..4208f9b5 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -67,16 +67,16 @@ module Bundler
"#{file}. Make sure you can build the gem, then try again"
end
+ @gemspecs << spec
+
gem_platforms = Bundler::Dependency::REVERSE_PLATFORM_MAP[Bundler::GemHelpers.generic_local_platform]
- gem spec.name, :path => path, :glob => glob, :platforms => gem_platforms
+ gem spec.name, :name => spec.name, :path => path, :glob => glob, :platforms => gem_platforms
group(development_group) do
spec.development_dependencies.each do |dep|
- gem dep.name, *(dep.requirement.as_list + [:type => :development])
+ gem dep.name, *(dep.requirement.as_list + [:type => :development, :platforms => gem_platforms])
end
end
-
- @gemspecs << gemspecs.first
when 0
raise InvalidOption, "There are no gemspecs at #{expanded_path}"
else
@@ -149,7 +149,11 @@ module Bundler
end
def path(path, options = {}, &blk)
- source_options = normalize_hash(options).merge("path" => Pathname.new(path), "root_path" => gemfile_root)
+ source_options = normalize_hash(options).merge(
+ "path" => Pathname.new(path),
+ "root_path" => gemfile_root,
+ "gemspec" => gemspecs.find {|g| g.name == options["name"] }
+ )
source = @sources.add_path_source(source_options)
with_source(source, &blk)
end
diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb
index b26fdaf9..69d05167 100644
--- a/lib/bundler/endpoint_specification.rb
+++ b/lib/bundler/endpoint_specification.rb
@@ -115,8 +115,8 @@ module Bundler
end
end
- def build_dependency(name, *requirements)
- Gem::Dependency.new(name, *requirements)
+ def build_dependency(name, requirements)
+ Gem::Dependency.new(name, requirements)
rescue ArgumentError => e
raise unless e.message.include?(ILLFORMED_MESSAGE)
puts # we shouldn't print the error message on the "fetching info" status line
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb
index baf6a10f..47e720a2 100644
--- a/lib/bundler/env.rb
+++ b/lib/bundler/env.rb
@@ -44,8 +44,8 @@ module Bundler
if print_gemspecs
dsl = Dsl.new.tap {|d| d.eval_gemfile(Bundler.default_gemfile) }
dsl.gemspecs.each do |gs|
- out << "\n#{Pathname.new(gs).basename}"
- out << "\n\n " << read_file(gs).gsub(/\n/, "\n ") << "\n"
+ out << "\n#{File.basename(gs.loaded_from)}"
+ out << "\n\n " << read_file(gs.loaded_from).gsub(/\n/, "\n ") << "\n"
end
end
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index 7da22f8e..fb9a4077 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -63,7 +63,7 @@ module Bundler
FAIL_ERRORS = begin
fail_errors = [AuthenticationRequiredError, BadAuthenticationError, FallbackError]
fail_errors << Gem::Requirement::BadRequirementError if defined?(Gem::Requirement::BadRequirementError)
- fail_errors.push(*NET_ERRORS.map {|e| SharedHelpers.const_get_safely(e, Net) }.compact)
+ fail_errors.concat(NET_ERRORS.map {|e| SharedHelpers.const_get_safely(e, Net) }.compact)
end.freeze
class << self
diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb
index 31557be0..c0e1b3b4 100644
--- a/lib/bundler/fetcher/compact_index.rb
+++ b/lib/bundler/fetcher/compact_index.rb
@@ -41,7 +41,7 @@ module Bundler
deps = compact_index_client.dependencies(remaining_gems)
next_gems = deps.map {|d| d[3].map(&:first).flatten(1) }.flatten(1).uniq
deps.each {|dep| gem_info << dep }
- complete_gems.push(*deps.map(&:first)).uniq!
+ complete_gems.concat(deps.map(&:first)).uniq!
remaining_gems = next_gems - complete_gems
end
@@ -89,7 +89,7 @@ module Bundler
worker_name = "Compact Index (#{display_uri.host})"
worker = Bundler::Worker.new(25, worker_name, func)
inputs.each {|input| worker.enq(input) }
- inputs.map { worker.deq }
+ inputs.map { worker.deq }.tap { worker.stop }
end
end
end
diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb
index 0e67375d..a145837a 100644
--- a/lib/bundler/fetcher/dependency.rb
+++ b/lib/bundler/fetcher/dependency.rb
@@ -54,7 +54,7 @@ module Bundler
gem_list = []
gem_names.each_slice(Source::Rubygems::API_REQUEST_SIZE) do |names|
marshalled_deps = downloader.fetch(dependency_api_uri(names)).body
- gem_list.push(*Bundler.load_marshal(marshalled_deps))
+ gem_list.concat(Bundler.load_marshal(marshalled_deps))
end
gem_list
end
@@ -64,7 +64,7 @@ module Bundler
spec_list = []
gem_list.each do |s|
- deps_list.push(*s[:dependencies].map(&:first))
+ deps_list.concat(s[:dependencies].map(&:first))
deps = s[:dependencies].map {|n, d| [n, d.split(", ")] }
spec_list.push([s[:name], s[:number], s[:platform], deps])
end
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index 5c490342..c28a1209 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -21,15 +21,14 @@ module Bundler
@sources = []
@cache = {}
@specs = Hash.new {|h, k| h[k] = {} }
- @all_specs = Hash.new {|h, k| h[k] = [] }
+ @all_specs = Hash.new {|h, k| h[k] = EMPTY_SEARCH }
end
def initialize_copy(o)
- super
- @sources = @sources.dup
+ @sources = o.sources.dup
@cache = {}
@specs = Hash.new {|h, k| h[k] = {} }
- @all_specs = Hash.new {|h, k| h[k] = [] }
+ @all_specs = Hash.new {|h, k| h[k] = EMPTY_SEARCH }
o.specs.each do |name, hash|
@specs[name] = hash.dup
@@ -49,7 +48,7 @@ module Bundler
end
def search_all(name)
- all_matches = @all_specs[name] + local_search(name)
+ all_matches = local_search(name) + @all_specs[name]
@sources.each do |source|
all_matches.concat(source.search_all(name))
end
@@ -60,19 +59,18 @@ module Bundler
# about, returning all of the results.
def search(query, base = nil)
results = local_search(query, base)
- seen = Set.new(results.map {|spec| [spec.name, spec.version, spec.platform] })
+ seen = results.map(&:full_name).to_set
@sources.each do |source|
source.search(query, base).each do |spec|
- lookup = [spec.name, spec.version, spec.platform]
- unless seen.include?(lookup)
- results << spec
- seen << lookup
- end
+ results << spec if seen.add?(spec.full_name)
end
end
- results.sort_by {|s| [s.version, s.platform.to_s == RUBY ? NULL : s.platform.to_s] }
+ results.sort_by do |s|
+ platform_string = s.platform.to_s
+ [s.version, platform_string == RUBY ? NULL : platform_string]
+ end
end
def local_search(query, base = nil)
@@ -90,14 +88,15 @@ module Bundler
def <<(spec)
@specs[spec.name][spec.full_name] = spec
-
spec
end
def each(&blk)
+ return enum_for(:each) unless blk
specs.values.each do |spec_sets|
spec_sets.values.each(&blk)
end
+ sources.each {|s| s.each(&blk) }
end
# returns a list of the dependencies
@@ -109,17 +108,17 @@ module Bundler
def dependency_names
names = []
- each {|s| names.push(*s.dependencies.map(&:name)) }
+ each {|s| names.concat(s.dependencies.map(&:name)) }
names.uniq
end
def use(other, override_dupes = false)
return unless other
other.each do |s|
- if (dupes = search_by_spec(s)) && dupes.any?
- @all_specs[s.name] = [s] + dupes
+ if (dupes = search_by_spec(s)) && !dupes.empty?
+ # safe to << since it's a new array when it has contents
+ @all_specs[s.name] = dupes << s
next unless override_dupes
- self << s
end
self << s
end
@@ -154,8 +153,10 @@ module Bundler
def search_by_dependency(dependency, base = nil)
@cache[base || false] ||= {}
@cache[base || false][dependency] ||= begin
- specs = specs_by_name(dependency.name) + (base || [])
+ specs = specs_by_name(dependency.name)
+ specs += base if base
found = specs.select do |spec|
+ next true if spec.source.is_a?(Source::Gemspec)
if base # allow all platforms when searching from a lockfile
dependency.matches_spec?(spec)
else
@@ -174,25 +175,11 @@ module Bundler
end
end
+ EMPTY_SEARCH = [].freeze
+
def search_by_spec(spec)
spec = @specs[spec.name][spec.full_name]
- spec ? [spec] : []
- end
-
- if RUBY_VERSION < "1.9"
- def same_version?(a, b)
- regex = /^(.*?)(?:\.0)*$/
- a.to_s[regex, 1] == b.to_s[regex, 1]
- end
- else
- def same_version?(a, b)
- a == b
- end
- end
-
- def spec_satisfies_dependency?(spec, dep)
- return false unless dep.name == spec.name
- dep.requirement.satisfied_by?(spec.version)
+ spec ? [spec] : EMPTY_SEARCH
end
end
end
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
index 1ad78c61..b6bddda5 100644
--- a/lib/bundler/inline.rb
+++ b/lib/bundler/inline.rb
@@ -48,8 +48,17 @@ def gemfile(install = false, options = {}, &gemfile)
def definition.lock(*); end
definition.validate_ruby!
- if install
- Bundler.ui = ui
+ missing_specs = proc do
+ begin
+ !definition.missing_specs.empty?
+ rescue Bundler::GemNotFound
+ definition.instance_variable_set(:@index, nil)
+ true
+ end
+ end
+
+ Bundler.ui = ui if install
+ if install || missing_specs.call
Bundler::Installer.install(Bundler.root, definition, :system => true)
Bundler::Installer.post_install_messages.each do |name, message|
Bundler.ui.info "Post-install message from #{name}:\n#{message}"
@@ -58,7 +67,7 @@ def gemfile(install = false, options = {}, &gemfile)
runtime = Bundler::Runtime.new(nil, definition)
runtime.setup.require
-
+ensure
bundler_module = class << Bundler; self; end
- bundler_module.send(:define_method, :root, old_root)
+ bundler_module.send(:define_method, :root, old_root) if old_root
end
diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb
index 29735fc6..6a02897c 100644
--- a/lib/bundler/remote_specification.rb
+++ b/lib/bundler/remote_specification.rb
@@ -66,6 +66,10 @@ module Bundler
[@name, @version, @platform == Gem::Platform::RUBY ? -1 : 1]
end
+ def to_s
+ "#<#{self.class} name=#{name} version=#{version} platform=#{platform}>"
+ end
+
private
def _remote_specification
@@ -75,11 +79,7 @@ module Bundler
end
def method_missing(method, *args, &blk)
- if Gem::Specification.new.respond_to?(method)
- _remote_specification.send(method, *args, &blk)
- else
- super
- end
+ _remote_specification.send(method, *args, &blk)
end
end
end
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 48f0d468..918b3c97 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -106,14 +106,8 @@ module Bundler
specs.values
end
- def activate_platform(platform)
- unless @activated.include?(platform)
- if for?(platform, nil)
- @activated << platform
- return __dependencies[platform] || []
- end
- end
- []
+ def activate_platform!(platform)
+ @activated << platform if !@activated.include?(platform) && for?(platform, nil)
end
def name
@@ -252,28 +246,34 @@ module Bundler
platform = dependency.__platform
dependency = dependency.dep unless dependency.is_a? Gem::Dependency
search = @search_for[dependency] ||= begin
- index = @source_requirements[dependency.name] || @index
+ index = index_for(dependency)
results = index.search(dependency, @base[dependency.name])
if vertex = @base_dg.vertex_named(dependency.name)
locked_requirement = vertex.payload.requirement
end
if results.any?
- version = results.first.version
- nested = [[]]
+ nested = []
results.each do |spec|
- if spec.version != version
- nested << []
- version = spec.version
+ version, specs = nested.last
+ if version == spec.version
+ specs << spec
+ else
+ nested << [spec.version, [spec]]
end
- nested.last << spec
end
- groups = nested.map {|a| SpecGroup.new(a) }
- !locked_requirement ? groups : groups.select {|sg| locked_requirement.satisfied_by? sg.version }
+ nested.reduce([]) do |groups, (version, specs)|
+ next groups if locked_requirement && !locked_requirement.satisfied_by?(version)
+ groups << SpecGroup.new(specs)
+ end
else
[]
end
end
- search.select {|sg| sg.for?(platform, @ruby_version) }.each {|sg| sg.activate_platform(platform) }
+ search.select {|sg| sg.for?(platform, @ruby_version) }.each {|sg| sg.activate_platform!(platform) }
+ end
+
+ def index_for(dependency)
+ @source_requirements[dependency.name] || @index
end
def name_for(dependency)
@@ -293,7 +293,7 @@ module Bundler
end
def requirement_satisfied_by?(requirement, activated, spec)
- requirement.matches_spec?(spec)
+ requirement.matches_spec?(spec) || spec.source.is_a?(Source::Gemspec)
end
def sort_dependencies(dependencies, activated, conflicts)
@@ -314,14 +314,12 @@ module Bundler
if (base = @base[dependency.name]) && !base.empty?
dependency.requirement.satisfied_by?(base.first.version) ? 0 : 1
else
- base_dep = Dependency.new dependency.name, ">= 0.a"
- all = search_for(DepProxy.new base_dep, dependency.__platform).size.to_f
- if all.zero?
- 0
- elsif (search = search_for(dependency).size.to_f) == all && all == 1
- 0
+ all = index_for(dependency).search(dependency.name).size
+ if all <= 1
+ all
else
- search / all
+ search = search_for(dependency).size
+ search - all
end
end
end
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 8a0fdbae..41ebc87c 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -212,7 +212,7 @@ module Bundler
# Fetch all specs, minus prerelease specs
spec_list = fetch_specs(true, false)
# Then fetch the prerelease specs
- fetch_prerelease_specs.each {|k, v| spec_list[k].push(*v) }
+ fetch_prerelease_specs.each {|k, v| spec_list[k].concat(v) }
spec_list.values.first
ensure
@@ -605,7 +605,7 @@ module Bundler
specs = fetch_specs(source, remote, "specs")
pres = fetch_specs(source, remote, "prerelease_specs") || []
- specs.push(*pres)
+ specs.concat(pres)
end
def download_gem(spec, uri, path)
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index 6f02ad85..3a86fe92 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -68,9 +68,9 @@ module Bundler
groups = [:default] if groups.empty?
@definition.dependencies.each do |dep|
- # Skip the dependency if it is not in any of the requested
- # groups
- next unless (dep.groups & groups).any? && dep.current_platform?
+ # Skip the dependency if it is not in any of the requested groups, or
+ # not for the current platform, or doesn't match the gem constraints.
+ next unless (dep.groups & groups).any? && dep.should_include?
required_file = nil
@@ -117,16 +117,9 @@ module Bundler
Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
- # Do not try to cache specification for the gem described any of the gemspecs
- root_gem_names = nil
- if gemspec_cache_hash = Bundler.instance_variable_get(:@gemspec_cache)
- gemspecs = gemspec_cache_hash.values
- root_gem_names = gemspecs.map(&:name)
- end
-
specs.each do |spec|
next if spec.name == "bundler"
- next if !Dir.glob("*.gemspec").empty? && spec.source.class == Bundler::Source::Path && root_gem_names.include?(spec.name)
+ next if spec.source.is_a?(Source::Gemspec)
spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true)
spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
end
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index eee4ade4..afa7d918 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
module Bundler
class Source
- autoload :Rubygems, "bundler/source/rubygems"
- autoload :Path, "bundler/source/path"
+ autoload :Gemspec, "bundler/source/gemspec"
autoload :Git, "bundler/source/git"
+ autoload :Path, "bundler/source/path"
+ autoload :Rubygems, "bundler/source/rubygems"
attr_accessor :dependency_names
diff --git a/lib/bundler/source/gemspec.rb b/lib/bundler/source/gemspec.rb
new file mode 100644
index 00000000..37e9a439
--- /dev/null
+++ b/lib/bundler/source/gemspec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+module Bundler
+ class Source
+ class Gemspec < Path
+ attr_reader :gemspec
+
+ def initialize(options)
+ super
+ @gemspec = options["gemspec"]
+ end
+ end
+ end
+end
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index bfead5c3..bbdd30b1 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -60,8 +60,8 @@ module Bundler
end
def eql?(other)
- other.instance_of?(Path) &&
- expanded_path == expand(other.path) &&
+ return unless other.class == Path || other.class == Gemspec
+ expanded_path == expand(other.path) &&
version == other.version
end
@@ -111,6 +111,10 @@ module Bundler
Bundler.root
end
+ def is_a_path?
+ instance_of?(Path)
+ end
+
private
def expanded_path
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 369de4fc..a7721de8 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -27,6 +27,7 @@ module Bundler
end
def remote!
+ @specs = nil
@allow_remote = true
end
diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb
index dc62c892..0595cbdc 100644
--- a/lib/bundler/source_list.rb
+++ b/lib/bundler/source_list.rb
@@ -12,7 +12,11 @@ module Bundler
end
def add_path_source(options = {})
- add_source_to_list Source::Path.new(options), path_sources
+ if options["gemspec"]
+ add_source_to_list Source::Gemspec.new(options), path_sources
+ else
+ add_source_to_list Source::Path.new(options), path_sources
+ end
end
def add_git_source(options = {})
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index db93547b..b1e8a49e 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -7,5 +7,5 @@ module Bundler
# We're doing this because we might write tests that deal
# with other versions of bundler and we are unsure how to
# handle this better.
- VERSION = "1.12.4" unless defined?(::Bundler::VERSION)
+ VERSION = "1.12.5" unless defined?(::Bundler::VERSION)
end