summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-08-03 11:00:55 -0700
committerCarl Lerche <carllerche@mac.com>2010-08-03 11:00:55 -0700
commit251b9c78cdb1c1cd04de57965752373fd37856df (patch)
tree5349d728d22590f15475e1d049d0e20c8d9bd378
parent37ee7577583215b87e4cfa37ab7bd5a2b1d1722c (diff)
downloadbundler-251b9c78cdb1c1cd04de57965752373fd37856df.tar.gz
Use the Gemfile's name as a base for Gemfile.lock
-rw-r--r--lib/bundler.rb9
-rw-r--r--lib/bundler/cli.rb4
-rw-r--r--lib/bundler/environment.rb2
-rw-r--r--lib/bundler/installer.rb4
-rw-r--r--lib/bundler/shared_helpers.rb4
-rw-r--r--spec/install/gems/simple_case_spec.rb20
6 files changed, 35 insertions, 8 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 26cd342933..38cb27245f 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -127,8 +127,7 @@ module Bundler
@definition ||= begin
configure
upgrade_lockfile
- lockfile = root.join("Gemfile.lock")
- Definition.build(default_gemfile, lockfile, unlock)
+ Definition.build(default_gemfile, default_lockfile, unlock)
end
end
@@ -184,6 +183,10 @@ module Bundler
SharedHelpers.default_gemfile
end
+ def default_lockfile
+ SharedHelpers.default_lockfile
+ end
+
WINDOWS = Config::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
NULL = WINDOWS ? "NUL" : "/dev/null"
@@ -223,7 +226,7 @@ module Bundler
end
def upgrade_lockfile
- lockfile = root.join("Gemfile.lock")
+ lockfile = default_lockfile
if lockfile.exist? && lockfile.read(3) == "---"
Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..."
lockfile.rmtree
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 8112437260..f094986f68 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -141,7 +141,7 @@ module Bundler
if opts[:production]
Bundler.production = true
- unless Bundler.root.join("Gemfile.lock").exist?
+ unless Bundler.default_lockfile.exist?
raise ProductionError, "The --production flag requires a Gemfile.lock. Please\n" \
"make sure you have checked your Gemfile.lock into version\n" \
"control before deploying."
@@ -153,7 +153,7 @@ module Bundler
end
# Can't use Bundler.settings for this because settings needs gemfile.dirname
- ENV['BUNDLE_GEMFILE'] = opts[:gemfile] if opts[:gemfile]
+ ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile]
Bundler.settings[:path] = nil if options[:system]
Bundler.settings[:path] = "vendor/bundle" if options[:production]
Bundler.settings[:path] = path if path
diff --git a/lib/bundler/environment.rb b/lib/bundler/environment.rb
index fe510e35a7..c5a44d1be3 100644
--- a/lib/bundler/environment.rb
+++ b/lib/bundler/environment.rb
@@ -36,7 +36,7 @@ module Bundler
end
def lock
- @definition.lock(root.join('Gemfile.lock'))
+ @definition.lock(Bundler.default_lockfile)
end
def update(*gems)
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 73d1dc5e99..1560f5ccd0 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -15,9 +15,9 @@ module Bundler
return
end
- if Bundler.root.join("Gemfile.lock").exist? && !options["update"]
+ if Bundler.default_lockfile.exist? && !options["update"]
begin
- tmpdef = Definition.build(Bundler.default_gemfile, Bundler.root.join("Gemfile.lock"), nil)
+ tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil)
local = true unless tmpdef.new_platform? || tmpdef.missing_specs.any?
rescue BundlerError
end
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 7bca421e1a..d71b1ccc40 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -22,6 +22,10 @@ module Bundler
Pathname.new(gemfile)
end
+ def default_lockfile
+ Pathname.new("#{default_gemfile}.lock")
+ end
+
def in_bundle?
find_gemfile
end
diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb
index 08b4d5537b..abe2f2f99b 100644
--- a/spec/install/gems/simple_case_spec.rb
+++ b/spec/install/gems/simple_case_spec.rb
@@ -20,6 +20,26 @@ describe "bundle install with gem sources" do
bundled_app("Gemfile.lock").should_not exist
end
+ it "creates a Gemfile.lock" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundled_app('Gemfile.lock').should exist
+ end
+
+ it "creates lock files based on the Gemfile name" do
+ gemfile bundled_app('OmgFile'), <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", "1.0"
+ G
+
+ bundle 'install --gemfile OmgFile'
+
+ bundled_app("OmgFile.lock").should exist
+ end
+
it "doesn't delete the lockfile if one already exists" do
install_gemfile <<-G
source "file://#{gem_repo1}"