bundler 0.8.1 → 0.9.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- data/README +7 -0
- data/bin/bundle +3 -0
- data/lib/bundler.rb +72 -37
- data/lib/bundler/cli.rb +64 -68
- data/lib/bundler/definition.rb +78 -0
- data/lib/bundler/dependency.rb +7 -57
- data/lib/bundler/dsl.rb +42 -142
- data/lib/bundler/environment.rb +94 -54
- data/lib/bundler/index.rb +98 -0
- data/lib/bundler/installer.rb +137 -0
- data/lib/bundler/remote_specification.rb +1 -1
- data/lib/bundler/resolver.rb +20 -50
- data/lib/bundler/rubygems.rb +22 -0
- data/lib/bundler/source.rb +185 -295
- data/lib/bundler/specification.rb +22 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/environment.erb +3 -153
- data/lib/bundler/ui.rb +51 -0
- data/lib/bundler/vendor/thor.rb +241 -0
- data/lib/bundler/vendor/thor/actions.rb +274 -0
- data/lib/bundler/vendor/thor/actions/create_file.rb +103 -0
- data/lib/bundler/vendor/thor/actions/directory.rb +91 -0
- data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
- data/lib/bundler/vendor/thor/actions/file_manipulation.rb +223 -0
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +101 -0
- data/lib/bundler/vendor/thor/base.rb +515 -0
- data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
- data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/bundler/vendor/thor/error.rb +27 -0
- data/lib/bundler/vendor/thor/group.rb +267 -0
- data/lib/bundler/vendor/thor/invocation.rb +178 -0
- data/lib/bundler/vendor/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
- data/lib/bundler/vendor/thor/parser/arguments.rb +145 -0
- data/lib/bundler/vendor/thor/parser/option.rb +132 -0
- data/lib/bundler/vendor/thor/parser/options.rb +142 -0
- data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
- data/lib/bundler/vendor/thor/runner.rb +303 -0
- data/lib/bundler/vendor/thor/shell.rb +78 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +239 -0
- data/lib/bundler/vendor/thor/shell/color.rb +108 -0
- data/lib/bundler/vendor/thor/task.rb +111 -0
- data/lib/bundler/vendor/thor/util.rb +233 -0
- data/lib/bundler/vendor/thor/version.rb +3 -0
- metadata +48 -26
- data/README.markdown +0 -284
- data/Rakefile +0 -81
- data/lib/bundler/bundle.rb +0 -314
- data/lib/bundler/commands/bundle_command.rb +0 -72
- data/lib/bundler/commands/exec_command.rb +0 -36
- data/lib/bundler/finder.rb +0 -51
- data/lib/bundler/gem_bundle.rb +0 -11
- data/lib/bundler/gem_ext.rb +0 -34
- data/lib/bundler/runtime.rb +0 -2
- data/lib/bundler/templates/app_script.erb +0 -3
- data/lib/bundler/templates/environment_picker.erb +0 -4
- data/lib/rubygems_plugin.rb +0 -6
    
        data/README
    ADDED
    
    
    
        data/bin/bundle
    ADDED
    
    
    
        data/lib/bundler.rb
    CHANGED
    
    | @@ -1,49 +1,84 @@ | |
| 1 | 
            +
            require 'fileutils'
         | 
| 1 2 | 
             
            require 'pathname'
         | 
| 2 | 
            -
            require ' | 
| 3 | 
            -
            require ' | 
| 4 | 
            -
            require 'erb'
         | 
| 5 | 
            -
            # Required elements of rubygems
         | 
| 6 | 
            -
            require "rubygems/remote_fetcher"
         | 
| 7 | 
            -
            require "rubygems/installer"
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            require "bundler/gem_bundle"
         | 
| 10 | 
            -
            require "bundler/source"
         | 
| 11 | 
            -
            require "bundler/finder"
         | 
| 12 | 
            -
            require "bundler/gem_ext"
         | 
| 13 | 
            -
            require "bundler/resolver"
         | 
| 14 | 
            -
            require "bundler/environment"
         | 
| 15 | 
            -
            require "bundler/dsl"
         | 
| 16 | 
            -
            require "bundler/cli"
         | 
| 17 | 
            -
            require "bundler/bundle"
         | 
| 18 | 
            -
            require "bundler/dependency"
         | 
| 19 | 
            -
            require "bundler/remote_specification"
         | 
| 3 | 
            +
            require 'yaml'
         | 
| 4 | 
            +
            require 'bundler/rubygems'
         | 
