Class: Inspec::Resources::YumRepo
- Inherits:
-
Object
- Object
- Inspec::Resources::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.
- #to_s ⇒ Object
Constructor Details
#initialize(yum, reponame) ⇒ YumRepo
Returns a new instance of YumRepo.
107 108 109 110 |
# File 'lib/resources/yum.rb', line 107 def initialize(yum, reponame) @yum = yum @reponame = reponame end |
Instance Method Details
#enabled? ⇒ Boolean
130 131 132 133 |
# File 'lib/resources/yum.rb', line 130 def enabled? return false unless exist? info['status'] == 'enabled' end |
#exist? ⇒ Boolean
126 127 128 |
# File 'lib/resources/yum.rb', line 126 def exist? !info.empty? end |
#info ⇒ Object
119 120 121 122 123 124 |
# File 'lib/resources/yum.rb', line 119 def info return @cache if defined?(@cache) selection = @yum.repositories.select { |e| e['id'] == @reponame || shortname(e['id']) == @reponame } @cache = selection.empty? ? {} : selection.first @cache end |
#shortname(id) ⇒ Object
extracts the shortname from a repo id e.g. extras/7/x86_64 -> extras
114 115 116 117 |
# File 'lib/resources/yum.rb', line 114 def shortname(id) val = %r{^\s*([^/]*?)/(.*?)\s*$}.match(id) val.nil? ? nil : val[1] end |
#to_s ⇒ Object
151 152 153 |
# File 'lib/resources/yum.rb', line 151 def to_s "YumRepo #{@reponame}" end |