diff options
author | Paul Berry <paul@puppetlabs.com> | 2010-12-30 11:18:57 -0800 |
---|---|---|
committer | Paul Berry <paul@puppetlabs.com> | 2010-12-30 11:57:22 -0800 |
commit | a6cd736379d37c5ca205d74d8a957a6c79f95548 (patch) | |
tree | 6d44781a7b38943665d77ebb5acfbbd098926331 | |
parent | 98db2da4e9b35f6260bf07c641550b380b603baa (diff) | |
download | puppet-a6cd736379d37c5ca205d74d8a957a6c79f95548.tar.gz puppet-a6cd736379d37c5ca205d74d8a957a6c79f95548.tar.xz puppet-a6cd736379d37c5ca205d74d8a957a6c79f95548.zip |
(#5715) Removed attribute source_description from the YAML representation of
Puppet::Resource::Status.
This attribute is only used for properly generating log messages and
was never intended to appear in reports.
-rw-r--r-- | lib/puppet/resource/status.rb | 6 | ||||
-rwxr-xr-x | 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 b138c6520..1108aa611 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 = %w{@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 3d9a84152..815f799a2 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 |