class CFME::Versions
Constants
- FIELDS
- VERSIONS
Public Class Methods
[](index)
click to toggle source
# File lib/cfme-versions.rb, line 68 def [](index) versions[index] end
each() { |version| ... }
click to toggle source
# File lib/cfme-versions.rb, line 60 def each versions.each { |version| yield version } end
last()
click to toggle source
# File lib/cfme-versions.rb, line 64 def last versions.last end
print_help()
click to toggle source
# File lib/cfme-versions.rb, line 86 def print_help puts <<~HELP usage: cfme-versions [OPTION]... Options: --version Prints the version number and exits --help This help HELP exit end
print_table()
click to toggle source
# File lib/cfme-versions.rb, line 99 def print_table # Print Header puts printable_row(FIELDS) puts printable_row(spacings.map { |size| "-" * size }) # Print version data raw_data.each do |version| version_data = version.map { |column| column == "N/A" ? "" : column } # remove N/A values puts printable_row(version_data) end end
print_version()
click to toggle source
# File lib/cfme-versions.rb, line 111 def print_version puts CFME::Versions.version exit end
raw_data()
click to toggle source
# File lib/cfme-versions.rb, line 82 def raw_data @raw_data ||= VERSIONS.dup end
run(argv = ARGV)
click to toggle source
# File lib/cfme-versions.rb, line 46 def run(argv = ARGV) until argv.empty? arg = argv.shift # The `return` statements are there for specs case arg when "--version" then return print_version when "--help" then return print_help end end CFME::Versions.print_table end
version()
click to toggle source
Version of this gem/tool
# File lib/cfme-versions.rb, line 73 def version numbers = versions.last.miq_semver.split(".").select { |val| val =~ /^\d+$/ } + %w[0 0 0] numbers.first(3).join(".") end
versions()
click to toggle source
# File lib/cfme-versions.rb, line 78 def versions @versions ||= raw_data.map { |data| Version.new(*data) } end
Private Class Methods
printable_row(data)
click to toggle source
# File lib/cfme-versions.rb, line 118 def printable_row(data) "| #{data.map.with_index { |header, index| header.ljust(spacings[index]) }.join(" | ")} |" end
spacings()
click to toggle source
Column width based on Miq::Versions.raw_data
# File lib/cfme-versions.rb, line 123 def spacings return @spacings if defined? @spacings @spacings = FIELDS.map(&:length) raw_data.each do |version| version.each.with_index do |col, index| @spacings[index] = [@spacings[index].to_i, col.length].max end end @spacings end