Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Gems from git need their full_gem_path fixed, even when locked

  • Loading branch information...
commit 0f97e4fcea15b2e5f2d6d045c686b5750c5d54de 1 parent 2c8d6ae
@indirect indirect authored
View
2  lib/bundler.rb
@@ -20,7 +20,7 @@ module Bundler
autoload :SharedHelpers, 'bundler/shared_helpers'
autoload :SpecSet, 'bundler/spec_set'
autoload :Source, 'bundler/source'
- autoload :Specification, 'bundler/specification'
+ autoload :Specification, 'bundler/shared_helpers'
autoload :UI, 'bundler/ui'
class BundlerError < StandardError
View
22 lib/bundler/shared_helpers.rb
@@ -11,6 +11,28 @@ def requirement
end
module Bundler
+ class Specification < Gem::Specification
+ attr_accessor :relative_loaded_from
+
+ def self.from_gemspec(gemspec)
+ spec = allocate
+ gemspec.instance_variables.each do |ivar|
+ spec.instance_variable_set(ivar, gemspec.instance_variable_get(ivar))
+ end
+ spec
+ end
+
+ def loaded_from
+ return super unless relative_loaded_from
+ source.path.join(relative_loaded_from).to_s
+ end
+
+ def full_gem_path
+ Pathname.new(loaded_from).dirname.expand_path.to_s
+ end
+
+ end
+
module SharedHelpers
attr_accessor :gem_loaded
View
23 lib/bundler/specification.rb
@@ -1,23 +0,0 @@
-module Bundler
- class Specification < Gem::Specification
- attr_accessor :relative_loaded_from
-
- def self.from_gemspec(gemspec)
- spec = allocate
- gemspec.instance_variables.each do |ivar|
- spec.instance_variable_set(ivar, gemspec.instance_variable_get(ivar))
- end
- spec
- end
-
- def loaded_from
- return super unless relative_loaded_from
- source.path.join(relative_loaded_from).to_s
- end
-
- def full_gem_path
- Pathname.new(loaded_from).dirname.expand_path.to_s
- end
-
- end
-end
View
7 lib/bundler/templates/environment.erb
@@ -8,6 +8,7 @@ require 'rubygems'
module Bundler
LOCKED_BY = '<%= Bundler::VERSION %>'
FINGERPRINT = <%= gemfile_fingerprint.inspect %>
+ HOME = '<%= Bundler.home %>'
AUTOREQUIRES = <%= autorequires_for_groups.inspect %>
SPECS = [
<% specs_for_lock_file.each do |spec| -%>
@@ -22,7 +23,11 @@ module Bundler
end
spec.loaded_from = hash[:loaded_from]
spec.require_paths = hash[:load_paths]
- spec
+ if spec.loaded_from.include?(HOME)
+ Bundler::Specification.from_gemspec(spec)
+ else
+ spec
+ end
end
extend SharedHelpers
View
24 spec/lock/git_spec.rb
@@ -1,7 +1,7 @@
require File.expand_path('../../spec_helper', __FILE__)
describe "bundle lock with git" do
- it "doesn't break right after running lock" do
+ before :each do
build_git "foo"
install_gemfile <<-G
@@ -10,18 +10,13 @@
G
bundle :lock
+ end
+
+ it "doesn't break right after running lock" do
should_be_installed "foo 1.0.0"
end
it "locks a git source to the current ref" do
- build_git "foo"
-
- install_gemfile <<-G
- git "#{lib_path('foo-1.0')}"
- gem 'foo'
- G
-
- bundle :lock
update_git "foo"
bundle :install
@@ -32,4 +27,15 @@
out.should == "WIN"
end
+
+ it "provides correct #full_gem_path" do
+ rev = revision_for(lib_path("foo-1.0"))
+ gem_path = "foo-1.0-5b89e78c95d2131a78cc39dab852b6266f4bed9d-#{rev}"
+ full_gem_path = Bundler.install_path.join(gem_path).to_s
+
+ run <<-RUBY
+ puts Bundler::SPECS.map{|s| s.full_gem_path }
+ RUBY
+ out.should == full_gem_path
+ end
end
View
12 spec/runtime/load_spec.rb
@@ -51,7 +51,7 @@
gem "activesupport", :group => :test
G
- ruby <<-R
+ ruby <<-RUBY
require "bundler"
Bundler.setup :default
Bundler.require :default
@@ -61,7 +61,7 @@
rescue LoadError
puts "no activesupport"
end
- R
+ RUBY
out.split("\n").should == ["1.0.0", "no activesupport"]
end
@@ -77,16 +77,16 @@
end
it "loads env.rb instead of the runtime" do
- ruby <<-R
+ ruby <<-RUBY
require 'bundler'
Bundler.load
puts Bundler.instance_eval{ @runtime }
- R
+ RUBY
out.should == "nil"
end
it "does not invoke setup inside env.rb" do
- ruby <<-R, :expect_err => true
+ ruby <<-RUBY, :expect_err => true
require 'bundler'
Bundler.load
if $LOAD_PATH.grep(/rack/i).any?
@@ -94,7 +94,7 @@
else
puts "hurrah"
end
- R
+ RUBY
out.should == "hurrah"
end
Please sign in to comment.
Something went wrong with that request. Please try again.