class Gem::Specification

def dependencies_to_gemfile(dependencies, group = nil)

def dependencies_to_gemfile(dependencies, group = nil)
  gemfile = ''
  if dependencies.any?
    gemfile << "group :#{group} do\n" if group
    dependencies.each do |dependency|
      gemfile << '  ' if group
      gemfile << %|gem "#{dependency.name}"|
      req = dependency.requirements_list.first
      gemfile << %|, "#{req}"| if req
      gemfile << "\n"
    end
    gemfile << "end\n" if group
  end
  gemfile
end