class Bundler::Definition

def to_lock

def to_lock
  out = ""
  sources.lock_sources.each do |source|
    # Add the source header
    out << source.to_lock
    # Find all specs for this source
    resolve.
      select { |s| source.can_lock?(s) }.
      # 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
  # Record the version of Bundler that was used to create the lockfile
  out << "\nBUNDLED WITH\n"
  out << "  #{lock_version}\n"
  out
end