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.
267 268 269 |
# File 'lib/puppet/util/inifile.rb', line 267 def initialize @files = {} end |
Instance Attribute Details
#files ⇒ Object (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
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 |
#store ⇒ Object
277 278 279 |
# File 'lib/puppet/util/inifile.rb', line 277 def store @files.values.each(&:store) end |