lib/bundler.rb in bundler-1.0.22 vs lib/bundler.rb in bundler-1.1.pre
- old
+ new
@@ -1,29 +1,21 @@
require 'rbconfig'
require 'fileutils'
require 'pathname'
-
-begin
- # Pull in Psych if we can, but not if Syck is already loaded
- require 'psych' unless defined?(Syck)
-rescue LoadError
-end
-
require 'yaml'
require 'bundler/rubygems_ext'
-require 'bundler/rubygems_integration'
require 'bundler/version'
module Bundler
ORIGINAL_ENV = ENV.to_hash
autoload :Definition, 'bundler/definition'
autoload :Dependency, 'bundler/dependency'
autoload :Dsl, 'bundler/dsl'
autoload :Environment, 'bundler/environment'
+ autoload :Fetcher, 'bundler/fetcher'
autoload :GemHelper, 'bundler/gem_helper'
- autoload :GemInstaller, 'bundler/gem_installer'
autoload :Graph, 'bundler/graph'
autoload :Index, 'bundler/index'
autoload :Installer, 'bundler/installer'
autoload :LazySpecification, 'bundler/lazy_specification'
autoload :LockfileParser, 'bundler/lockfile_parser'
@@ -36,26 +28,26 @@
autoload :Source, 'bundler/source'
autoload :Specification, 'bundler/shared_helpers'
autoload :UI, 'bundler/ui'
class BundlerError < StandardError
- def self.status_code(code)
+ def self.status_code(code = nil)
define_method(:status_code) { code }
end
end
class GemfileNotFound < BundlerError; status_code(10) ; end
class GemNotFound < BundlerError; status_code(7) ; end
class GemfileError < BundlerError; status_code(4) ; end
- class InstallError < BundlerError; status_code(5) ; end
class PathError < BundlerError; status_code(13) ; end
class GitError < BundlerError; status_code(11) ; end
class DeprecatedError < BundlerError; status_code(12) ; end
class GemspecError < BundlerError; status_code(14) ; end
class DslError < BundlerError; status_code(15) ; end
class ProductionError < BundlerError; status_code(16) ; end
class InvalidOption < DslError ; end
+ class HTTPError < BundlerError; status_code(17) ; end
WINDOWS = RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
FREEBSD = RbConfig::CONFIG["host_os"] =~ /bsd/
NULL = WINDOWS ? "NUL" : "/dev/null"
@@ -87,10 +79,11 @@
def ui
@ui ||= UI.new
end
def bundle_path
+ # STDERR.puts settings.path
@bundle_path ||= Pathname.new(settings.path).expand_path(root)
end
def bin_path
@bin_path ||= begin
@@ -112,11 +105,12 @@
@completed_groups ||= []
# Figure out which groups haven't been loaded yet
unloaded = groups - @completed_groups
# Record groups that are now loaded
@completed_groups = groups
- unloaded.any? ? load.setup(*groups) : load
+ # Load any groups that are not yet loaded
+ unloaded.any? ? load.setup(*unloaded) : load
end
end
def require(*groups)
setup(*groups).require(*groups)
@@ -138,15 +132,15 @@
Definition.build(default_gemfile, default_lockfile, unlock)
end
end
def ruby_scope
- "#{Bundler.rubygems.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
+ "#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
end
def user_bundle_path
- Pathname.new(Bundler.rubygems.user_home).join(".bundler")
+ Pathname.new(Gem.user_home).join(".bundler")
end
def home
bundle_path.join("bundler")
end
@@ -200,11 +194,11 @@
def default_lockfile
SharedHelpers.default_lockfile
end
def requires_sudo?
- return @requires_sudo if defined?(@checked_for_sudo) && @checked_for_sudo
+ return @requires_sudo if @checked_for_sudo
path = bundle_path
path = path.parent until path.exist?
sudo_present = !(`which sudo` rescue '').empty?
@@ -230,17 +224,16 @@
def load_gemspec(file)
path = Pathname.new(file)
# Eval the gemspec from its parent directory
Dir.chdir(path.dirname.to_s) do
- contents = File.read(path.basename.to_s)
begin
- Gem::Specification.from_yaml(contents)
+ Gem::Specification.from_yaml(path.basename.to_s)
# Raises ArgumentError if the file is not valid YAML
rescue ArgumentError, SyntaxError, Gem::EndOfYAMLException, Gem::Exception
begin
- eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
+ eval(File.read(path.basename.to_s), TOPLEVEL_BINDING, path.expand_path.to_s)
rescue LoadError => e
original_line = e.backtrace.find { |line| line.include?(path.to_s) }
msg = "There was a LoadError while evaluating #{path.basename}:\n #{e.message}"
msg << " from\n #{original_line}" if original_line
msg << "\n"
@@ -259,20 +252,17 @@
def configure_gem_home_and_path
if settings[:disable_shared_gems]
ENV['GEM_PATH'] = ''
ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
- elsif Bundler.rubygems.gem_dir != bundle_path.to_s
- possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
- paths = possibles.flatten.compact.uniq.reject { |p| p.empty? }
+ elsif Gem.dir != bundle_path.to_s
+ paths = [Gem.dir, Gem.path].flatten.compact.uniq.reject{|p| p.empty? }
ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = bundle_path.to_s
end
- # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602)
- FileUtils.mkdir_p bundle_path.to_s rescue nil
-
- Bundler.rubygems.clear_paths
+ FileUtils.mkdir_p bundle_path.to_s
+ Gem.clear_paths
end
def upgrade_lockfile
lockfile = default_lockfile
if lockfile.exist? && lockfile.read(3) == "---"