<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -68,11 +68,15 @@ module Facter
         if string.nil?
             return
         end
-        if @@debug != 0
+        if self.debugging?
             puts GREEN + string + RESET
         end
     end
 
+    def self.debugging?
+        @@debug != 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)
@@ -173,6 +177,13 @@ module Facter
         end
     end
 
+
+    def self.warn(msg)
+        if Facter.debugging? and msg and not msg.empty?
+            msg.each { |line| Kernel.warn line }
+        end
+    end
+
     # Remove them all.
     def self.reset
         @collection = nil</diff>
      <filename>lib/facter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -131,6 +131,79 @@ describe Facter do
         Facter.should respond_to(:search_path)
     end
 
+    it &quot;should have a method to query debugging mode&quot; do
+        Facter.should respond_to(:debugging?)
+    end
+
+    it &quot;should have a method to warn&quot; do
+        Facter.should respond_to(:warn)
+    end
+
+    describe &quot;when warning&quot; do
+        it &quot;should warn if debugging is enabled&quot; do
+          Facter.debugging(true)
+          Kernel.stubs(:warn)
+          Kernel.expects(:warn).with('foo')
+          Facter.warn('foo')
+        end
+
+        it &quot;should not warn if debugging is enabled but nil is passed&quot; do
+          Facter.debugging(true)
+          Kernel.stubs(:warn)
+          Kernel.expects(:warn).never
+          Facter.warn(nil)
+        end
+
+        it &quot;should not warn if debugging is enabled but an empyt string is passed&quot; do
+          Facter.debugging(true)
+          Kernel.stubs(:warn)
+          Kernel.expects(:warn).never
+          Facter.warn('')
+        end
+
+        it &quot;should not warn if debugging is disabled&quot; do
+          Facter.debugging(false)
+          Kernel.stubs(:warn)
+          Kernel.expects(:warn).never
+          Facter.warn('foo')
+        end
+
+        it &quot;should warn for any given element for an array if debugging is enabled&quot; do
+          Facter.debugging(true)
+          Kernel.stubs(:warn)
+          Kernel.expects(:warn).with('foo')
+          Kernel.expects(:warn).with('bar')
+          Facter.warn( ['foo','bar'])
+        end
+    end
+
+    describe &quot;when setting debugging mode&quot; do
+        it &quot;should have debugging enabled using 1&quot; do
+            Facter.debugging(1)
+            Facter.should be_debugging
+        end
+        it &quot;should have debugging enabled using true&quot; do
+            Facter.debugging(true)
+            Facter.should be_debugging
+        end
+        it &quot;should have debugging enabled using any string except off&quot; do
+            Facter.debugging('aaaaa')
+            Facter.should be_debugging
+        end
+        it &quot;should have debugging disabled using 0&quot; do
+            Facter.debugging(0)
+            Facter.should_not be_debugging
+        end
+        it &quot;should have debugging disabled using false&quot; do
+            Facter.debugging(false)
+            Facter.should_not be_debugging
+        end
+        it &quot;should have debugging disabled using the string 'off'&quot; do
+            Facter.debugging('off')
+            Facter.should_not be_debugging
+        end
+    end
+
     describe &quot;when registering directories to search&quot; do
         after { Facter.instance_variable_set(&quot;@search_path&quot;, []) }
 </diff>
      <filename>spec/unit/facter.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b2c1ca56ebc7ec78c71a1fbf6026411494214e67</id>
    </parent>
  </parents>
  <author>
    <name>Peter Meier</name>
    <email>peter.meier@immerda.ch</email>
  </author>
  <url>http://github.com/jamtur01/facter/commit/810980659d86a30cc9dde6018a4749f659fe2d00</url>
  <id>810980659d86a30cc9dde6018a4749f659fe2d00</id>
  <committed-date>2009-11-07T03:16:14-08:00</committed-date>
  <authored-date>2009-11-07T03:10:29-08:00</authored-date>
  <message>introduce a warn mechanism for debugging

We can now warn messages that will be passed to Kernel.warn if
debugging is enabled.</message>
  <tree>5acfd02792ec3822a5b7ca3c51194f8cbce9787a</tree>
  <committer>
    <name>James Turnbull</name>
    <email>james@lovedthanlost.net</email>
  </committer>
</commit>