| 20 5 |  | 
| 21 6 | 
             
            module Bundler
         | 
| 22 | 
            -
              VERSION = "0. | 
| 7 | 
            +
              VERSION = "0.9.0.pre1"
         | 
| 23 8 |  | 
| 24 | 
            -
               | 
| 25 | 
            -
             | 
| 9 | 
            +
              autoload :Definition,          'bundler/definition'
         | 
| 10 | 
            +
              autoload :Dependency,          'bundler/dependency'
         | 
| 11 | 
            +
              autoload :Dsl,                 'bundler/dsl'
         | 
| 12 | 
            +
              autoload :Environment,         'bundler/environment'
         | 
| 13 | 
            +
              autoload :Index,               'bundler/index'
         | 
| 14 | 
            +
              autoload :Installer,           'bundler/installer'
         | 
| 15 | 
            +
              autoload :RemoteSpecification, 'bundler/remote_specification'
         | 
| 16 | 
            +
              autoload :Resolver,            'bundler/resolver'
         | 
| 17 | 
            +
              autoload :Source,              'bundler/source'
         | 
| 18 | 
            +
              autoload :Specification,       'bundler/specification'
         | 
| 19 | 
            +
              autoload :UI,                  'bundler/ui'
         | 
| 26 20 |  | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
                    logger
         | 
| 32 | 
            -
                  end
         | 
| 33 | 
            -
                end
         | 
| 21 | 
            +
              class GemfileNotFound < StandardError; end
         | 
| 22 | 
            +
              class GemNotFound     < StandardError; end
         | 
| 23 | 
            +
              class VersionConflict < StandardError; end
         | 
| 24 | 
            +
              class GemfileError    < StandardError; end
         | 
| 34 25 |  | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 26 | 
            +
              def self.ui
         | 
| 27 | 
            +
                @ui ||= UI.new
         | 
| 28 | 
            +
              end
         | 
| 38 29 |  | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 30 | 
            +
              def self.ui=(ui)
         | 
| 31 | 
            +
                @ui = ui
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              def self.setup(*groups)
         | 
| 35 | 
            +
                gemfile = default_gemfile
         | 
| 36 | 
            +
                load(gemfile).setup(*groups)
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def self.load(gemfile = default_gemfile)
         | 
| 40 | 
            +
                root = Pathname.new(gemfile).dirname
         | 
| 41 | 
            +
                Environment.new root, definition(gemfile)
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              def self.definition(gemfile = default_gemfile)
         | 
| 45 | 
            +
                root = Pathname.new(gemfile).dirname
         | 
| 46 | 
            +
                lockfile = root.join("vendor/lock.yml")
         | 
| 47 | 
            +
                if lockfile.exist?
         | 
| 48 | 
            +
                  Definition.from_lock(lockfile)
         | 
| 49 | 
            +
                else
         | 
| 50 | 
            +
                  Definition.from_gemfile(gemfile)
         | 
| 41 51 | 
             
                end
         | 
| 52 | 
            +
              end
         | 
| 42 53 |  | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 54 | 
            +
              def self.home
         | 
| 55 | 
            +
                Pathname.new(Gem.dir).join("bundler")
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              def self.install_path
         | 
| 59 | 
            +
                home.join("gems")
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              def self.cache
         | 
| 63 | 
            +
                home.join("cache")
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              def self.root
         | 
| 67 | 
            +
                default_gemfile.dirname
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            private
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              def self.default_gemfile
         | 
| 73 | 
            +
                current = Pathname.new(Dir.pwd)
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                until current.root?
         | 
| 76 | 
            +
                  filename = current.join("Gemfile")
         | 
| 77 | 
            +
                  return filename if filename.exist?
         | 
| 78 | 
            +
                  current = current.parent
         | 
| 45 79 | 
             
                end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                raise GemfileNotFound, "The default Gemfile was not found"
         | 
| 46 82 | 
             
              end
         | 
| 47 83 |  | 
| 48 | 
            -
             | 
| 49 | 
            -
            end
         | 
| 84 | 
            +
            end
         | 
    
        data/lib/bundler/cli.rb
    CHANGED
    
    | @@ -1,89 +1,85 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            $:.unshift File.expand_path('../vendor', __FILE__)
         | 
| 2 | 
            +
            require 'thor'
         | 
| 3 | 
            +
            require 'bundler'
         | 
| 4 | 
            +
            require 'rubygems/config_file'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Work around a RubyGems bug
         | 
| 7 | 
            +
            Gem.configuration
         | 
