~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to lib/puppet/util/inifile.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
# something has changed are written back to disk
6
6
# Great care is taken to preserve comments and blank lines from the original
7
7
# files
8
 
 
8
#
9
9
# The parsing tries to stay close to python's ConfigParser
10
10
 
11
11
require 'puppet/util/filetype'
79
79
            return text
80
80
        end
81
81
 
82
 
        private 
 
82
        private
83
83
        def find_entry(key)
84
84
            @entries.each do |entry|
85
85
                if entry.is_a?(Array) && entry[0] == key
88
88
            end
89
89
            return nil
90
90
        end
91
 
        
 
91
 
92
92
    end
93
93
 
94
94
    # A logical .ini-file that can be spread across several physical
113
113
            text.each_line do |l|
114
114
                line += 1
115
115
                if l.strip.empty? || "#;".include?(l[0,1]) ||
116
 
                        (l.split(nil, 2)[0].downcase == "rem" && 
 
116
                        (l.split(nil, 2)[0].downcase == "rem" &&
117
117
                         l[0,1].downcase == "r")
118
118
                    # Whitespace or comment
119
119
                    if section.nil?
146
146
        end
147
147
 
148
148
        # Store all modifications made to sections in this file back
149
 
        # to the physical files. If no modifications were made to 
 
149
        # to the physical files. If no modifications were made to
150
150
        # a physical file, nothing is written
151
151
        def store
152
152
            @files.each do |file, lines|
180
180
            end
181
181
        end
182
182
 
 
183
        # Execute BLOCK, passing each file constituting this inifile
 
184
        # as an argument
 
185
        def each_file(&block)
 
186
            @files.keys.each do |file|
 
187
                yield(file)
 
188
            end
 
189
        end
 
190
 
183
191
        # Return the Section with the given name or nil
184
192
        def [](name)
185
193
            name = name.to_s