diff options
Diffstat (limited to 'lib/facter.rb')
-rw-r--r-- | lib/facter.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/facter.rb b/lib/facter.rb index 42d5371..f48138a 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -48,6 +48,7 @@ module Facter GREEN = "[0;32m" RESET = "[0m" @@debug = 0 + @@timing = 0 # module methods @@ -77,6 +78,15 @@ module Facter @@debug != 0 end + # show the timing information + def self.show_time(string) + puts "#{GREEN}#{string}#{RESET}" if string and Facter.timing? + end + + def self.timing? + @@timing != 0 + end + # Return a fact object by name. If you use this, you still have to call # 'value' on it to retrieve the actual value. def self.[](name) @@ -177,6 +187,22 @@ module Facter end end + # Set timing on or off. + def self.timing(bit) + if bit + case bit + when TrueClass; @@timing = 1 + when Fixnum + if bit > 0 + @@timing = 1 + else + @@timing = 0 + end + end + else + @@timing = 0 + end + end def self.warn(msg) if Facter.debugging? and msg and not msg.empty? |