| 2 8 |  | 
| 3 9 | 
             
            module Bundler
         | 
| 4 | 
            -
              class CLI
         | 
| 5 | 
            -
                def self. | 
| 6 | 
            -
                   | 
| 7 | 
            -
                rescue DefaultManifestNotFound => e
         | 
| 8 | 
            -
                  Bundler.logger.error "Could not find a Gemfile to use"
         | 
| 9 | 
            -
                  exit 3
         | 
| 10 | 
            -
                rescue InvalidEnvironmentName => e
         | 
| 11 | 
            -
                  Bundler.logger.error "Gemfile error: #{e.message}"
         | 
| 12 | 
            -
                  exit 4
         | 
| 13 | 
            -
                rescue InvalidRepository => e
         | 
| 14 | 
            -
                  Bundler.logger.error e.message
         | 
| 15 | 
            -
                  exit 5
         | 
| 16 | 
            -
                rescue VersionConflict => e
         | 
| 17 | 
            -
                  Bundler.logger.error e.message
         | 
| 18 | 
            -
                  exit 6
         | 
| 19 | 
            -
                rescue GemNotFound => e
         | 
| 20 | 
            -
                  Bundler.logger.error e.message
         | 
| 21 | 
            -
                  exit 7
         | 
| 22 | 
            -
                rescue InvalidCacheArgument => e
         | 
| 23 | 
            -
                  Bundler.logger.error e.message
         | 
| 24 | 
            -
                  exit 8
         | 
| 25 | 
            -
                rescue SourceNotCached => e
         | 
| 26 | 
            -
                  Bundler.logger.error e.message
         | 
| 27 | 
            -
                  exit 9
         | 
| 28 | 
            -
                rescue ManifestFileNotFound => e
         | 
| 29 | 
            -
                  Bundler.logger.error e.message
         | 
| 30 | 
            -
                  exit 10
         | 
| 10 | 
            +
              class CLI < Thor
         | 
| 11 | 
            +
                def self.banner(task)
         | 
| 12 | 
            +
                  task.formatted_usage(self, false)
         | 
| 31 13 | 
             
                end
         | 
| 32 14 |  | 
| 33 | 
            -
                 | 
| 34 | 
            -
             | 
| 35 | 
            -
                   | 
| 36 | 
            -
             | 
| 15 | 
            +
                desc "init", "Generates a Gemfile into the current working directory"
         | 
| 16 | 
            +
                def init
         | 
| 17 | 
            +
                  if File.exist?("Gemfile")
         | 
| 18 | 
            +
                    puts "Gemfile already exists at `#{Dir.pwd}/Gemfile`"
         | 
| 19 | 
            +
                  else
         | 
| 20 | 
            +
                    puts "Writing new Gemfile to `#{Dir.pwd}/Gemfile`"
         | 
| 21 | 
            +
                    FileUtils.cp(File.expand_path('../templates/Gemfile', __FILE__), 'Gemfile')
         | 
| 22 | 
            +
                  end
         | 
| 37 23 | 
             
                end
         | 
| 38 24 |  | 
| 39 | 
            -
                def  | 
| 40 | 
            -
                   | 
| 25 | 
            +
                def initialize(*)
         | 
| 26 | 
            +
                  super
         | 
| 27 | 
            +
                  Bundler.ui = UI::Shell.new(shell)
         | 
| 28 | 
            +
                  Gem::DefaultUserInteraction.ui = UI::RGProxy.new(Bundler.ui)
         | 
| 41 29 | 
             
                end
         | 
| 42 30 |  | 
| 43 | 
            -
                 | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
                     | 
| 48 | 
            -
             | 
| 49 | 
            -
                     | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
                       | 
| 31 | 
            +
                desc "check", "Checks if the dependencies listed in Gemfile are satisfied by currently installed gems"
         | 
| 32 | 
            +
                def check
         | 
| 33 | 
            +
                  with_rescue do
         | 
| 34 | 
            +
                    env = Bundler.load
         | 
| 35 | 
            +
                    # Check top level dependencies
         | 
| 36 | 
            +
                    missing = env.dependencies.select { |d| env.index.search(d).empty? }
         | 
| 37 | 
            +
                    if missing.any?
         | 
| 38 | 
            +
                      puts "The following dependencies are missing"
         | 
| 39 | 
            +
                      missing.each do |d|
         | 
| 40 | 
            +
                        puts "  * #{d}"
         | 
| 41 | 
            +
                      end
         | 
