lib/bundler.rb in bundler-0.9.0.pre4 vs lib/bundler.rb in bundler-0.9.0.pre5
- old
+ new
@@ -2,20 +2,21 @@
require 'pathname'
require 'yaml'
require 'bundler/rubygems'
module Bundler
- VERSION = "0.9.0.pre4"
+ VERSION = "0.9.0.pre5"
autoload :Definition, 'bundler/definition'
autoload :Dependency, 'bundler/dependency'
autoload :Dsl, 'bundler/dsl'
autoload :Environment, 'bundler/environment'
autoload :Index, 'bundler/index'
autoload :Installer, 'bundler/installer'
autoload :RemoteSpecification, 'bundler/remote_specification'
autoload :Resolver, 'bundler/resolver'
+ autoload :Settings, 'bundler/settings'
autoload :Source, 'bundler/source'
autoload :Specification, 'bundler/specification'
autoload :UI, 'bundler/ui'
class BundlerError < StandardError
@@ -31,27 +32,31 @@
class GemfileNotFound < BundlerError; status_code(10) ; end
class GemNotFound < BundlerError; status_code(7) ; end
class VersionConflict < BundlerError; status_code(6) ; end
class GemfileError < BundlerError; status_code(4) ; end
+ class GitError < BundlerError; status_code(11) ; end
class << self
attr_writer :ui, :bundle_path
def configure
@configured ||= begin
- point_gem_home(env[:bundle_path])
+ configure_gem_home_and_path
true
end
end
def ui
@ui ||= UI.new
end
def bundle_path
- @bundle_path ||= Pathname.new(env[:bundle_path] || Gem.dir)
+ @bundle_path ||= begin
+ path = settings[:path] || "#{Gem.user_home}/.bundle"
+ Pathname.new(path).expand_path(root)
+ end
end
def setup(*groups)
gemfile = default_gemfile
load(gemfile).setup(*groups)
@@ -87,10 +92,14 @@
def root
default_gemfile.dirname
end
+ def settings
+ @settings ||= Settings.new(root)
+ end
+
private
def default_gemfile
current = Pathname.new(Dir.pwd)
@@ -101,25 +110,19 @@
end
raise GemfileNotFound, "The default Gemfile was not found"
end
- def env
- @env ||= begin
- env = {}
- file = "#{root}/.bundleconfig"
- config = File.exist?(file) ? YAML.load_file(file) : {}
- %w(BUNDLE_PATH).each do |key|
- env[key.downcase.to_sym] = config[key] || ENV[key]
- end
- env
+ def configure_gem_home_and_path
+ if path = settings[:path]
+ ENV['GEM_HOME'] = File.expand_path(path, root)
+ ENV['GEM_PATH'] = ''
+ else
+ gem_home, gem_path = Gem.dir, Gem.path
+ ENV["GEM_PATH"] = [gem_home, gem_path].flatten.compact.join(File::PATH_SEPARATOR)
+ ENV["GEM_HOME"] = bundle_path.to_s
end
- end
- def point_gem_home(path)
- return unless path
- ENV['GEM_HOME'] = File.expand_path(path, root)
- ENV['GEM_PATH'] = ''
Gem.clear_paths
end
end
end
\ No newline at end of file