summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-01-19 15:42:59 -0800
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit6651aa4fc84506b9d20076be28741516214c5d5d (patch)
treee2f7292c62c8db88f348fbdd1f5039673d830a7b /lib
parent4bb35a7f229fca1ce838b9e2e74c0ada48908cfa (diff)
downloadpuppet-6651aa4fc84506b9d20076be28741516214c5d5d.tar.gz
puppet-6651aa4fc84506b9d20076be28741516214c5d5d.tar.xz
puppet-6651aa4fc84506b9d20076be28741516214c5d5d.zip
Adding first version of Resource::Status class
This is the class that will be returned in reports, and they'll contain the events being created. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/resource/status.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/puppet/resource/status.rb b/lib/puppet/resource/status.rb
new file mode 100644
index 000000000..0ca295d4d
--- /dev/null
+++ b/lib/puppet/resource/status.rb
@@ -0,0 +1,51 @@
+class Puppet::Resource::Status
+ include Puppet::Util::Tagging
+ include Puppet::Util::Logging
+
+ ATTRIBUTES = [:resource, :node, :version, :file, :line, :current_values, :skipped_reason, :status, :evaluation_time]
+ attr_accessor *ATTRIBUTES
+
+ STATES = [:skipped, :failed, :changed, :out_of_sync, :scheduled]
+ attr_accessor *STATES
+
+ attr_reader :source_description, :default_log_level, :time, :resource
+
+ # Provide a boolean method for each of the states.
+ STATES.each do |attr|
+ define_method("#{attr}?") do
+ !! send(attr)
+ end
+ end
+
+ def <<(event)
+ add_event(event)
+ self
+ end
+
+ def add_event(event)
+ @events << event
+ end
+
+ def events
+ @events
+ end
+
+ def initialize(resource)
+ @source_description = resource.path
+ @resource = resource.to_s
+
+ [:file, :line, :version].each do |attr|
+ send(attr.to_s + "=", resource.send(attr))
+ end
+
+ tag(*resource.tags)
+ @time = Time.now
+ @events = []
+ end
+
+ private
+
+ def log_source
+ source_description
+ end
+end