| 42 | 
            +
                    else
         | 
| 43 | 
            +
                      env.specs
         | 
| 44 | 
            +
                      puts "The Gemfile's dependencies are satisfied"
         | 
| 54 45 | 
             
                    end
         | 
| 55 | 
            -
                    gemfiles = Dir["#{gemfile}/*.gem"]
         | 
| 56 | 
            -
                    if gemfiles.empty?
         | 
| 57 | 
            -
                      raise InvalidCacheArgument, "'#{gemfile}' contains no gemfiles"
         | 
| 58 | 
            -
                    end
         | 
| 59 | 
            -
                    @bundle.cache(*gemfiles)
         | 
| 60 | 
            -
                  else
         | 
| 61 | 
            -
                    raise InvalidCacheArgument, "w0t? '#{gemfile}' means nothing to me."
         | 
| 62 46 | 
             
                  end
         | 
| 47 | 
            +
                rescue VersionConflict => e
         | 
| 48 | 
            +
                  puts e.message
         | 
| 63 49 | 
             
                end
         | 
| 64 50 |  | 
| 65 | 
            -
                 | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 51 | 
            +
                desc "install", "Install the current environment to the system"
         | 
| 52 | 
            +
                method_option :without, :type => :array, :banner => "Exclude gems thar are part of the specified named group"
         | 
| 53 | 
            +
                def install
         | 
| 54 | 
            +
                  opts = options.dup
         | 
| 55 | 
            +
                  opts[:without] ||= []
         | 
| 56 | 
            +
                  opts[:without].map! { |g| g.to_sym }
         | 
| 69 57 |  | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 58 | 
            +
                  Installer.install(Bundler.root, Bundler.definition, opts)
         | 
| 59 | 
            +
                rescue Bundler::GemNotFound => e
         | 
| 60 | 
            +
                  puts e.message
         | 
| 61 | 
            +
                  exit 1
         | 
| 72 62 | 
             
                end
         | 
| 73 63 |  | 
| 74 | 
            -
                 | 
| 75 | 
            -
             | 
| 64 | 
            +
                desc "lock", "Locks a resolve"
         | 
| 65 | 
            +
                def lock
         | 
| 66 | 
            +
                  environment = Bundler.load
         | 
| 67 | 
            +
                  environment.lock
         | 
| 76 68 | 
             
                end
         | 
| 77 69 |  | 
| 78 | 
            -
                 | 
| 79 | 
            -
             | 
| 80 | 
            -
                   | 
| 81 | 
            -
                   | 
| 70 | 
            +
                desc "pack", "Packs all the gems to vendor/cache"
         | 
| 71 | 
            +
                def pack
         | 
| 72 | 
            +
                  environment = Bundler.load
         | 
| 73 | 
            +
                  environment.pack
         | 
| 82 74 | 
             
                end
         | 
| 83 75 |  | 
| 84 | 
            -
             | 
| 85 | 
            -
                  send(command)
         | 
| 86 | 
            -
                end
         | 
| 76 | 
            +
              private
         | 
| 87 77 |  | 
| 78 | 
            +
                def with_rescue
         | 
| 79 | 
            +
                  yield
         | 
| 80 | 
            +
                rescue GemfileNotFound => e
         | 
| 81 | 
            +
                  puts e.message
         | 
| 82 | 
            +
                  exit 1
         | 
| 83 | 
            +
                end
         | 
| 88 84 | 
             
              end
         | 
| 89 | 
            -
            end
         | 
| 85 | 
            +
            end
         | 
| @@ -0,0 +1,78 @@ | |
| 1 | 
            +
            module Bundler
         | 
| 2 | 
            +
              class Definition
         | 
| 3 | 
            +
                def self.from_gemfile(gemfile)
         | 
| 4 | 
            +
                  gemfile = Pathname.new(gemfile).expand_path
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  unless gemfile.file?
         | 
| 7 | 
            +
                    raise GemfileNotFound, "`#{gemfile}` not found"
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  Dsl.evaluate(gemfile)
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def self.from_lock(lockfile)
         | 
| 14 | 
            +
                  # gemfile_definition = from_gemfile(nil)
         | 
| 15 | 
            +
                  locked_definition = Locked.new(YAML.load_file(lockfile))
         | 
| 16 | 
            +
                  # raise GemfileError unless gemfile_definition.equivalent?(locked_definition)
         | 
| 17 | 
            +
                  locked_definition
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                attr_reader :dependencies, :sources
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                alias actual_dependencies dependencies
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def initialize(dependencies, sources)
         | 
