Class: Zypper::Upgraderepo::OsRelease
- Inherits:
-
Object
- Object
- Zypper::Upgraderepo::OsRelease
- Defined in:
- lib/zypper/upgraderepo/os_release.rb
Constant Summary collapse
- OS_VERSIONS =
['13.1', '13.2', '42.1', '42.2', '42.3', '15.0', '15.1', '15.2', '15.3', '15.4']
- UNSTABLE_VERSION =
'15.5'
- OS_RELEASE_FILE =
'/etc/os-release'
- SUSE_RELEASE_FILE =
'/etc/SuSE-release'
Instance Attribute Summary collapse
-
#custom ⇒ Object
readonly
Returns the value of attribute custom.
-
#unstable ⇒ Object
readonly
Returns the value of attribute unstable.
Instance Method Summary collapse
- #current ⇒ Object
- #current?(version) ⇒ Boolean
- #first? ⇒ Boolean
- #fullname ⇒ Object
-
#initialize(options) ⇒ OsRelease
constructor
A new instance of OsRelease.
- #last ⇒ Object
- #last? ⇒ Boolean
- #newer ⇒ Object
- #next ⇒ Object
- #previous ⇒ Object
- #seniority ⇒ Object
- #valid?(version) ⇒ Boolean
Constructor Details
#initialize(options) ⇒ OsRelease
Returns a new instance of OsRelease.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 19 def initialize() if .allow_unstable raise NoUnstableVersionAvailable if UNSTABLE_VERSION.empty? OS_VERSIONS << UNSTABLE_VERSION @unstable = true end fname = if File.exist? self.class::OS_RELEASE_FILE self.class::OS_RELEASE_FILE elsif File.exist? self.class::SUSE_RELEASE_FILE self.class::SUSE_RELEASE_FILE else raise ReleaseFileNotFound end @release = IniParse.parse(File.read(fname)) @current_idx = OS_VERSIONS.index(@release['__anonymous__']['VERSION'].delete('"')) if .version raise InvalidVersion, .version unless OS_VERSIONS.include?(.version) @custom = .version end end |
Instance Attribute Details
#custom ⇒ Object (readonly)
Returns the value of attribute custom.
9 10 11 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 9 def custom @custom end |
#unstable ⇒ Object (readonly)
Returns the value of attribute unstable.
9 10 11 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 9 def unstable @unstable end |
Instance Method Details
#current ⇒ Object
43 44 45 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 43 def current OS_VERSIONS[@current_idx] end |
#current?(version) ⇒ Boolean
95 96 97 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 95 def current?(version) OS_VERSIONS.index(version) == @current_idx end |
#first? ⇒ Boolean
87 88 89 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 87 def first? @current_idx == 0 end |
#fullname ⇒ Object
67 68 69 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 67 def fullname @release['__anonymous__']['PRETTY_NAME'].gsub(/"/, '') end |
#last ⇒ Object
47 48 49 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 47 def last OS_VERSIONS[-1] end |
#last? ⇒ Boolean
83 84 85 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 83 def last? @current_idx == (OS_VERSIONS.count - 1) end |
#newer ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 75 def newer if seniority > 0 OS_VERSIONS[@current_idx.next..-1] else [] end end |
#next ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 51 def next unless last? OS_VERSIONS[@current_idx.next] else nil end end |
#previous ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 59 def previous unless first? OS_VERSIONS[@current_idx.pred] else nil end end |
#seniority ⇒ Object
71 72 73 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 71 def seniority OS_VERSIONS.count - @current_idx.next end |
#valid?(version) ⇒ Boolean
91 92 93 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 91 def valid?(version) OS_VERSIONS.include? version end |