Class: HipChatNotifier
- Inherits:
-
Object
- Object
- HipChatNotifier
- Defined in:
- lib/abt/notifiers/hip_chat_notifier.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ HipChatNotifier
constructor
A new instance of HipChatNotifier.
- #send_formatted_message(result) ⇒ Object
- #send_message(message, color = 'yellow') ⇒ Object
Constructor Details
#initialize(config) ⇒ HipChatNotifier
Returns a new instance of HipChatNotifier.
5 6 7 8 9 |
# File 'lib/abt/notifiers/hip_chat_notifier.rb', line 5 def initialize(config) @client = HipChat::API.new(config["token"]) @room_name = config["room_name"] @user_name = config["user_name"] || "AbtWorker" end |
Instance Method Details
#send_formatted_message(result) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/abt/notifiers/hip_chat_notifier.rb', line 11 def (result) color = result.passed? ? 'green' : 'red' = "Result: <b>#{result.status}</b> [#{result.pass_percentage}%] <br> <strong>#{result.run_count}</strong> tests, <strong>#{result.assertion_count}</strong> assertions" if result.error_occurred? || result.failure_occurred? +=", <strong>#{result.failure_count}</strong> failures, <strong>#{result.error_count}</strong>, errors<br/>" result.faults.each { |f| +="<br><pre>#{f.to_s.gsub(/>/,' ').gsub(/</,' ')}</pre><br/>" } end (,color) end |
#send_message(message, color = 'yellow') ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/abt/notifiers/hip_chat_notifier.rb', line 22 def (,color='yellow') puts "sending_message #{}" begin puts @client.(@room_name, @user_name, , false,color).body rescue =>ex ex.inspect end end |