| 25 | 
            +
                  @dependencies = dependencies
         | 
| 26 | 
            +
                  @sources = sources
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def local_index
         | 
| 30 | 
            +
                  @local_index ||= begin
         | 
| 31 | 
            +
                    index = Index.from_installed_gems
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    sources.each do |source|
         | 
| 34 | 
            +
                      next unless source.respond_to?(:local_specs)
         | 
| 35 | 
            +
                      index = source.local_specs.merge(index)
         | 
| 36 | 
            +
                    end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                    index
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                # def equivalent?(other)
         | 
| 43 | 
            +
                #   self.matches?(other) && other.matches?(self)
         | 
| 44 | 
            +
                #   # other.matches?(self)
         | 
| 45 | 
            +
                # end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                # def matches?(other)
         | 
| 48 | 
            +
                #   dependencies.all? do |dep|
         | 
| 49 | 
            +
                #     dep =~ other.specs.find {|spec| spec.name == dep.name }
         | 
| 50 | 
            +
                #   end
         | 
| 51 | 
            +
                # end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                class Locked < Definition
         | 
| 54 | 
            +
                  def initialize(details)
         | 
| 55 | 
            +
                    @details = details
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  def sources
         | 
| 59 | 
            +
                    @sources ||= @details["sources"].map do |args|
         | 
| 60 | 
            +
                      name, options = args.to_a.flatten
         | 
| 61 | 
            +
                      Bundler::Source.const_get(name).new(options)
         | 
| 62 | 
            +
                    end
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  def actual_dependencies
         | 
| 66 | 
            +
                    @actual_dependencies ||= @details["specs"].map do |args|
         | 
| 67 | 
            +
                      Gem::Dependency.new(*args.to_a.flatten)
         | 
| 68 | 
            +
                    end
         | 
| 69 | 
            +
                  end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                  def dependencies
         | 
| 72 | 
            +
                    @dependencies ||= @details["dependencies"].map do |args|
         | 
| 73 | 
            +
                      Gem::Dependency.new(*args.to_a.flatten)
         | 
| 74 | 
            +
                    end
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
            end
         | 
    
        data/lib/bundler/dependency.rb
    CHANGED
    
    | @@ -1,62 +1,12 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
              class InvalidEnvironmentName < StandardError; end
         | 
| 1 | 
            +
            require 'rubygems/dependency'
         | 
| 3 2 |  | 
| 3 | 
            +
            module Bundler
         | 
| 4 4 | 
             
              class Dependency < Gem::Dependency
         | 
| 5 | 
            -
                 | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
                def initialize(name, options = {}, &block)
         | 
| 9 | 
            -
                  options.each do |k, v|
         | 
| 10 | 
            -
                    options[k.to_s] = v
         | 
| 11 | 
            -
                  end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                  super(name, options["version"] || ">= 0")
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                  @require_as = options["require_as"]
         | 
| 16 | 
            -
                  @only       = options["only"]
         | 
| 17 | 
            -
                  @except     = options["except"]
         | 
| 18 | 
            -
                  @source     = options["source"]
         | 
| 19 | 
            -
                  @block      = block
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                  if (@only && @only.include?("rubygems")) || (@except && @except.include?("rubygems"))
         | 
| 22 | 
            -
                    raise InvalidEnvironmentName, "'rubygems' is not a valid environment name"
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                def in?(environment)
         | 
| 27 | 
            -
                  environment = environment.to_s
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                  return false unless !@only || @only.include?(environment)
         | 
| 30 | 
            -
                  return false if @except && @except.include?(environment)
         | 
| 31 | 
            -
                  true
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                def require_env(environment)
         | 
| 35 | 
            -
                  return unless in?(environment)
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                  if @require_as
         | 
| 38 | 
            -
                    Array(@require_as).each { |file| require file }
         | 
| 39 | 
            -
                  else
         | 
| 40 | 
            -
                    begin
         | 
| 41 | 
            -
                      require name
         | 
| 42 | 
            -
                    rescue LoadError
         | 
| 43 | 
            -
                      # Do nothing
         | 
| 44 | 
            -
                    end
         | 
| 45 | 
            -
                  end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                  @block.call if @block
         | 
| 48 | 
            -
                end
         | 
| 5 | 
            +
                def initialize(name, version, options = {}, &blk)
         | 
| 6 | 
            +
                  super(name, version)
         | 
| 49 7 |  | 
| 50 | 
            -
             | 
