Deprecated methods
# File lib/bundler/dsl.rb, line 168 168: def self.deprecate(name, replacement = nil) 169: define_method(name) do |*| 170: message = "'#{name}' has been removed from the Gemfile DSL, " 171: if replacement 172: message << "and has been replaced with '#{replacement}'." 173: else 174: message << "and is no longer supported." 175: end 176: message << "\nSee the README for more information on upgrading from Bundler 0.8." 177: raise DeprecatedError, message 178: end 179: end
# File lib/bundler/dsl.rb, line 5 5: def self.evaluate(gemfile, lockfile, unlock) 6: builder = new 7: builder.instance_eval(Bundler.read_file(gemfile.to_s), gemfile.to_s, 1) 8: builder.to_definition(lockfile, unlock) 9: rescue ScriptError, RegexpError, NameError, ArgumentError => e 10: e.backtrace[0] = "#{e.backtrace[0]}: #{e.message} (#{e.class})" 11: Bundler.ui.info e.backtrace.join("\n ") 12: raise GemfileError, "There was an error in your Gemfile," " and Bundler cannot continue." 13: end
# File lib/bundler/dsl.rb, line 159 159: def env(name) 160: @env, old = name, @env 161: yield 162: ensure 163: @env = old 164: end
# File lib/bundler/dsl.rb, line 54 54: def gem(name, *args) 55: if name.is_a?(Symbol) 56: raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.} 57: end 58: 59: options = Hash === args.last ? args.pop : {} 60: version = args || [">= 0"] 61: 62: _deprecated_options(options) 63: _normalize_options(name, version, options) 64: 65: dep = Dependency.new(name, version, options) 66: 67: # if there's already a dependency with this name we try to prefer one 68: if current = @dependencies.find { |d| d.name == dep.name } 69: if current.requirement != dep.requirement 70: if current.type == :development 71: @dependencies.delete current 72: elsif dep.type == :development 73: return 74: else 75: raise DslError, "You cannot specify the same gem twice with different version requirements. " "You specified: #{current.name} (#{current.requirement}) and " "#{dep.name} (#{dep.requirement})" 76: end 77: end 78: 79: if current.source != dep.source 80: if current.type == :development 81: @dependencies.delete current 82: elsif dep.type == :development 83: return 84: else 85: 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}" 86: end 87: end 88: end 89: 90: @dependencies << dep 91: end
# File lib/bundler/dsl.rb, line 30 30: def gemspec(opts = nil) 31: path = opts && opts[:path] || '.' 32: name = opts && opts[:name] || '{,*}' 33: development_group = opts && opts[:development_group] || :development 34: path = File.expand_path(path, Bundler.default_gemfile.dirname) 35: gemspecs = Dir[File.join(path, "#{name}.gemspec")] 36: 37: case gemspecs.size 38: when 1 39: spec = Bundler.load_gemspec(gemspecs.first) 40: raise InvalidOption, "There was an error loading the gemspec at #{gemspecs.first}." unless spec 41: gem spec.name, :path => path 42: group(development_group) do 43: spec.development_dependencies.each do |dep| 44: gem dep.name, *(dep.requirement.as_list + [:type => :development]) 45: end 46: end 47: when 0 48: raise InvalidOption, "There are no gemspecs at #{path}." 49: else 50: raise InvalidOption, "There are multiple gemspecs at #{path}. Please use the :name option to specify which one." 51: end 52: end
# File lib/bundler/dsl.rb, line 124 124: def git(uri, options = {}, source_options = {}, &blk) 125: unless block_given? 126: 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" 127: raise DeprecatedError, msg 128: end 129: 130: source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options, &blk 131: end
# File lib/bundler/dsl.rb, line 144 144: def group(*args, &blk) 145: @groups.concat args 146: yield 147: ensure 148: args.each { @groups.pop } 149: end
# File lib/bundler/dsl.rb, line 120 120: def path(path, options = {}, source_options = {}, &blk) 121: source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk 122: end
# File lib/bundler/dsl.rb, line 151 151: def platforms(*platforms) 152: @platforms.concat platforms 153: yield 154: ensure 155: platforms.each { @platforms.pop } 156: end
# File lib/bundler/dsl.rb, line 97 97: def source(source, options = {}) 98: case source 99: when :gemcutter, :rubygems, :rubyforge then 100: @rubygems_source.add_remote "http://rubygems.org" 101: return 102: when String 103: @rubygems_source.add_remote source 104: return 105: else 106: @source = source 107: if options[:prepend] 108: @sources = [@source] | @sources 109: else 110: @sources = @sources | [@source] 111: end 112: 113: yield if block_given? 114: return @source 115: end 116: ensure 117: @source = nil 118: end
# File lib/bundler/dsl.rb, line 246 246: def _deprecated_options(options) 247: end
# File lib/bundler/dsl.rb, line 183 183: def _normalize_hash(opts) 184: # Cannot modify a hash during an iteration in 1.9 185: opts.keys.each do |k| 186: next if String === k 187: v = opts[k] 188: opts.delete(k) 189: opts[k.to_s] = v 190: end 191: opts 192: end
# File lib/bundler/dsl.rb, line 194 194: def _normalize_options(name, version, opts) 195: _normalize_hash(opts) 196: 197: invalid_keys = opts.keys - %(group groups git github path name branch ref tag require submodules platform platforms type) 198: if invalid_keys.any? 199: plural = invalid_keys.size > 1 200: message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} " 201: if plural 202: message << "as options for gem '#{name}', but they are invalid." 203: else 204: message << "as an option for gem '#{name}', but it is invalid." 205: end 206: raise InvalidOption, message 207: end 208: 209: groups = @groups.dup 210: opts["group"] = opts.delete("groups") || opts["group"] 211: groups.concat Array(opts.delete("group")) 212: groups = [:default] if groups.empty? 213: 214: platforms = @platforms.dup 215: opts["platforms"] = opts["platform"] || opts["platforms"] 216: platforms.concat Array(opts.delete("platforms")) 217: platforms.map! { |p| p.to_sym } 218: platforms.each do |p| 219: next if VALID_PLATFORMS.include?(p) 220: raise DslError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}" 221: end 222: 223: if github = opts.delete("github") 224: github = "#{github}/#{github}" unless github.include?("/") 225: opts["git"] = "git://github.com/#{github}.git" 226: end 227: 228: ["git", "path"].each do |type| 229: if param = opts[type] 230: if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/ 231: options = opts.merge("name" => name, "version" => $1) 232: else 233: options = opts.dup 234: end 235: source = send(type, param, options, :prepend => true) {} 236: opts["source"] = source 237: end 238: end 239: 240: opts["source"] ||= @source 241: opts["env"] ||= @env 242: opts["platforms"] = platforms.dup 243: opts["group"] = groups 244: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.