Object
Deprecated methods
# File lib/bundler/dsl.rb, line 144 144: def self.deprecate(name, replacement = nil) 145: define_method(name) do |*| 146: message = "'#{name}' has been removed from the Gemfile DSL, " 147: if replacement 148: message << "and has been replaced with '#{replacement}'." 149: else 150: message << "and is no longer supported." 151: end 152: message << "\nSee the README for more information on upgrading from Bundler 0.8." 153: raise DeprecatedError, message 154: end 155: end
# File lib/bundler/dsl.rb, line 135 135: def env(name) 136: @env, old = name, @env 137: yield 138: ensure 139: @env = old 140: end
# File lib/bundler/dsl.rb, line 47 47: def gem(name, *args) 48: if name.is_a?(Symbol) 49: raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.} 50: end 51: 52: options = Hash === args.last ? args.pop : {} 53: version = args || [">= 0"] 54: 55: _deprecated_options(options) 56: _normalize_options(name, version, options) 57: 58: dep = Dependency.new(name, version, options) 59: 60: if current = @dependencies.find { |d| d.name == dep.name } 61: if current.requirement != dep.requirement 62: raise DslError, "You cannot specify the same gem twice with different version requirements. " "You specified: #{current.name} (#{current.requirement}) and " "#{dep.name} (#{dep.requirement})" 63: end 64: 65: if current.source != dep.source 66: 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}" 67: end 68: end 69: @dependencies << Dependency.new(name, version, options) 70: 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 = Bundler.load_gemspec(gemspecs.first) 33: raise InvalidOption, "There was an error loading the gemspec at #{gemspecs.first}." unless spec 34: gem spec.name, :path => path 35: group(development_group) do 36: spec.development_dependencies.each do |dep| 37: gem dep.name, *dep.requirement.as_list 38: end 39: end 40: when 0 41: raise InvalidOption, "There are no gemspecs at #{path}." 42: else 43: raise InvalidOption, "There are multiple gemspecs at #{path}. Please use the :name option to specify which one." 44: end 45: end
# File lib/bundler/dsl.rb, line 99 99: def git(uri, options = {}, source_options = {}, &blk) 100: unless block_given? 101: 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" 102: raise DeprecatedError, msg 103: end 104: 105: source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options, &blk 106: end
# File lib/bundler/dsl.rb, line 120 120: def group(*args, &blk) 121: @groups.concat args 122: yield 123: ensure 124: args.each { @groups.pop } 125: end
# File lib/bundler/dsl.rb, line 95 95: def path(path, options = {}, source_options = {}, &blk) 96: source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk 97: end
# File lib/bundler/dsl.rb, line 127 127: def platforms(*platforms) 128: @platforms.concat platforms 129: yield 130: ensure 131: platforms.each { @platforms.pop } 132: end
# File lib/bundler/dsl.rb, line 76 76: def source(source, options = {}) 77: case source 78: when :gemcutter, :rubygems, :rubyforge then 79: rubygems_source "http://rubygems.org" 80: return 81: when String 82: rubygems_source source 83: return 84: end 85: 86: @source = source 87: options[:prepend] ? @sources.unshift(@source) : @sources << @source 88: 89: yield if block_given? 90: @source 91: ensure 92: @source = nil 93: end
# File lib/bundler/dsl.rb, line 231 231: def _deprecated_options(options) 232: if options.include?(:require_as) 233: raise DeprecatedError, "Please replace :require_as with :require" 234: elsif options.include?(:vendored_at) 235: raise DeprecatedError, "Please replace :vendored_at with :path" 236: elsif options.include?(:only) 237: raise DeprecatedError, "Please replace :only with :group" 238: elsif options.include?(:except) 239: raise DeprecatedError, "The :except option is no longer supported" 240: end 241: end
# File lib/bundler/dsl.rb, line 172 172: def _normalize_hash(opts) 173: # Cannot modify a hash during an iteration in 1.9 174: opts.keys.each do |k| 175: next if String === k 176: v = opts[k] 177: opts.delete(k) 178: opts[k.to_s] = v 179: end 180: opts 181: end
# File lib/bundler/dsl.rb, line 183 183: def _normalize_options(name, version, opts) 184: _normalize_hash(opts) 185: 186: invalid_keys = opts.keys - %(group groups git path name branch ref tag require submodules platform platforms) 187: if invalid_keys.any? 188: plural = invalid_keys.size > 1 189: message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} " 190: if plural 191: message << "as options for gem '#{name}', but they are invalid." 192: else 193: message << "as an option for gem '#{name}', but it is invalid." 194: end 195: raise InvalidOption, message 196: end 197: 198: groups = @groups.dup 199: opts["group"] = opts.delete("groups") || opts["group"] 200: groups.concat Array(opts.delete("group")) 201: groups = [:default] if groups.empty? 202: 203: platforms = @platforms.dup 204: opts["platforms"] = opts["platform"] || opts["platforms"] 205: platforms.concat Array(opts.delete("platforms")) 206: platforms.map! { |p| p.to_sym } 207: platforms.each do |p| 208: next if VALID_PLATFORMS.include?(p) 209: raise DslError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}" 210: end 211: 212: # Normalize git and path options 213: ["git", "path"].each do |type| 214: if param = opts[type] 215: if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/ 216: options = opts.merge("name" => name, "version" => $1) 217: else 218: options = opts.dup 219: end 220: source = send(type, param, options, :prepend => true) {} 221: opts["source"] = source 222: end 223: end 224: 225: opts["source"] ||= @source 226: opts["env"] ||= @env 227: opts["platforms"] = platforms.dup 228: opts["group"] = groups 229: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.