Class: Puppet::Util::IniConfig::FileCollection
- Defined in:
- lib/puppet/util/inifile.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #add_section(name, file) ⇒ Object
- #each_file(&block) ⇒ Object
- #each_section(&block) ⇒ Object
- #get_section(name) ⇒ Object (also: #[])
- #include?(name) ⇒ Boolean
-
#initialize ⇒ FileCollection
constructor
A new instance of FileCollection.
-
#read(file) ⇒ Object
Read and parse a file and store it in the collection.
- #store ⇒ Object
Constructor Details
#initialize ⇒ FileCollection
Returns a new instance of FileCollection.
266 267 268 |
# File 'lib/puppet/util/inifile.rb', line 266 def initialize @files = {} end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
264 265 266 |
# File 'lib/puppet/util/inifile.rb', line 264 def files @files end |
Instance Method Details
#add_section(name, file) ⇒ Object
311 312 313 |
# File 'lib/puppet/util/inifile.rb', line 311 def add_section(name, file) get_physical_file(file).add_section(name) end |
#each_file(&block) ⇒ Object
290 291 292 293 294 |
# File 'lib/puppet/util/inifile.rb', line 290 def each_file(&block) @files.keys.each do |path| yield path end end |
#each_section(&block) ⇒ Object
282 283 284 285 286 287 288 |
# File 'lib/puppet/util/inifile.rb', line 282 def each_section(&block) @files.values.each do |file| file.sections.each do |section| yield section end end end |
#get_section(name) ⇒ Object Also known as: []
296 297 298 299 300 301 302 303 304 |
# File 'lib/puppet/util/inifile.rb', line 296 def get_section(name) sect = nil @files.values.each do |file| if (current = file.get_section(name)) sect = current end end sect end |
#include?(name) ⇒ Boolean
307 308 309 |
# File 'lib/puppet/util/inifile.rb', line 307 def include?(name) !! get_section(name) end |
#read(file) ⇒ Object
Read and parse a file and store it in the collection. If the file has already been read it will be destroyed and re-read.
272 273 274 |
# File 'lib/puppet/util/inifile.rb', line 272 def read(file) new_physical_file(file).read end |
#store ⇒ Object
276 277 278 279 280 |
# File 'lib/puppet/util/inifile.rb', line 276 def store @files.values.each do |file| file.store end end |