Class: YumRepo
- Inherits:
-
Object
- Object
- YumRepo
- Defined in:
- lib/resources/yum.rb
Instance Method Summary collapse
- #enabled? ⇒ Boolean
- #exist? ⇒ Boolean
- #info ⇒ Object
-
#initialize(yum, reponame) ⇒ YumRepo
constructor
A new instance of YumRepo.
-
#shortname(id) ⇒ Object
extracts the shortname from a repo id e.g.
Constructor Details
#initialize(yum, reponame) ⇒ YumRepo
Returns a new instance of YumRepo.
101 102 103 104 |
# File 'lib/resources/yum.rb', line 101 def initialize(yum, reponame) @yum = yum @reponame = reponame end |
Instance Method Details
#enabled? ⇒ Boolean
124 125 126 127 128 |
# File 'lib/resources/yum.rb', line 124 def enabled? repo = info return false if repo.nil? info['status'] == 'enabled' end |
#exist? ⇒ Boolean
120 121 122 |
# File 'lib/resources/yum.rb', line 120 def exist? !info.nil? end |
#info ⇒ Object
113 114 115 116 117 118 |
# File 'lib/resources/yum.rb', line 113 def info return @cache if defined?(@cache) selection = @yum.repositories.select { |e| e['id'] == @reponame || shortname(e['id']) == @reponame } @cache = selection[0] if !selection.nil? && selection.length == 1 @cache end |
#shortname(id) ⇒ Object
extracts the shortname from a repo id e.g. extras/7/x86_64 -> extras
108 109 110 111 |
# File 'lib/resources/yum.rb', line 108 def shortname(id) val = %r{^\s*([^/]*?)/(.*?)\s*$}.match(id) val.nil? ? nil : val[1] end |