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

Returns a new instance of FileCollection.



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

def initialize
  @files = {}
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



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

def files
  @files
end

Instance Method Details

#add_section(name, file) ⇒ Object



312
313
314
# File 'lib/puppet/util/inifile.rb', line 312

def add_section(name, file)
  get_physical_file(file).add_section(name)
end

#each_file(&block) ⇒ Object



291
292
293
294
295
# File 'lib/puppet/util/inifile.rb', line 291

def each_file(&block)
  @files.keys.each do |path|
    yield path
  end
end

#each_section(&block) ⇒ Object



283
284
285
286
287
288
289
# File 'lib/puppet/util/inifile.rb', line 283

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: []



297
298
299
300
301
302
303
304
305
# File 'lib/puppet/util/inifile.rb', line 297

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

Returns:

  • (Boolean)


308
309
310
# File 'lib/puppet/util/inifile.rb', line 308

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.



273
274
275
# File 'lib/puppet/util/inifile.rb', line 273

def read(file)
  new_physical_file(file).read
end

#storeObject



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

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