Class: CFME::Versions

Inherits:
Object
  • Object
show all
Extended by:
Enumerable
Defined in:
lib/cfme-versions.rb

Constant Summary collapse

FIELDS =
[
     "MANAGEIQ",      "CLOUDFORMS MANAGEMENT ENGINE", "CLOUDFORMS", "RUBY", "RAILS", "POSTGRESQL"
].freeze
VERSIONS =
[
  %w[ N/A              5.1.z                           2.0           N/A     N/A      N/A        ],
  %w[ N/A              5.2.z                           3.0           N/A     N/A      N/A        ],
  %w[ Anand            5.3.z                           3.1           N/A     N/A      N/A        ],
  %w[ Botvinnik        5.4.z                           3.1           N/A     N/A      N/A        ],
  %w[ Capablanca       5.5.z                           4.0           2.2.z   4.2.z    9.4.z      ],
  %w[ Darga            5.6.z                           4.1           2.2.z   5.0.z    9.4.z      ],
  %w[ Euwe             5.7.z                           4.1           2.3.z   5.0.z    9.5.z      ],
  %w[ Fine             5.8.z                           4.5           2.3.z   5.0.z    9.5.z      ],
  %w[ Gaprindashvili   5.9.z                           4.6           2.3.z   5.0.z    9.5.z      ],
  %w[ Hammer           5.10.z                          4.7           2.4.z   5.0.z    9.5.z      ],
  %w[ Ivanchuk         5.11.z                          5.0           2.5.z   5.1.z    10.y       ],
  %w[ Jansa            5.12.z                          5.1           2.5.z   5.2.z    10.y       ]
].freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.markdownObject

Returns the value of attribute markdown.



63
64
65
# File 'lib/cfme-versions.rb', line 63

def markdown
  @markdown
end

Class Method Details

.[](index) ⇒ Object



88
89
90
# File 'lib/cfme-versions.rb', line 88

def [](index)
  versions[index]
end

.eachObject



80
81
82
# File 'lib/cfme-versions.rb', line 80

def each
  versions.each { |version| yield version }
end

.lastObject



84
85
86
# File 'lib/cfme-versions.rb', line 84

def last
  versions.last
end


105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/cfme-versions.rb', line 105

def print_help
  puts <<-HELP.gsub(/^ {10}/, '')
    usage:  cfme-versions [OPTION]...

    Options:

        --markdown    Print table in markdown format
        --version     Prints the version number and exits
        --help        This help

  HELP
  exit
end


119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/cfme-versions.rb', line 119

def print_table
  # Print Header
  puts spacer unless markdown
  puts printable_row(FIELDS)
  puts spacer

  # 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
  puts spacer unless markdown
end


133
134
135
136
# File 'lib/cfme-versions.rb', line 133

def print_version
  puts CFME::Versions.version
  exit
end

.raw_dataObject



101
102
103
# File 'lib/cfme-versions.rb', line 101

def raw_data
  @raw_data ||= VERSIONS.dup
end

.run(argv = ARGV) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cfme-versions.rb', line 65

def run(argv = ARGV)
  until argv.empty?
    arg = argv.shift

    # The `return` statements are there for specs
    case arg
    when "--markdown" then self.markdown = true
    when "--version"  then return print_version
    when "--help"     then return print_help
    end
  end

  CFME::Versions.print_table
end

.versionObject

Version of this gem/tool



93
94
95
# File 'lib/cfme-versions.rb', line 93

def version
  versions.last.cfme_release.split(".").select { |val| val =~ /^\d+$/ }.join('.')
end

.versionsObject



97
98
99
# File 'lib/cfme-versions.rb', line 97

def versions
  @versions ||= raw_data.map { |data| Version.new(*data) }
end