summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2018-08-07 00:15:10 -0700
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-10 17:47:39 +0100
commitcf245d61559b53f6c5f110778cdbe47a437b1142 (patch)
tree06b1a78eb997d741f57355f7c38c9d2317a29ecb
parent140b5de76f2e23fc44333d55efb689ad27a81828 (diff)
downloadbundler-cf245d61559b53f6c5f110778cdbe47a437b1142.tar.gz
[StubSpecification] Fix up the stubs to_spec whenever it is referenced
-rw-r--r--lib/bundler/stub_specification.rb21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb
index d45f80a80a..08b7507d86 100644
--- a/lib/bundler/stub_specification.rb
+++ b/lib/bundler/stub_specification.rb
@@ -11,7 +11,13 @@ module Bundler
spec
end
- attr_accessor :stub, :ignored
+ def initialize(*)
+ @_remote_specification = nil
+ super
+ end
+
+ attr_accessor :ignored
+ attr_writer :stub
def source=(source)
super
@@ -71,14 +77,21 @@ module Bundler
stub.raw_require_paths
end
+ def stub
+ if !@_remote_specification && @stub.instance_variable_get(:@data) && Gem.loaded_specs[name].equal?(self)
+ _remote_specification
+ end
+ @stub
+ end
+
private
def _remote_specification
@_remote_specification ||= begin
- rs = stub.to_spec
+ rs = @stub.to_spec
if rs.equal?(self) # happens when to_spec gets the spec from Gem.loaded_specs
- rs = Gem::Specification.load(loaded_from)
- Bundler.rubygems.stub_set_spec(stub, rs)
+ rs = Gem::Specification.load(@stub.loaded_from)
+ Bundler.rubygems.stub_set_spec(@stub, rs)
end
unless rs