Class: HoptoadHandler
- Inherits:
-
Chef::Handler
- Object
- Chef::Handler
- HoptoadHandler
- Defined in:
- lib/hoptoad_handler.rb
Constant Summary collapse
- VERSION =
"0.1.2"
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
TODO: remove to_s when toadhopper will be fixed.
-
#initialize(options = {}) ⇒ HoptoadHandler
constructor
A new instance of HoptoadHandler.
- #report ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ HoptoadHandler
Returns a new instance of HoptoadHandler.
28 29 30 31 |
# File 'lib/hoptoad_handler.rb', line 28 def initialize(={}) @api_key = .delete(:api_key) = end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
26 27 28 |
# File 'lib/hoptoad_handler.rb', line 26 def api_key @api_key end |
#options ⇒ Object
Returns the value of attribute options.
26 27 28 |
# File 'lib/hoptoad_handler.rb', line 26 def end |
Instance Method Details
#client ⇒ Object
55 56 57 58 |
# File 'lib/hoptoad_handler.rb', line 55 def client raise "You must specify Hoptoad api key" unless api_key Toadhopper.new(api_key) end |
#hoptoad_params ⇒ Object
TODO: remove to_s when toadhopper will be fixed
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/hoptoad_handler.rb', line 42 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.to_s, :end_time => run_status.end_time.to_s, :elapsed_time => run_status.elapsed_time.to_s, :run_list => run_status.node.run_list.to_s } }.merge() end |
#report ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/hoptoad_handler.rb', line 33 def report if run_status.failed? Chef::Log.error("Creating Hoptoad exception report") client.post!(run_status.exception, hoptoad_params) end end |