Sha256: c6a19dc1dd18cda16d201c7b6ab901e3f3cc605d1bee2dd251aabfb784417b45

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require "compact_index/version"
require "compact_index/versions_file"

module CompactIndex
  def self.names(gem_names)
    "---\n" << gem_names.join("\n") << "\n"
  end

  def self.versions(versions_file, gems)
    versions_file.contents(gems)
  end

  def self.info(params)
    output = "---\n"
    params.each do |version|
      output << version_line(version) << "\n"
    end
    output
  end

  private
    def self.version_line(version)
      if version[:dependencies]
        version[:dependencies]
        deps = version[:dependencies].map do |d|
          [
             d[:gem],
             number_and_platform(d[:version],d[:platform]).gsub(/, /, "&")
          ].join(':')
        end
      else
        deps = []
      end

      line = number_and_platform(version[:number], version[:platform])
      line << " "
      line << deps.join(",")
      line << "|"

      line << "checksum:#{version[:checksum]}"
      line << ",ruby:#{version[:ruby_version]}" if version[:ruby_version]
      line << ",rubygems:#{version[:rubygems_version]}" if version[:rubygems_version]

      line
    end

    def self.number_and_platform(number, platform)
      if platform.nil? || platform == 'ruby'
        number
      else
        "#{number}-#{platform}"
      end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
compact_index-0.9.0 lib/compact_index.rb