Class: Zypper::Upgraderepo::OsRelease
- Inherits:
-
Object
- Object
- Zypper::Upgraderepo::OsRelease
- Defined in:
- lib/zypper/upgraderepo/os_release.rb
Overview
Detect the current and next release.
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", "15.5", "15.6"].freeze
- UNSTABLE_VERSION =
"16.0"
- 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.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 23 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('"')) return unless .version raise InvalidVersion, .version unless OS_VERSIONS.include?(.version) @custom = .version end |
Instance Attribute Details
#custom ⇒ Object (readonly)
Returns the value of attribute custom.
11 12 13 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 11 def custom @custom end |
#unstable ⇒ Object (readonly)
Returns the value of attribute unstable.
11 12 13 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 11 def unstable @unstable end |
Instance Method Details
#current ⇒ Object
47 48 49 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 47 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.zero? 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
51 52 53 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 51 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.positive? OS_VERSIONS[@current_idx.next..-1] else [] end end |
#next ⇒ Object
55 56 57 58 59 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 55 def next return if last? OS_VERSIONS[@current_idx.next] end |
#previous ⇒ Object
61 62 63 64 65 |
# File 'lib/zypper/upgraderepo/os_release.rb', line 61 def previous return if first? OS_VERSIONS[@current_idx.pred] 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 |