Class: HipchatNotification::Message
- Inherits:
-
Object
- Object
- HipchatNotification::Message
- Defined in:
- app/models/hipchat_notification.rb
Instance Method Summary collapse
- #content ⇒ Object
- #from ⇒ Object
-
#initialize(deploy, is_multi_message) ⇒ Message
constructor
A new instance of Message.
- #style ⇒ Object
- #subject ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(deploy, is_multi_message) ⇒ Message
40 41 42 43 44 45 46 47 |
# File 'app/models/hipchat_notification.rb', line 40 def initialize(deploy, ) @deploy = deploy @stage = deploy.stage @project = @stage.project @user = @deploy.user @changeset = @deploy.changeset = end |
Instance Method Details
#content ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'app/models/hipchat_notification.rb', line 77 def content if return subject if @deploy.job.succeeded? || @deploy.job.failed? || @deploy.job.errored? @content ||= HipchatNotificationRenderer.render(@deploy, subject, {is_multi_message: true}) else @content ||= HipchatNotificationRenderer.render(@deploy, subject) end end |
#from ⇒ Object
53 54 55 |
# File 'app/models/hipchat_notification.rb', line 53 def from "Deploy" end |
#style ⇒ Object
49 50 51 |
# File 'app/models/hipchat_notification.rb', line 49 def style {:color => color, :notify => } end |
#subject ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/models/hipchat_notification.rb', line 57 def subject if subject = "#{@user.name} is <a href='#{deploy_url}'>deploying</a> <strong>#{@project.name}</strong> to <strong>#{@stage.name}</strong><br>" subject = "#{@user.name} successfully deployed <strong>#{@project.name}</strong> @<a href='#{diff_url}'>#{@deploy.commit}</a> to <strong>#{@stage.name}</strong><br>" if @deploy.job.succeeded? subject = "#{@user.name} failed to <a href='#{deploy_url}'>deployed</a> <strong>#{@project.name}</strong> to <strong>#{@stage.name}</strong><br>" if @deploy.job.failed? || @deploy.job.errored? subject = "#{@user.name} cancelled <a href='#{deploy_url}'>deploy</a> <strong>#{@project.name}</strong> to <strong>#{@stage.name}</strong><br>" if @deploy.job.cancelled? subject else subject = "#{@user.name} successfully deployed <strong>#{@project.name}</strong> @ <a href='#{diff_url}'>#{@deploy.commit}</a> to <strong>#{@stage.name}</strong><br>" if @deploy.job.succeeded? end end |
#to_s ⇒ Object
73 74 75 |
# File 'app/models/hipchat_notification.rb', line 73 def to_s content end |