Sha256: 972f86224de438fbb8fa16759b420a767ee5593193b44ecd8bbd565e21dfddde

Contents?: true

Size: 1.09 KB

Versions: 18

Compression:

Stored size: 1.09 KB

Contents

#!/usr/bin/env ruby

require 'gems'
require 'ostruct'
require 'terminal-table'

versions = Gems.versions('image_optim_pack').map(&OpenStruct.method(:new))
platforms = versions.map(&:platform).uniq.sort_by do |platform|
  platform.sub('amd64', 'x86_64').split('-').reverse
end

$stdout << Terminal::Table.new do |table|
  table.headings = %W[version base\ dls] + platforms.map do |platform|
    platform.split('-').reverse.join("\n")
  end

  versions.group_by(&:number).each do |version_number, platform_versions|
    next if platform_versions.length == 1
    downloads_by_platform = Hash[platform_versions.map do |version|
      [version.platform, version.downloads_count]
    end]

    base_downloads = platform_versions.map(&:downloads_count).min

    platform_values = downloads_by_platform.values_at(*platforms).map do |count|
      next unless count
      count == base_downloads ? '=' : format('%+d', count - base_downloads)
    end
    table << [version_number, base_downloads] + platform_values
  end

  (1...table.number_of_columns).each do |column|
    table.align_column(column, :right)
  end
end << "\n"

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
image_optim_pack-0.5.0.20171208-x86_64-openbsd script/platform_downloads
image_optim_pack-0.5.0.20171208-x86-openbsd script/platform_downloads
image_optim_pack-0.5.0.20171208-x86_64-linux script/platform_downloads
image_optim_pack-0.5.0.20171208-x86-linux script/platform_downloads
image_optim_pack-0.5.0.20171208-x86-freebsd script/platform_downloads
image_optim_pack-0.5.0.20171208-amd64-freebsd script/platform_downloads
image_optim_pack-0.5.0.20171208-x86_64-darwin script/platform_downloads
image_optim_pack-0.5.0.20171208-x86-darwin script/platform_downloads
image_optim_pack-0.5.0.20171208 script/platform_downloads
image_optim_pack-0.5.0.20171101-x86_64-openbsd script/platform_downloads
image_optim_pack-0.5.0.20171101-x86-openbsd script/platform_downloads
image_optim_pack-0.5.0.20171101-x86_64-linux script/platform_downloads
image_optim_pack-0.5.0.20171101-x86-linux script/platform_downloads
image_optim_pack-0.5.0.20171101-x86-freebsd script/platform_downloads
image_optim_pack-0.5.0.20171101-amd64-freebsd script/platform_downloads
image_optim_pack-0.5.0.20171101-x86_64-darwin script/platform_downloads
image_optim_pack-0.5.0.20171101-x86-darwin script/platform_downloads
image_optim_pack-0.5.0.20171101 script/platform_downloads