lib/bundler.rb in bundler-0.8.1 vs lib/bundler.rb in bundler-0.9.0.pre1

- old
+ new

@@ -1,49 +1,84 @@ +require 'fileutils' require 'pathname' -require 'logger' -require 'set' -require 'erb' -# Required elements of rubygems -require "rubygems/remote_fetcher" -require "rubygems/installer" +require 'yaml' +require 'bundler/rubygems' -require "bundler/gem_bundle" -require "bundler/source" -require "bundler/finder" -require "bundler/gem_ext" -require "bundler/resolver" -require "bundler/environment" -require "bundler/dsl" -require "bundler/cli" -require "bundler/bundle" -require "bundler/dependency" -require "bundler/remote_specification" - module Bundler - VERSION = "0.8.1" + VERSION = "0.9.0.pre1" - class << self - attr_writer :logger, :mode + 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 :Source, 'bundler/source' + autoload :Specification, 'bundler/specification' + autoload :UI, 'bundler/ui' - def logger - @logger ||= begin - logger = Logger.new(STDOUT, Logger::INFO) - logger.formatter = proc {|_,_,_,msg| "#{msg}\n" } - logger - end - end + class GemfileNotFound < StandardError; end + class GemNotFound < StandardError; end + class VersionConflict < StandardError; end + class GemfileError < StandardError; end - def local? - @mode == :local - end + def self.ui + @ui ||= UI.new + end - def writable? - @mode != :readonly + def self.ui=(ui) + @ui = ui + end + + def self.setup(*groups) + gemfile = default_gemfile + load(gemfile).setup(*groups) + end + + def self.load(gemfile = default_gemfile) + root = Pathname.new(gemfile).dirname + Environment.new root, definition(gemfile) + end + + def self.definition(gemfile = default_gemfile) + root = Pathname.new(gemfile).dirname + lockfile = root.join("vendor/lock.yml") + if lockfile.exist? + Definition.from_lock(lockfile) + else + Definition.from_gemfile(gemfile) end + end - def remote? - @mode == :readwrite + def self.home + Pathname.new(Gem.dir).join("bundler") + end + + def self.install_path + home.join("gems") + end + + def self.cache + home.join("cache") + end + + def self.root + default_gemfile.dirname + end + +private + + def self.default_gemfile + current = Pathname.new(Dir.pwd) + + until current.root? + filename = current.join("Gemfile") + return filename if filename.exist? + current = current.parent end + + raise GemfileNotFound, "The default Gemfile was not found" end - self.mode = :readonly -end +end \ No newline at end of file