Class: HoptoadHandler
- Inherits:
-
Chef::Handler
- Object
- Chef::Handler
- HoptoadHandler
- Defined in:
- lib/hoptoad_handler.rb
Constant Summary collapse
- VERSION =
"0.1.4"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #client ⇒ Object
- #hoptoad_params ⇒ Object
-
#initialize(options = {}) ⇒ HoptoadHandler
constructor
A new instance of HoptoadHandler.
- #report ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ HoptoadHandler
Returns a new instance of HoptoadHandler.
27 28 29 30 |
# File 'lib/hoptoad_handler.rb', line 27 def initialize(={}) @api_key = .delete(:api_key) @options = end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
25 26 27 |
# File 'lib/hoptoad_handler.rb', line 25 def api_key @api_key end |
#options ⇒ Object
Returns the value of attribute options.
25 26 27 |
# File 'lib/hoptoad_handler.rb', line 25 def @options end |
Instance Method Details
#client ⇒ Object
53 54 55 56 |
# File 'lib/hoptoad_handler.rb', line 53 def client raise ArgumentError.new("You must specify Hoptoad api key") unless api_key Toadhopper.new(api_key) end |
#hoptoad_params ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/hoptoad_handler.rb', line 40 def hoptoad_params { :notifier_name => "Chef Hoptoad Notifier", :notifier_version => VERSION, :notifier_url => "https://github.com/morgoth/hoptoad_handler", :component => run_status.node.name, :url => nil, :environment => {}, :params => { :start_time => run_status.start_time, :end_time => run_status.end_time, :elapsed_time => run_status.elapsed_time, :run_list => run_status.node.run_list.to_s } }.merge() end |
#report ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/hoptoad_handler.rb', line 32 def report if run_status.failed? Chef::Log.error("Creating Hoptoad exception report") client.post!(run_status.exception, hoptoad_params) end end |