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.dup : {}
version = args
_normalize_options(name, version, options)
dep = Dependency.new(name, version, options)
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 GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
"You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})"
end
else
Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
"You should probably keep only one of them.\n" \
"While it's not a problem now, it could cause errors if you change the version of just one of them later."
end
if current.source != dep.source
if current.type == :development
@dependencies.delete current
elsif dep.type == :development
return
else
raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
"You specified that #{dep.name} (#{dep.requirement}) should come from " \
"#{current.source || 'an unspecified source'} and #{dep.source}\n"
end
end
end
@dependencies << dep
end