class Bundler::Definition

def to_lock

def to_lock
  out = ""
  sorted_sources.each do |source|
    # Add the source header
    out << source.to_lock
    # Find all specs for this source
    resolve.
      select  { |s| s.source == source }.
      # This needs to be sorted by full name so that
      # gems with the same name, but different platform
      # are ordered consistently
      sort_by { |s| s.full_name }.
      each do |spec|
        next if spec.name == 'bundler'
        out << spec.to_lock
    end
    out << "\n"
  end
  out << "PLATFORMS\n"
  platforms.map { |p| p.to_s }.sort.each do |p|
    out << "  #{p}\n"
  end
  out << "\n"
  out << "DEPENDENCIES\n"
  handled = []
  dependencies.
    sort_by { |d| d.to_s }.
    each do |dep|
      next if handled.include?(dep.name)
      out << dep.to_lock
      handled << dep.name
  end
  out
end