Class: Zypper::Upgraderepo::Repository
- Inherits:
-
Object
- Object
- Zypper::Upgraderepo::Repository
- Defined in:
- lib/zypper/upgraderepo/repository.rb
Overview
Single repository class.
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#old_alias ⇒ Object
readonly
Returns the value of attribute old_alias.
-
#old_name ⇒ Object
readonly
Returns the value of attribute old_name.
-
#old_url ⇒ Object
readonly
Returns the value of attribute old_url.
Instance Method Summary collapse
- #alias ⇒ Object
- #alias=(value) ⇒ Object
- #enable!(value = nil) ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(filename, variables) ⇒ Repository
constructor
A new instance of Repository.
- #name ⇒ Object
- #name=(value) ⇒ Object
- #priority ⇒ Object
- #protocol ⇒ Object
- #save ⇒ Object
- #type ⇒ Object
- #unversioned? ⇒ Boolean
- #upgrade!(version, args = {}) ⇒ Object
- #upgraded?(item = :url) ⇒ Boolean
- #url ⇒ Object
- #url=(value) ⇒ Object
- #versioned? ⇒ Boolean
Constructor Details
#initialize(filename, variables) ⇒ Repository
Returns a new instance of Repository.
172 173 174 175 176 177 178 179 180 |
# File 'lib/zypper/upgraderepo/repository.rb', line 172 def initialize(filename, variables) @filename = filename @repo = IniParse.parse(File.read(filename)) @key = read_key @old_url = nil @old_name = nil @old_alias = nil resolve_variables!(variables) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
170 171 172 |
# File 'lib/zypper/upgraderepo/repository.rb', line 170 def filename @filename end |
#old_alias ⇒ Object (readonly)
Returns the value of attribute old_alias.
170 171 172 |
# File 'lib/zypper/upgraderepo/repository.rb', line 170 def old_alias @old_alias end |
#old_name ⇒ Object (readonly)
Returns the value of attribute old_name.
170 171 172 |
# File 'lib/zypper/upgraderepo/repository.rb', line 170 def old_name @old_name end |
#old_url ⇒ Object (readonly)
Returns the value of attribute old_url.
170 171 172 |
# File 'lib/zypper/upgraderepo/repository.rb', line 170 def old_url @old_url end |
Instance Method Details
#alias ⇒ Object
226 227 228 |
# File 'lib/zypper/upgraderepo/repository.rb', line 226 def alias @key end |
#alias=(value) ⇒ Object
230 231 232 233 |
# File 'lib/zypper/upgraderepo/repository.rb', line 230 def alias=(value) @repo = IniParse.parse(@repo.to_ini.sub(/\[[^\]]+\]/, "[#{value}]")) @key = read_key end |
#enable!(value = nil) ⇒ Object
186 187 188 |
# File 'lib/zypper/upgraderepo/repository.rb', line 186 def enable!(value = nil) @repo[@key]["enabled"] = (value || true).to_s =~ /true|1|yes/i ? 1 : 0 end |
#enabled? ⇒ Boolean
182 183 184 |
# File 'lib/zypper/upgraderepo/repository.rb', line 182 def enabled? @repo[@key]["enabled"].to_i == 1 end |
#name ⇒ Object
194 195 196 |
# File 'lib/zypper/upgraderepo/repository.rb', line 194 def name @repo[@key]["name"] || @key end |
#name=(value) ⇒ Object
198 199 200 |
# File 'lib/zypper/upgraderepo/repository.rb', line 198 def name=(value) @repo[@key]["name"] = value end |
#priority ⇒ Object
202 203 204 |
# File 'lib/zypper/upgraderepo/repository.rb', line 202 def priority @repo[@key]["priority"] || 99 end |
#protocol ⇒ Object
214 215 216 |
# File 'lib/zypper/upgraderepo/repository.rb', line 214 def protocol URI(url.to_s).scheme end |
#save ⇒ Object
250 251 252 253 254 255 256 257 |
# File 'lib/zypper/upgraderepo/repository.rb', line 250 def save raise InvalidWritePermissions, @filename unless File.writable? @filename process, pid = libzypp_process raise SystemUpdateRunning, { pid: pid, process: process } if pid @repo.save(@filename) end |
#type ⇒ Object
190 191 192 |
# File 'lib/zypper/upgraderepo/repository.rb', line 190 def type @repo[@key]["type"] end |
#unversioned? ⇒ Boolean
218 219 220 |
# File 'lib/zypper/upgraderepo/repository.rb', line 218 def unversioned? (url =~ /\d\d\.\d/).nil? end |
#upgrade!(version, args = {}) ⇒ Object
235 236 237 238 239 240 241 242 243 244 |
# File 'lib/zypper/upgraderepo/repository.rb', line 235 def upgrade!(version, args = {}) @old_url ||= url @old_alias ||= self.alias @old_name ||= name self.url = (args[:url_override] || url.gsub(/\d\d\.\d/, version)) self.alias = self.alias.gsub(/\d\d\.\d/, version) if args[:alias] self.name = name.gsub(/\d\d\.\d/, version) if args[:name] end |
#upgraded?(item = :url) ⇒ Boolean
246 247 248 |
# File 'lib/zypper/upgraderepo/repository.rb', line 246 def upgraded?(item = :url) !send("old_#{item}").nil? && (send("old_#{item}") != send(item)) end |
#url ⇒ Object
206 207 208 |
# File 'lib/zypper/upgraderepo/repository.rb', line 206 def url @repo[@key]["baseurl"] end |
#url=(value) ⇒ Object
210 211 212 |
# File 'lib/zypper/upgraderepo/repository.rb', line 210 def url=(value) @repo[@key]["baseurl"] = value end |
#versioned? ⇒ Boolean
222 223 224 |
# File 'lib/zypper/upgraderepo/repository.rb', line 222 def versioned? !unversioned? end |