lib/bundler.rb in bundler-0.9.14 vs lib/bundler.rb in bundler-0.9.15
- old
+ new
@@ -1,13 +1,12 @@
require 'fileutils'
require 'pathname'
require 'yaml'
require 'bundler/rubygems_ext'
+require 'bundler/version'
-
module Bundler
- VERSION = "0.9.14"
ORIGINAL_ENV = ENV.to_hash
autoload :Definition, 'bundler/definition'
autoload :Dependency, 'bundler/dependency'
autoload :Dsl, 'bundler/dsl'
@@ -41,10 +40,11 @@
class GemfileError < BundlerError; status_code(4) ; end
class PathError < BundlerError; status_code(13) ; end
class GitError < BundlerError; status_code(11) ; end
class DeprecatedMethod < BundlerError; status_code(12) ; end
class DeprecatedOption < BundlerError; status_code(12) ; end
+ class InvalidOption < BundlerError; status_code(15) ; end
class << self
attr_writer :ui, :bundle_path
def configure
@@ -64,37 +64,43 @@
Pathname.new(path).expand_path(root)
end
end
def setup(*groups)
- gemfile = default_gemfile
- load(gemfile).setup(*groups)
+ load.setup(*groups)
end
def require(*groups)
- gemfile = default_gemfile
- load(gemfile).require(*groups)
+ load.require(*groups)
end
- def load(gemfile = default_gemfile)
- root = Pathname.new(gemfile).dirname
- Runtime.new root, definition(gemfile)
+ def load
+ if current_env_file?
+ SharedHelpers.gem_loaded = true
+ Kernel.require env_file
+ Bundler
+ else
+ runtime
+ end
end
- def definition(gemfile = default_gemfile)
+ def runtime
+ Runtime.new(root, definition)
+ end
+
+ def definition
configure
- root = Pathname.new(gemfile).dirname
lockfile = root.join("Gemfile.lock")
if lockfile.exist?
Definition.from_lock(lockfile)
else
- Definition.from_gemfile(gemfile)
+ Definition.from_gemfile(default_gemfile)
end
end
def home
- Pathname.new(bundle_path).join("bundler")
+ bundle_path.join("bundler")
end
def install_path
home.join("gems")
end
@@ -113,10 +119,14 @@
def settings
@settings ||= Settings.new(root)
end
+ def env_file
+ SharedHelpers.env_file
+ end
+
def with_clean_env
bundled_env = ENV.to_hash
ENV.replace(ORIGINAL_ENV)
yield
ensure
@@ -138,8 +148,12 @@
ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = bundle_path.to_s
end
Gem.clear_paths
+ end
+
+ def current_env_file?
+ env_file.exist? && (env_file.read(100) =~ /Bundler #{Bundler::VERSION}/)
end
end
end