Class: Zypper::Upgraderepo::Repository
- Inherits:
-
Object
- Object
- Zypper::Upgraderepo::Repository
- Defined in:
- lib/zypper/upgraderepo/repository.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #alias ⇒ Object
- #alias=(value) ⇒ Object
- #available? ⇒ Boolean
- #enabled? ⇒ Boolean
- #evaluate_alternative(version) ⇒ Object
-
#initialize(filename) ⇒ Repository
constructor
A new instance of Repository.
- #name ⇒ Object
- #name=(value) ⇒ Object
- #not_found? ⇒ Boolean
- #priority ⇒ Object
- #redirected? ⇒ Boolean
- #redirected_to ⇒ Object
- #save ⇒ Object
- #type ⇒ Object
- #url ⇒ Object
- #url=(value) ⇒ Object
Constructor Details
#initialize(filename) ⇒ Repository
Returns a new instance of Repository.
61 62 63 64 65 66 |
# File 'lib/zypper/upgraderepo/repository.rb', line 61 def initialize(filename) @filename = filename @repo = IniParse.parse(File.read(filename)) @key = get_key @res = nil end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
59 60 61 |
# File 'lib/zypper/upgraderepo/repository.rb', line 59 def filename @filename end |
Instance Method Details
#alias ⇒ Object
96 97 98 |
# File 'lib/zypper/upgraderepo/repository.rb', line 96 def alias @key end |
#alias=(value) ⇒ Object
100 101 102 103 |
# File 'lib/zypper/upgraderepo/repository.rb', line 100 def alias=(value) @repo = IniParse.parse(@repo.to_ini.sub(/\[[^\]]+\]/, "[#{value}]")) @key = get_key end |
#available? ⇒ Boolean
105 106 107 |
# File 'lib/zypper/upgraderepo/repository.rb', line 105 def available? ping.is_a?(Net::HTTPSuccess) end |
#enabled? ⇒ Boolean
68 69 70 |
# File 'lib/zypper/upgraderepo/repository.rb', line 68 def enabled? @repo[@key]['enabled'].to_i == 1 end |
#evaluate_alternative(version) ⇒ Object
126 127 128 129 130 131 132 133 134 |
# File 'lib/zypper/upgraderepo/repository.rb', line 126 def evaluate_alternative(version) if url =~ /dl\.google\.com/ return { url: '', message: 'Just Google security, use this repo anyway ;)'} elsif not_found? return traverse_url(URI(url.clone), version) elsif redirected? return { url: redirected_to, message: 'Redirected to:' } end end |
#name ⇒ Object
76 77 78 |
# File 'lib/zypper/upgraderepo/repository.rb', line 76 def name @repo[@key]['name'] || @key end |
#name=(value) ⇒ Object
80 81 82 |
# File 'lib/zypper/upgraderepo/repository.rb', line 80 def name=(value) @repo[@key]['name'] = value end |
#not_found? ⇒ Boolean
117 118 119 |
# File 'lib/zypper/upgraderepo/repository.rb', line 117 def not_found? ping.is_a?(Net::HTTPNotFound) end |
#priority ⇒ Object
84 85 86 |
# File 'lib/zypper/upgraderepo/repository.rb', line 84 def priority @repo[@key]['priority'] || 99 end |
#redirected? ⇒ Boolean
109 110 111 |
# File 'lib/zypper/upgraderepo/repository.rb', line 109 def redirected? ping.is_a?(Net::HTTPRedirection) end |
#redirected_to ⇒ Object
113 114 115 |
# File 'lib/zypper/upgraderepo/repository.rb', line 113 def redirected_to ping['location'] end |
#save ⇒ Object
121 122 123 124 |
# File 'lib/zypper/upgraderepo/repository.rb', line 121 def save raise InvalidPermissions, @filename unless File.writable? @filename @repo.save(@filename) end |
#type ⇒ Object
72 73 74 |
# File 'lib/zypper/upgraderepo/repository.rb', line 72 def type @repo[@key]['type'] end |
#url ⇒ Object
88 89 90 |
# File 'lib/zypper/upgraderepo/repository.rb', line 88 def url @repo[@key]['baseurl'] end |
#url=(value) ⇒ Object
92 93 94 |
# File 'lib/zypper/upgraderepo/repository.rb', line 92 def url=(value) @repo[@key]['baseurl'] = value end |