lib/bundler.rb in bundler-1.7.15 vs lib/bundler.rb in bundler-1.8.0.pre
- old
+ new
@@ -189,34 +189,45 @@
def cache
bundle_path.join("cache/bundler")
end
def root
- @root ||= default_gemfile.dirname.expand_path
+ @root ||= begin
+ default_gemfile.dirname.expand_path
+ rescue GemfileNotFound
+ bundle_dir = default_bundle_dir
+ raise GemfileNotFound, "Could not locate Gemfile or .bundle/ directory" unless bundle_dir
+ Pathname.new(File.expand_path("..", bundle_dir))
+ end
end
def app_config_path
ENV['BUNDLE_APP_CONFIG'] ?
Pathname.new(ENV['BUNDLE_APP_CONFIG']).expand_path(root) :
root.join('.bundle')
end
def app_cache(custom_path = nil)
path = custom_path || root
- path.join("vendor/cache")
+ path.join(self.settings.app_cache_path)
end
def tmp(name = Process.pid.to_s)
@tmp ||= Pathname.new Dir.mktmpdir("bundler")
@tmp.join(name)
end
+ def cleanup
+ FileUtils.remove_entry_secure(@tmp) if @tmp
+ rescue
+ end
+
def settings
return @settings if defined?(@settings)
@settings = Settings.new(app_config_path)
rescue GemfileNotFound
- @settings = Settings.new
+ @settings = Settings.new(Pathname.new(".bundle").expand_path)
end
def with_original_env
bundled_env = ENV.to_hash
ENV.replace(ORIGINAL_ENV)
@@ -251,10 +262,14 @@
def default_lockfile
SharedHelpers.default_lockfile
end
+ def default_bundle_dir
+ SharedHelpers.default_bundle_dir
+ end
+
def system_bindir
# Gem.bindir doesn't always return the location that Rubygems will install
# system binaries. If you put '-n foo' in your .gemrc, Rubygems will
# install binstubs there instead. Unfortunately, Rubygems doesn't expose
# that directory at all, so rather than parse .gemrc ourselves, we allow
@@ -365,9 +380,13 @@
@git_present = Bundler.which("git") || Bundler.which("git.exe")
end
def ruby_version
@ruby_version ||= SystemRubyVersion.new
+ end
+
+ def reset!
+ @definition = nil
end
private
def eval_yaml_gemspec(path, contents)