Object
Deprecated methods
# File lib/bundler/dsl.rb, line 148 148: def self.deprecate(name, replacement = nil) 149: define_method(name) do |*| 150: message = "'#{name}' has been removed from the Gemfile DSL, " 151: if replacement 152: message << "and has been replaced with '#{replacement}'." 153: else 154: message << "and is no longer supported." 155: end 156: message << "\nSee the README for more information on upgrading from Bundler 0.8." 157: raise DeprecatedError, message 158: end 159: end
# File lib/bundler/dsl.rb, line 139 139: def env(name) 140: @env, old = name, @env 141: yield 142: ensure 143: @env = old 144: end
# File lib/bundler/dsl.rb, line 49 49: def gem(name, *args) 50: if name.is_a?(Symbol) 51: raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.} 52: end 53: 54: options = Hash === args.last ? args.pop : {} 55: version = args || [">= 0"] 56: if group = options[:groups] || options[:group] 57: options[:group] = group 58: end 59: 60: _deprecated_options(options) 61: _normalize_options(name, version, options) 62: 63: dep = Dependency.new(name, version, options) 64: 65: if current = @dependencies.find { |d| d.name == dep.name } 66: if current.requirement != dep.requirement 67: raise DslError, "You cannot specify the same gem twice with different version requirements. " "You specified: #{current.name} (#{current.requirement}) and " "#{dep.name} (#{dep.requirement})" 68: end 69: 70: if current.source != dep.source 71: raise DslError, "You cannot specify the same gem twice coming from different sources. You " "specified that #{dep.name} (#{dep.requirement}) should come from " "#{current.source || 'an unspecfied source'} and #{dep.source}" 72: end 73: end 74: @dependencies << Dependency.new(name, version, options) 75: end
# File lib/bundler/dsl.rb, line 23 23: def gemspec(opts = nil) 24: path = opts && opts[:path] || '.' 25: name = opts && opts[:name] || '*' 26: development_group = opts && opts[:development_group] || :development 27: path = File.expand_path(path, Bundler.default_gemfile.dirname) 28: gemspecs = Dir[File.join(path, "#{name}.gemspec")] 29: 30: case gemspecs.size 31: when 1 32: spec = Gem::Specification.load(gemspecs.first) 33: gem spec.name, :path => path 34: spec.runtime_dependencies.each do |dep| 35: gem dep.name, dep.requirement.to_s 36: end 37: group(development_group) do 38: spec.development_dependencies.each do |dep| 39: gem dep.name, dep.requirement.to_s 40: end 41: end 42: when 0 43: raise InvalidOption, "There are no gemspecs at #{path}." 44: else 45: raise InvalidOption, "There are multiple gemspecs at #{path}. Please use the :name option to specify which one." 46: end 47: end
# File lib/bundler/dsl.rb, line 104 104: def git(uri, options = {}, source_options = {}, &blk) 105: unless block_given? 106: msg = "You can no longer specify a git source by itself. Instead, \n" "either use the :git option on a gem, or specify the gems that \n" "bundler should find in the git source by passing a block to \n" "the git method, like: \n\n" " git 'git://github.com/rails/rails.git' do\n" " gem 'rails'\n" " end" 107: raise DeprecatedError, msg 108: end 109: 110: source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options, &blk 111: end
# File lib/bundler/dsl.rb, line 125 125: def group(*args, &blk) 126: @groups.concat args 127: yield 128: ensure 129: args.each { @groups.pop } 130: end
# File lib/bundler/dsl.rb, line 100 100: def path(path, options = {}, source_options = {}, &blk) 101: source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk 102: end
# File lib/bundler/dsl.rb, line 132 132: def platforms(*platforms) 133: @platforms.concat platforms 134: yield 135: ensure 136: platforms.each { @platforms.pop } 137: end
# File lib/bundler/dsl.rb, line 81 81: def source(source, options = {}) 82: case source 83: when :gemcutter, :rubygems, :rubyforge then 84: rubygems_source "http://rubygems.org" 85: return 86: when String 87: rubygems_source source 88: return 89: end 90: 91: @source = source 92: options[:prepend] ? @sources.unshift(@source) : @sources << @source 93: 94: yield if block_given? 95: @source 96: ensure 97: @source = nil 98: end
# File lib/bundler/dsl.rb, line 233 233: def _deprecated_options(options) 234: if options.include?(:require_as) 235: raise DeprecatedError, "Please replace :require_as with :require" 236: elsif options.include?(:vendored_at) 237: raise DeprecatedError, "Please replace :vendored_at with :path" 238: elsif options.include?(:only) 239: raise DeprecatedError, "Please replace :only with :group" 240: elsif options.include?(:except) 241: raise DeprecatedError, "The :except option is no longer supported" 242: end 243: end
# File lib/bundler/dsl.rb, line 176 176: def _normalize_hash(opts) 177: # Cannot modify a hash during an iteration in 1.9 178: opts.keys.each do |k| 179: next if String === k 180: v = opts[k] 181: opts.delete(k) 182: opts[k.to_s] = v 183: end 184: opts 185: end
# File lib/bundler/dsl.rb, line 187 187: def _normalize_options(name, version, opts) 188: _normalize_hash(opts) 189: 190: invalid_keys = opts.keys - %(group git path name branch ref tag require submodules platforms) 191: if invalid_keys.any? 192: plural = invalid_keys.size > 1 193: message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} " 194: if plural 195: message << "as options for gem '#{name}', but they are invalid." 196: else 197: message << "as an option for gem '#{name}', but it is invalid." 198: end 199: raise InvalidOption, message 200: end 201: 202: groups = @groups.dup 203: groups.concat Array(opts.delete("group")) 204: groups = [:default] if groups.empty? 205: 206: platforms = @platforms.dup 207: platforms.concat Array(opts.delete("platforms")) 208: platforms.map! { |p| p.to_sym } 209: platforms.each do |p| 210: next if VALID_PLATFORMS.include?(p) 211: raise DslError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}" 212: end 213: 214: # Normalize git and path options 215: ["git", "path"].each do |type| 216: if param = opts[type] 217: if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/ 218: options = opts.merge("name" => name, "version" => $1) 219: else 220: options = opts.dup 221: end 222: source = send(type, param, options, :prepend => true) {} 223: opts["source"] = source 224: end 225: end 226: 227: opts["source"] ||= @source 228: opts["env"] ||= @env 229: opts["platforms"] = @platforms.dup 230: opts["group"] = groups 231: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.