aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/bundler.rb2
-rw-r--r--lib/bundler/shared_helpers.rb22
-rw-r--r--lib/bundler/specification.rb23
-rw-r--r--lib/bundler/templates/environment.erb7
-rw-r--r--spec/lock/git_spec.rb24
-rw-r--r--spec/runtime/load_spec.rb12
6 files changed, 50 insertions, 40 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index cec6de8b..dfda6481 100644
--- a/lib/bundler.rb
+++ b/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
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index a824d2f7..4e570579 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -11,6 +11,28 @@ module Gem
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
diff --git a/lib/bundler/specification.rb b/lib/bundler/specification.rb
deleted file mode 100644
index 0f3f0f70..00000000
--- a/lib/bundler/specification.rb
+++ /dev/null
@@ -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 \ No newline at end of file
diff --git a/lib/bundler/templates/environment.erb b/lib/bundler/templates/environment.erb
index 0a44ad1e..91ede348 100644
--- a/lib/bundler/templates/environment.erb
+++ b/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
diff --git a/spec/lock/git_spec.rb b/spec/lock/git_spec.rb
index a0b72e9e..b0603de6 100644
--- a/spec/lock/git_spec.rb
+++ b/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 @@ describe "bundle lock with git" do
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 @@ describe "bundle lock with git" do
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 \ No newline at end of file
diff --git a/spec/runtime/load_spec.rb b/spec/runtime/load_spec.rb
index 4c59c3f5..c2897a7b 100644
--- a/spec/runtime/load_spec.rb
+++ b/spec/runtime/load_spec.rb
@@ -51,7 +51,7 @@ describe "Bundler.load" do
gem "activesupport", :group => :test
G
- ruby <<-R
+ ruby <<-RUBY
require "bundler"
Bundler.setup :default
Bundler.require :default
@@ -61,7 +61,7 @@ describe "Bundler.load" do
rescue LoadError
puts "no activesupport"
end
- R
+ RUBY
out.split("\n").should == ["1.0.0", "no activesupport"]
end
@@ -77,16 +77,16 @@ describe "Bundler.load" do
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 @@ describe "Bundler.load" do
else
puts "hurrah"
end
- R
+ RUBY
out.should == "hurrah"
end