class Bundler::Dsl
def gem(name, *args)
def gem(name, *args) if name.is_a?(Symbol) raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.} end options = Hash === args.last ? args.pop : {} version = args || [">= 0"] _deprecated_options(options) _normalize_options(name, version, options) dep = Dependency.new(name, version, options) # if there's already a dependency with this name we try to prefer one if current = @dependencies.find { |d| d.name == dep.name } if current.requirement != dep.requirement if current.type == :development @dependencies.delete current elsif dep.type == :development return else raise DslError, "You cannot specify the same gem twice with different version requirements. " \ "You specified: #{current.name} (#{current.requirement}) and " \ "#{dep.name} (#{dep.requirement})" end end if current.source != dep.source if current.type == :development @dependencies.delete current elsif dep.type == :development return else 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}" end end end @dependencies << dep end