Module Facter
In: lib/facter.rb

Methods

[]   add   clear   collection   debug   debugging   each   loadfacts   method_missing   reset   search   search_path   version  

Included Modules

Comparable Enumerable

Classes and Modules

Module Facter::Manufacturer
Module Facter::Memory
Module Facter::NetMask
Module Facter::Util

Constants

FACTERVERSION = '1.5.4'
GREEN = ""
RESET = ""

Public Class methods

Return a fact object by name. If you use this, you still have to call ‘value’ on it to retrieve the actual value.

[Source]

    # File lib/facter.rb, line 78
78:     def self.[](name)
79:         collection.fact(name)
80:     end

Add a resolution mechanism for a named fact. This does not distinguish between adding a new fact and adding a new way to resolve a fact.

[Source]

     # File lib/facter.rb, line 100
100:     def self.add(name, options = {}, &block)
101:         collection.add(name, options, &block)
102:     end

Clear all facts. Mostly used for testing.

[Source]

     # File lib/facter.rb, line 145
145:     def self.clear
146:         Facter.flush
147:         Facter.reset
148:     end

module methods

[Source]

    # File lib/facter.rb, line 54
54:     def self.collection
55:         unless defined?(@collection) and @collection
56:             @collection = Facter::Util::Collection.new
57:         end
58:         @collection
59:     end

Add some debugging

[Source]

    # File lib/facter.rb, line 67
67:     def self.debug(string)
68:         if string.nil?
69:             return
70:         end
71:         if @@debug != 0
72:             puts GREEN + string + RESET
73:         end
74:     end

Set debugging on or off.

[Source]

     # File lib/facter.rb, line 151
151:         def self.debugging(bit)
152:                 if bit
153:             case bit
154:             when TrueClass; @@debug = 1
155:             when FalseClass; @@debug = 0
156:             when Fixnum
157:                 if bit > 0
158:                     @@debug = 1
159:                 else
160:                     @@debug = 0
161:                 end
162:             when String;
163:                 if bit.downcase == 'off'
164:                     @@debug = 0
165:                 else
166:                     @@debug = 1
167:                 end
168:             else
169:                 @@debug = 0
170:             end
171:                 else
172:                         @@debug = 0
173:                 end
174:         end

[Source]

     # File lib/facter.rb, line 104
104:     def self.each
105:         # Make sure all facts are loaded.
106:         collection.load_all
107: 
108:         collection.each do |*args|
109:             yield(*args)
110:         end
111:     end

Load all of the default facts, and then everything from disk.

[Source]

     # File lib/facter.rb, line 182
182:     def self.loadfacts
183:         collection.load_all
184:     end

Allow users to call fact names directly on the Facter class, either retrieving the value or comparing it to an existing value.

[Source]

     # File lib/facter.rb, line 116
116:         def method_missing(name, *args)
117:             question = false
118:             if name.to_s =~ /\?$/
119:                 question = true
120:                 name = name.to_s.sub(/\?$/,'')
121:             end
122: 
123:             if fact = @collection.fact(name)
124:                 if question
125:                     value = fact.value.downcase
126:                     args.each do |arg|
127:                         if arg.to_s.downcase == value
128:                             return true
129:                         end
130:                     end
131: 
132:                     # If we got this far, there was no match.
133:                     return false
134:                 else
135:                     return fact.value
136:                 end
137:             else
138:                 # Else, fail like a normal missing method.
139:                 raise NoMethodError, "Could not find fact '%s'" % name
140:             end
141:         end

Remove them all.

[Source]

     # File lib/facter.rb, line 177
177:     def self.reset
178:         @collection = nil
179:     end

Register a directory to search through.

[Source]

     # File lib/facter.rb, line 189
189:     def self.search(*dirs)
190:         @search_path += dirs
191:     end

Return our registered search directories.

[Source]

     # File lib/facter.rb, line 194
194:     def self.search_path
195:         @search_path.dup
196:     end

Return the version of the library.

[Source]

    # File lib/facter.rb, line 62
62:     def self.version
63:         return FACTERVERSION
64:     end

[Validate]