Class: HipchatNotification
- Inherits:
-
Object
- Object
- HipchatNotification
- Defined in:
- app/models/hipchat_notification.rb
Defined Under Namespace
Classes: Message
Instance Method Summary collapse
- #deliver ⇒ Object
-
#initialize(deploy) ⇒ HipchatNotification
constructor
A new instance of HipchatNotification.
- #try_delivery(deploy, room) ⇒ Object
Constructor Details
#initialize(deploy) ⇒ HipchatNotification
Returns a new instance of HipchatNotification.
3 4 5 6 |
# File 'app/models/hipchat_notification.rb', line 3 def initialize(deploy) @deploy = deploy @stage = deploy.stage end |
Instance Method Details
#deliver ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'app/models/hipchat_notification.rb', line 8 def deliver return if @stage.hipchat_rooms.empty? @stage.hipchat_rooms.each do |room| try_delivery(@deploy, room) end end |
#try_delivery(deploy, room) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/hipchat_notification.rb', line 17 def try_delivery(deploy, room) if !room.accept_notify?(deploy) Rails.logger.debug("No need to notify #{room.name}") return end Rails.logger.debug("Begin to notify #{room.name}") = Message.new(deploy, room.) begin hipchat(room.token)[room.name].send .from, .to_s, **.style rescue HipChat::UnknownRoom => e Rails.logger.error("Room did not existed") rescue HipChat:: => e Rails.logger.error("Invalid token to post to room") rescue HipChat::UnknownResponseCode => e Rails.logger.error("Could not deliver hipchat message: #{e.message} to room #{room.name}") end end |