diff options
| author | Paul Berry <paul@puppetlabs.com> | 2010-12-30 11:26:30 -0800 |
|---|---|---|
| committer | Paul Berry <paul@puppetlabs.com> | 2010-12-30 11:58:27 -0800 |
| commit | 1f72c31f9e0223e71e2729da96e0e98ebea5417e (patch) | |
| tree | 704631b3841d536b82cbecc18a1886023dbf94e2 | |
| parent | a6cd736379d37c5ca205d74d8a957a6c79f95548 (diff) | |
| download | puppet-1f72c31f9e0223e71e2729da96e0e98ebea5417e.tar.gz puppet-1f72c31f9e0223e71e2729da96e0e98ebea5417e.tar.xz puppet-1f72c31f9e0223e71e2729da96e0e98ebea5417e.zip | |
(#5715) Added attributes resource_type and title to Puppet::Resource::Status.
These new attributes save report processors from having to parse the
"resource" attribute.
| -rw-r--r-- | lib/puppet/resource/status.rb | 6 | ||||
| -rwxr-xr-x | 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 1108aa611..ee83004bb 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 = %w{@resource @file @line @evaluation_time @change_count @out_of_sync_count @tags @time @events @out_of_sync @changed} + YAML_ATTRIBUTES = %w{@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 815f799a2..4e76fa463 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") |
