~gandelman-a/ubuntu/precise/facter/merge922788

« back to all changes in this revision

Viewing changes to lib/facter.rb

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2011-10-18 10:32:42 UTC
  • mfrom: (1.3.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: package-import@ubuntu.com-20111018103242-ag8i8vejfp8v7b1b
Tags: upstream-1.6.1
ImportĀ upstreamĀ versionĀ 1.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#--
2
 
# Copyright 2006 Luke Kanies <luke@madstop.com>
3
 
#
4
 
# This library is free software; you can redistribute it and/or
5
 
# modify it under the terms of the GNU Lesser General Public
6
 
# License as published by the Free Software Foundation; either
7
 
# version 2.1 of the License, or (at your option) any later version.
8
 
#
9
 
# This library is distributed in the hope that it will be useful,
10
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
# Lesser General Public License for more details.
13
 
#
14
 
# You should have received a copy of the GNU Lesser General Public
15
 
# License along with this library; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17
 
#
18
 
#--
 
1
# Facter - Host Fact Detection and Reporting
 
2
#
 
3
# Copyright 2011 Puppet Labs Inc
 
4
#
 
5
# Licensed under the Apache License, Version 2.0 (the "License");
 
6
# you may not use this file except in compliance with the License.
 
7
# You may obtain a copy of the License at
 
8
#
 
9
# http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
# Unless required by applicable law or agreed to in writing, software
 
12
# distributed under the License is distributed on an "AS IS" BASIS,
 
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
# See the License for the specific language governing permissions and 
 
15
# limitations under the License.
19
16
 
20
17
module Facter
21
18
    # This is just so the other classes have the constant.
27
24
    include Comparable
28
25
    include Enumerable
29
26
 
30
 
    FACTERVERSION = '1.5.9'
 
27
    FACTERVERSION = '1.6.1'
31
28
    # = Facter
32
29
    # Functions as a hash of 'facts' you might care about about your
33
30
    # system, such as mac address, IP address, Video card, etc.
49
46
    RESET = ""
50
47
    @@debug = 0
51
48
    @@timing = 0
 
49
    @@messages = {}
52
50
 
53
51
    # module methods
54
52
 
161
159
        Facter.reset
162
160
    end
163
161
 
 
162
    # Clear all messages. Used only in testing. Can't add to self.clear
 
163
    # because we don't want to warn multiple times for items that are warnonce'd
 
164
    def self.clear_messages
 
165
        @@messages.clear
 
166
    end
 
167
 
164
168
    # Set debugging on or off.
165
169
    def self.debugging(bit)
166
170
        if bit
211
215
        end
212
216
    end
213
217
 
 
218
    # Warn once.
 
219
    def self.warnonce(msg)
 
220
        if msg and not msg.empty? and @@messages[msg].nil?
 
221
            @@messages[msg] = true
 
222
            Kernel.warn(msg)
 
223
        end
 
224
    end
 
225
 
214
226
    # Remove them all.
215
227
    def self.reset
216
228
        @collection = nil