Class: Puppet::Util::IniConfig::FileCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/inifile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFileCollection


266
267
268
# File 'lib/puppet/util/inifile.rb', line 266

def initialize
  @files = {}
end

Instance Attribute Details

#filesObject (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

#storeObject


276
277
278
279
280
# File 'lib/puppet/util/inifile.rb', line 276

def store
  @files.values.each do |file|
    file.store
  end
end