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



310
311
312
# File 'lib/puppet/util/inifile.rb', line 310

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

#each_file(&block) ⇒ Object



289
290
291
292
293
# File 'lib/puppet/util/inifile.rb', line 289

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

#each_section(&block) ⇒ Object



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

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



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

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)


306
307
308
# File 'lib/puppet/util/inifile.rb', line 306

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
# File 'lib/puppet/util/inifile.rb', line 277

def store
  @files.values.each(&:store)
end