These new attributes save report processors from having to parse the
"resource" attribute.

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

diff --git a/lib/puppet/resource/status.rb b/lib/puppet/resource/status.rb
index 1108aa6..ee83004 100644
--- a/lib/puppet/resource/status.rb
+++ b/lib/puppet/resource/status.rb
@@ -10,9 +10,9 @@ module Puppet
       attr_accessor *STATES
 
       attr_reader :source_description, :default_log_level, :time, :resource
-      attr_reader :change_count, :out_of_sync_count
+      attr_reader :change_count, :out_of_sync_count, :resource_type, :title
 
-      YAML_ATTRIBUTES = %...@resource @file @line @evaluation_time 
@change_count @out_of_sync_count @tags @time @events @out_of_sync @changed}
+      YAML_ATTRIBUTES = %...@resource @file @line @evaluation_time 
@change_count @out_of_sync_count @tags @time @events @out_of_sync @changed 
@resource_type @title}
 
       # Provide a boolean method for each of the states.
       STATES.each do |attr|
@@ -59,6 +59,8 @@ module Puppet
         tag(*resource.tags)
         @time = Time.now
         @events = []
+        @resource_type = resource.type.to_s.capitalize
+        @title = resource.title
       end
 
       def to_yaml_properties
diff --git a/spec/unit/resource/status_spec.rb 
b/spec/unit/resource/status_spec.rb
index 815f799..4e76fa4 100755
--- a/spec/unit/resource/status_spec.rb
+++ b/spec/unit/resource/status_spec.rb
@@ -10,6 +10,11 @@ describe Puppet::Resource::Status do
     @status = Puppet::Resource::Status.new(@resource)
   end
 
+  it "should compute type and title correctly" do
+    @status.resource_type.should == "File"
+    @status.title.should == "/my/file"
+  end
+
   [:node, :file, :line, :current_values, :status, :evaluation_time].each do 
|attr|
     it "should support #{attr}" do
       @status.send(attr.to_s + "=", "foo")
-- 
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