Class: Version

Inherits:
Object
  • Object
show all
Defined in:
lib/HMC/Version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string = '') ⇒ Version

Returns a new instance of Version.



11
12
13
14
15
# File 'lib/HMC/Version.rb', line 11

def initialize(string = '')

  @patches = {}
  parse(string) unless string.empty?
end

Instance Attribute Details

#base_versionObject (readonly)

Returns the value of attribute base_version.



7
8
9
# File 'lib/HMC/Version.rb', line 7

def base_version
  @base_version
end

#hmcBuildLevelObject (readonly)

Returns the value of attribute hmcBuildLevel.



6
7
8
# File 'lib/HMC/Version.rb', line 6

def hmcBuildLevel
  @hmcBuildLevel
end

#patchesObject (readonly)

Returns the value of attribute patches.



8
9
10
# File 'lib/HMC/Version.rb', line 8

def patches
  @patches
end

#patches_rawObject (readonly)

Returns the value of attribute patches_raw.



9
10
11
# File 'lib/HMC/Version.rb', line 9

def patches_raw
  @patches_raw
end

#releaseObject (readonly)

Returns the value of attribute release.



4
5
6
# File 'lib/HMC/Version.rb', line 4

def release
  @release
end

#servicePackObject (readonly)

Returns the value of attribute servicePack.



5
6
7
# File 'lib/HMC/Version.rb', line 5

def servicePack
  @servicePack
end

#versionObject (readonly)

Returns the value of attribute version.



3
4
5
# File 'lib/HMC/Version.rb', line 3

def version
  @version
end

Instance Method Details

#hasFix?(fix_name) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/HMC/Version.rb', line 76

def hasFix?(fix_name)
  @patches.key?(fix_name)
end

#parse(string) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/HMC/Version.rb', line 17

def parse(string)

  regexp_all = %r{Version:\s(\d)\s+
\s+Release:\s+(\d\.\d\.\d)\s+
\s+Service\sPack:\s+(\d+)\s+
\s+HMC\sBuild\slevel\s([\d\.]+)\s*
(.*)\s*\"\,\"base_version=(V\dR\d\.\d\.\d)\s+
\s+\"}x

  regexp = %r{Version:\s(\d)\s+
\s+Release:\s+(\d\.\d\.\d)\s+
\s+Service\sPack:\s+(\d+)\s+
HMC\sBuild\slevel\s([\d\.]+)\s*
(.*)\s*
\"\,\"base_version=(V\dR\d\.\d\.\d)\s+
}x


  match = regexp.match(string)

  if match
    @version = match[1]
    @release	= match[2]
    @servicePack = match[3]
    @hmcBuildLevel 	= match[4]
    @patches_raw	= match[5]
    @base_version = match[6]

    parse_patches(@patches_raw) unless @patches_raw.empty?

  else
    puts string
    puts regexp
    puts match
    puts "regexp couldn't decode string #{string}"
    raise

  end
end

#parse_patches(string) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/HMC/Version.rb', line 57

def parse_patches(string)

  regexp = %r{(MH\d{5})\:(.*)}
  match = regexp.match(string)

  if match
    version        = match[1]
    description	 = match[2]
    @patches[version] = description
  else
    puts string
    puts regexp
    puts match
    puts "regexp couldn't decode string #{string}"
    raise
  end

end

#version_cmdObject



80
81
82
# File 'lib/HMC/Version.rb', line 80

def version_cmd
  'lshmc -V'
end