Sha256: d30769974cff8def5b667d9aba0e7bf110e7165e00ed1d7b5765705835648b7d

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 KB

Contents

#!/usr/bin/env ruby

require 'faraday'
require 'tty-table'
require 'pastel'

if ENV['HACKING']
  require_relative '../lib/cloudstrap'
else
  require 'cloudstrap'
end

CLOUDSTRAP_VERSION = $LOADED_FEATURES
                       .map { |f| f.match %r{cloudstrap-(?<version>[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(\.pre)?)} }
                       .compact
                       .map { |m| m['version'] }
                       .uniq
                       .first

gem = ->(name) { MultiJson.load Faraday.new(Gem.host).get("/api/v1/gems/#{name}.json").body }
latest_cloudstrap = gem.(:cloudstrap)['version']

config = Cloudstrap::Config.new

green = Pastel.new.green.detach
red = Pastel.new.red.detach

cloudstrap = ((CLOUDSTRAP_VERSION.nil? || CLOUDSTRAP_VERSION.end_with?('pre')) ? red : green).call CLOUDSTRAP_VERSION
latest = ->(component) { config.send(:latest).send(component) }
using  = ->(component) { config.send("#{component}_version") }

version = ->(component) { (using.(component) == latest.(component) ? green : red).call using.(component) }

table = TTY::Table.new %w(component using latest), [
                         ['cloudstrap', cloudstrap, green.(latest_cloudstrap)],
                         [:hce, version.(:hce), green.(latest.(:hce))],
                         [:hcp, version.(:hcp), green.(latest.(:hcp))],
                         [:hsm, version.(:hsm), green.(latest.(:hsm))]
                       ]

case ARGV.first
when nil, /^--?(p(retty)?|u(nicode)?)$/i
  puts table.render(:unicode)
when /^--?a(scii)?$/i
  puts table.render(:ascii)
when /^--?b(asic)?$/i
  puts Pastel.new.strip table.render(:basic)
else
  STDERR.puts "usage: #{File.basename $PROGRAM_NAME} (--pretty | --unicode | --ascii | --basic)"
  abort
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cloudstrap-0.51.1.pre bin/cloudstrap-versions
cloudstrap-0.50.1.pre bin/cloudstrap-versions
cloudstrap-0.49.12.pre bin/cloudstrap-versions
cloudstrap-0.49.11.pre bin/cloudstrap-versions
cloudstrap-0.49.10.pre bin/cloudstrap-versions
cloudstrap-0.49.8.pre bin/cloudstrap-versions
cloudstrap-0.49.4.pre bin/cloudstrap-versions
cloudstrap-0.49.2.pre bin/cloudstrap-versions
cloudstrap-0.49.1.pre bin/cloudstrap-versions
cloudstrap-0.49.0.pre bin/cloudstrap-versions
cloudstrap-0.48.15.pre bin/cloudstrap-versions
cloudstrap-0.48.2.pre bin/cloudstrap-versions
cloudstrap-0.48.0.pre bin/cloudstrap-versions