This attribute is only used for properly generating log messages and
was never intended to appear in reports.

Signed-off-by: Paul Berry <[email protected]>
---
 lib/puppet/resource/status.rb     |    6 ++++++
 spec/unit/resource/status_spec.rb |   10 ++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/resource/status.rb b/lib/puppet/resource/status.rb
index b138c65..1108aa6 100644
--- a/lib/puppet/resource/status.rb
+++ b/lib/puppet/resource/status.rb
@@ -12,6 +12,8 @@ module Puppet
       attr_reader :source_description, :default_log_level, :time, :resource
       attr_reader :change_count, :out_of_sync_count
 
+      YAML_ATTRIBUTES = %...@resource @file @line @evaluation_time 
@change_count @out_of_sync_count @tags @time @events @out_of_sync @changed}
+
       # Provide a boolean method for each of the states.
       STATES.each do |attr|
         define_method("#{attr}?") do
@@ -59,6 +61,10 @@ module Puppet
         @events = []
       end
 
+      def to_yaml_properties
+        (YAML_ATTRIBUTES & instance_variables).sort
+      end
+
       private
 
       def log_source
diff --git a/spec/unit/resource/status_spec.rb 
b/spec/unit/resource/status_spec.rb
index 3d9a841..815f799 100755
--- a/spec/unit/resource/status_spec.rb
+++ b/spec/unit/resource/status_spec.rb
@@ -135,4 +135,14 @@ describe Puppet::Resource::Status do
       @status.out_of_sync.should == true
     end
   end
+
+  describe "When converting to YAML" do
+    it "should include only documented attributes" do
+      @status.file = "/foo.rb"
+      @status.line = 27
+      @status.evaluation_time = 2.7
+      @status.tags = %w{one two}
+      @status.to_yaml_properties.should == 
Puppet::Resource::Status::YAML_ATTRIBUTES.sort
+    end
+  end
 end
-- 
1.7.2

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to