| 51 | 
            -
                  source  | 
| 8 | 
            +
                  @group  = options["group"] || :default
         | 
| 9 | 
            +
                  @source = options["source"]
         | 
| 52 10 | 
             
                end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                def ==(o)
         | 
| 55 | 
            -
                  [name, version, require_as, only, except] ==
         | 
| 56 | 
            -
                    [o.name, o.version, o.require_as, o.only, o.except]
         | 
| 57 | 
            -
                end
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                alias version version_requirements
         | 
| 60 | 
            -
             | 
| 61 11 | 
             
              end
         | 
| 62 | 
            -
            end
         | 
| 12 | 
            +
            end
         | 
    
        data/lib/bundler/dsl.rb
    CHANGED
    
    | @@ -1,110 +1,56 @@ | |
| 1 1 | 
             
            module Bundler
         | 
| 2 | 
            -
              class  | 
| 3 | 
            -
              class InvalidKey < StandardError; end
         | 
| 4 | 
            -
              class DefaultManifestNotFound < StandardError; end
         | 
| 2 | 
            +
              class DslError < StandardError; end
         | 
| 5 3 |  | 
| 6 4 | 
             
              class Dsl
         | 
| 7 | 
            -
                def self.evaluate( | 
| 8 | 
            -
                  builder = new | 
| 9 | 
            -
                  builder.instance_eval(File.read( | 
| 10 | 
            -
                   | 
| 5 | 
            +
                def self.evaluate(gemfile)
         | 
| 6 | 
            +
                  builder = new
         | 
| 7 | 
            +
                  builder.instance_eval(File.read(gemfile.to_s), gemfile.to_s, 1)
         | 
| 8 | 
            +
                  builder.to_definition
         | 
| 11 9 | 
             
                end
         | 
| 12 10 |  | 
| 13 | 
            -
                def initialize | 
| 14 | 
            -
                  @ | 
| 15 | 
            -
                  @ | 
| 16 | 
            -
                  @ | 
| 17 | 
            -
                  @git_sources = {}
         | 
| 18 | 
            -
                  @only, @except, @directory, @git = nil, nil, nil, nil
         | 
| 11 | 
            +
                def initialize
         | 
| 12 | 
            +
                  @sources = [] # Gem.sources.map { |s| Source::Rubygems.new(:uri => s) }
         | 
| 13 | 
            +
                  @dependencies = []
         | 
| 14 | 
            +
                  @group = nil
         | 
| 19 15 | 
             
                end
         | 
| 20 16 |  | 
| 21 | 
            -
                def  | 
| 22 | 
            -
                   | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
                def bin_path(path)
         | 
| 26 | 
            -
                  @bundle.bindir = Pathname.new(path)
         | 
| 27 | 
            -
                end
         | 
| 17 | 
            +
                def gem(name, *args)
         | 
| 18 | 
            +
                  options = Hash === args.last ? args.pop : {}
         | 
| 19 | 
            +
                  version = args.last || ">= 0"
         | 
| 28 20 |  | 
| 29 | 
            -
             | 
| 30 | 
            -
                  @environment.rubygems = false
         | 
| 31 | 
            -
                end
         | 
| 21 | 
            +
                  _normalize_options(name, version, options)
         | 
| 32 22 |  | 
| 33 | 
            -
             | 
| 34 | 
            -
                  @environment.system_gems = false
         | 
| 23 | 
            +
                  @dependencies << Dependency.new(name, version, options)
         | 
| 35 24 | 
             
                end
         | 
| 36 25 |  | 
| 37 26 | 
             
                def source(source)
         | 
| 38 | 
            -
                  source =  | 
| 39 | 
            -
                   | 
| 40 | 
            -
             | 
| 27 | 
            +
                  source = case source
         | 
| 28 | 
            +
                  when :gemcutter, :rubygems, :rubyforge then Source::Rubygems.new(:uri => "http://gemcutter.org")
         | 
| 29 | 
            +
                  when String then Source::Rubygems.new(:uri => source)
         | 
| 30 | 
            +
                  else source
         | 
| 41 31 | 
             
                  end
         | 
| 42 | 
            -
                end
         | 
| 43 32 |  | 
| 44 | 
            -
             | 
| 45 | 
            -
                   | 
| 46 | 
            -
                  yield
         | 
| 47 | 
            -
                  @only = old
         | 
| 33 | 
            +
                  @sources << source
         | 
| 34 | 
            +
                  source
         | 
| 48 35 | 
             
                end
         | 
| 49 36 |  | 
| 50 | 
            -
                def  | 
| 51 | 
            -
                   | 
| 52 | 
            -
                  yield
         | 
| 53 | 
            -
                  @except = old
         | 
| 54 | 
            -
                end
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                def directory(path, options = {})
         | 
| 57 | 
            -
                  raise DirectorySourceError, "cannot nest calls to directory or git" if @directory || @git
         | 
| 58 | 
            -
                  @directory = DirectorySource.new(@bundle, options.merge(:location => path))
         | 
| 59 | 
            -
                  @directory_sources << @directory
         | 
| 60 | 
            -
                  @environment.add_priority_source(@directory)
         | 
| 61 | 
            -
                  retval = yield if block_given?
         | 
| 62 | 
            -
                  @directory = nil
         | 
| 63 | 
            -
                  retval
         | 
| 37 | 
            +
                def path(path, options = {})
         | 
| 38 | 
            +
                  source Source::Path.new(options.merge(:path => path))
         | 
| 64 39 | 
             
                end
         | 
| 65 40 |  | 
| 66 41 | 
             
                def git(uri, options = {})
         | 
| 67 | 
            -
                   | 
| 68 | 
            -
                  @git = GitSource.new(@bundle, options.merge(:uri => uri))
         | 
| 69 | 
            -
                  @git_sources[uri] = @git
         | 
| 70 | 
            -
                  @environment.add_priority_source(@git)
         | 
| 71 | 
            -
                  retval = yield if block_given?
         | 
| 72 | 
            -
                  @git = nil
         | 
| 73 | 
            -
                  retval
         | 
| 42 | 
            +
                  source Source::Git.new(options.merge(:uri => uri))
         | 
| 74 43 | 
             
                end
         | 
| 75 44 |  | 
| 76 | 
            -
                def  | 
| 77 | 
            -
                  @ | 
| 45 | 
            +
                def to_definition
         | 
| 46 | 
            +
                  Definition.new(@dependencies, @sources)
         | 
| 78 47 | 
             
                end
         | 
| 79 48 |  | 
| 80 | 
            -
                def  | 
| 81 | 
            -
                   | 
| 82 | 
            -
                   | 
| 83 | 
            -
             | 
| 84 | 
            -
                   | 
| 85 | 
            -
                  unless (invalid = options.keys - keys).empty?
         | 
| 86 | 
            -
                    raise InvalidKey, "Only #{keys.join(", ")} are valid options to #gem. You used #{invalid.join(", ")}"
         | 
| 87 | 
            -
                  end
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                  if path = options.delete(:vendored_at)
         | 
| 90 | 
            -
                    options[:path] = path
         | 
| 91 | 
            -
                    warn "The :vendored_at option is deprecated. Use :path instead.\nFrom #{caller[0]}"
         | 
| 92 | 
            -
                  end
         | 
| 93 | 
            -
             | 
| 94 | 
            -
                  options[:only] = _combine_only(options[:only] || options["only"])
         | 
| 95 | 
            -
                  options[:except] = _combine_except(options[:except] || options["except"])
         | 
| 96 | 
            -
             | 
| 97 | 
            -
                  dep = Dependency.new(name, options.merge(:version => version))
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                  if options.key?(:bundle) && !options[:bundle]
         | 
| 100 | 
            -
                    dep.source = SystemGemSource.new(@bundle)
         | 
| 101 | 
            -
                  elsif @git || options[:git]
         | 
| 102 | 
            -
                    dep.source = _handle_git_option(name, version, options)
         | 
| 103 | 
            -
                  elsif @directory || options[:path]
         | 
| 104 | 
            -
                    dep.source = _handle_vendored_option(name, version, options)
         | 
| 105 | 
            -
                  end
         | 
| 106 | 
            -
             | 
| 107 | 
            -
                  @environment.dependencies << dep
         | 
| 49 | 
            +
                def group(name, options = {}, &blk)
         | 
| 50 | 
            +
                  old, @group = @group, name
         | 
| 51 | 
            +
                  yield
         | 
| 52 | 
            +
                ensure
         | 
| 53 | 
            +
                  @group = old
         | 
| 108 54 | 
             
                end
         | 
| 109 55 |  | 
| 110 56 | 
             
              private
         | 
| @@ -113,70 +59,24 @@ module Bundler | |
| 113 59 | 
             
                  version && Gem::Version.new(version) rescue false
         | 
| 114 60 | 
             
                end
         | 
| 115 61 |  | 
| 116 | 
            -
                def  | 
| 117 | 
            -
                   | 
| 118 | 
            -
             | 
| 119 | 
            -
                  if dir
         | 
| 120 | 
            -
                    dir.required_specs << name
         | 
| 121 | 
            -
                    dir.add_spec(path, name, version) if _version?(version)
         | 
| 122 | 
            -
                    dir
         | 
| 123 | 
            -
                  else
         | 
| 124 | 
            -
                    directory options[:path] do
         | 
| 125 | 
            -
                      _handle_vendored_option(name, version, {})
         | 
| 126 | 
            -
                    end
         | 
| 127 | 
            -
                  end
         | 
| 128 | 
            -
                end
         | 
| 129 | 
            -
             | 
| 130 | 
            -
                def _find_directory_source(path)
         | 
| 131 | 
            -
                  if @directory
         | 
| 132 | 
            -
                    return @directory, Pathname.new(path || '')
         | 
| 62 | 
            +
                def _normalize_options(name, version, opts)
         | 
| 63 | 
            +
                  opts.each do |k, v|
         | 
| 64 | 
            +
                    opts[k.to_s] = v
         | 
| 133 65 | 
             
                  end
         | 
| 134 66 |  | 
| 135 | 
            -
                   | 
| 136 | 
            -
             | 
| 137 | 
            -
                  @directory_sources.each do |s|
         | 
| 138 | 
            -
                    if s.location.expand_path.to_s < path.expand_path.to_s
         | 
| 139 | 
            -
                      return s, path.relative_path_from(s.location)
         | 
| 140 | 
            -
                    end
         | 
| 141 | 
            -
                  end
         | 
| 67 | 
            +
                  opts["group"] ||= @group
         | 
| 142 68 |  | 
| 143 | 
            -
                   | 
| 69 | 
            +
                  _normalize_git_options(name, version, opts)
         | 
| 144 70 | 
             
                end
         | 
| 145 71 |  | 
| 146 | 
            -
                def  | 
| 147 | 
            -
                   | 
| 148 | 
            -
                   | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
                    if ref && source.ref != ref
         | 
| 153 | 
            -
                      raise GitSourceError, "'#{git}' already specified with ref: #{source.ref}"
         | 
| 154 | 
            -
                    elsif branch && source.branch != branch
         | 
| 155 | 
            -
                      raise GitSourceError, "'#{git}' already specified with branch: #{source.branch}"
         | 
| 156 | 
            -
                    end
         | 
| 157 | 
            -
             | 
| 158 | 
            -
                    source.required_specs << name
         | 
| 159 | 
            -
                    source.add_spec(Pathname.new(options[:path] || '.'), name, version) if _version?(version)
         | 
| 160 | 
            -
                    source
         | 
| 161 | 
            -
                  else
         | 
| 162 | 
            -
                    git(git, :ref => ref, :branch => branch) do
         | 
| 163 | 
            -
                      _handle_git_option(name, version, options)
         | 
| 164 | 
            -
                    end
         | 
| 72 | 
            +
                def _normalize_git_options(name, version, opts)
         | 
| 73 | 
            +
                  # Normalize Git options
         | 
| 74 | 
            +
                  if opts["git"]
         | 
| 75 | 
            +
                    source  = git(opts["git"], :ref => opts["ref"])
         | 
| 76 | 
            +
                    source.default_spec name, version if _version?(version)
         | 
| 77 | 
            +
                    opts["source"] = source
         | 
| 165 78 | 
             
                  end
         | 
| 166 79 | 
             
                end
         | 
| 167 80 |  | 
| 168 | 
            -
                def _combine_only(only)
         | 
| 169 | 
            -
                  return @only unless only
         | 
| 170 | 
            -
                  only = Array(only).compact.uniq.map { |o| o.to_s }
         | 
| 171 | 
            -
                  only &= @only if @only
         | 
| 172 | 
            -
                  only
         | 
| 173 | 
            -
                end
         | 
| 174 | 
            -
             | 
| 175 | 
            -
                def _combine_except(except)
         | 
| 176 | 
            -
                  return @except unless except
         | 
| 177 | 
            -
                  except = Array(except).compact.uniq.map { |o| o.to_s }
         | 
| 178 | 
            -
                  except |= @except if @except
         | 
| 179 | 
            -
                  except
         | 
| 180 | 
            -
                end
         | 
| 181 81 | 
             
              end
         | 
| 182 | 
            -
            end
         | 
| 82 | 
            +
            end
         |