~nvalcarcel/ubuntu/lucid/puppet/fix-546677

« back to all changes in this revision

Viewing changes to lib/puppet/util/warnings.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:
2
2
module Puppet::Util::Warnings
3
3
    module_function
4
4
 
 
5
    def notice_once(msg)
 
6
        Puppet::Util::Warnings.maybe_log(msg, self.class) { Puppet.notice msg }
 
7
    end
 
8
 
 
9
 
5
10
    def warnonce(msg)
6
 
        $stampwarnings ||= {}
7
 
        $stampwarnings[self.class] ||= []
8
 
        unless $stampwarnings[self.class].include? msg
9
 
            Puppet.warning msg
10
 
            $stampwarnings[self.class] << msg
11
 
        end
12
 
 
13
 
        return nil
 
11
        Puppet::Util::Warnings.maybe_log(msg, self.class) { Puppet.warning msg }
14
12
    end
15
13
 
16
14
    def clear_warnings()
17
 
        $stampwarnings = {}
 
15
        @stampwarnings = {}
 
16
        return nil
 
17
    end
 
18
 
 
19
    protected
 
20
 
 
21
    def self.maybe_log(message, klass)
 
22
        @stampwarnings ||= {}
 
23
        @stampwarnings[klass] ||= []
 
24
        return nil if @stampwarnings[klass].include? message
 
25
        yield
 
26
        @stampwarnings[klass] << message
18
27
        return nil
19
28
    end
20
29
end
21