chef-reporting 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -53,7 +53,7 @@ handler. Copy the following block to the top of your `client.rb`.
53
53
 
54
54
  ```ruby
55
55
  begin
56
- require chef_reporting
56
+ require 'chef_reporting'
57
57
  start_handlers << Chef::Reporting::StartHandler.new()
58
58
  rescue LoadError
59
59
  Chef::Log.warn "Failed to load #{lib}. This should be resolved after a chef run."
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Daniel DeLeo (<dan@opscode.com>)
3
3
  # Author:: Prajakta Purohit (prajakta@opscode.com>)
4
- # Auther:: Tyler Cloke (<tyler@opscode.com>)
4
+ # Author:: Tyler Cloke (<tyler@opscode.com>)
5
5
  #
6
6
  # Copyright:: Copyright (c) 2012-13 Opscode, Inc.
7
7
  # License:: Apache License, Version 2.0
@@ -49,10 +49,10 @@ class Chef
49
49
  def for_json
50
50
  as_hash = {}
51
51
  as_hash["type"] = new_resource.class.dsl_name
52
- as_hash["name"] = new_resource.name
53
- as_hash["id"] = new_resource.identity
54
- as_hash["after"] = new_resource.state
55
- as_hash["before"] = current_resource ? current_resource.state : {}
52
+ as_hash["name"] = new_resource.name.to_s
53
+ as_hash["id"] = new_resource.identity.to_s
54
+ as_hash["after"] = state(new_resource)
55
+ as_hash["before"] = current_resource ? state(current_resource) : {}
56
56
  as_hash["duration"] = (elapsed_time * 1000).to_i.to_s
57
57
  as_hash["delta"] = new_resource.diff if new_resource.respond_to?("diff")
58
58
  as_hash["delta"] = "" if as_hash["delta"].nil?
@@ -63,8 +63,11 @@ class Chef
63
63
  else
64
64
  #as_hash["result"] = "failed"
65
65
  end
66
- as_hash["cookbook_name"] = new_resource.cookbook_name
67
- as_hash["cookbook_version"] = new_resource.cookbook_version ? new_resource.cookbook_version.version : "0.0.0"
66
+ if new_resource.cookbook_name
67
+ as_hash["cookbook_name"] = new_resource.cookbook_name
68
+ as_hash["cookbook_version"] = new_resource.cookbook_version.version
69
+ end
70
+
68
71
  as_hash
69
72
  end
70
73
 
@@ -76,6 +79,12 @@ class Chef
76
79
  !self.exception
77
80
  end
78
81
 
82
+ def state(r)
83
+ r.class.state_attrs.inject({}) do |state_attrs, attr_name|
84
+ state_attrs[attr_name] = r.send(attr_name)
85
+ state_attrs
86
+ end
87
+ end
79
88
  end # End class ResouceReport
80
89
 
81
90
  attr_reader :updated_resources
@@ -17,7 +17,7 @@
17
17
 
18
18
  module Chef
19
19
  module Reporting
20
- VERSION = "0.1.2"
20
+ VERSION = "0.1.3"
21
21
  end
22
22
  end
23
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-reporting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-05 00:00:00.000000000 Z
12
+ date: 2014-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -69,4 +69,3 @@ signing_key:
69
69
  specification_version: 3
70
70
  summary: Backport of Chef Reporting handler for Chef < 11.6.0
71
71
  test_files: []
72
- has_rdoc: