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) ⇒ Message
constructor
A new instance of Message.
- #style ⇒ Object
- #subject ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(deploy) ⇒ Message
Returns a new instance of Message.
25 26 27 28 29 30 31 |
# File 'app/models/hipchat_notification.rb', line 25 def initialize(deploy) @deploy = deploy @stage = deploy.stage @project = @stage.project @user = @deploy.user @changeset = @deploy.changeset end |
Instance Method Details
#content ⇒ Object
55 56 57 58 |
# File 'app/models/hipchat_notification.rb', line 55 def content return subject if @deploy.job.succeeded? || @deploy.job.failed? || @deploy.job.errored? @content ||= HipchatNotificationRenderer.render(@deploy, subject) end |
#from ⇒ Object
37 38 39 |
# File 'app/models/hipchat_notification.rb', line 37 def from "Deploy" end |
#style ⇒ Object
33 34 35 |
# File 'app/models/hipchat_notification.rb', line 33 def style {:color => color} end |
#subject ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/models/hipchat_notification.rb', line 41 def subject subject = "#{@user.name} is about to <a href='#{deploy_url}'>deploy</a> <strong>#{@project.name}</strong> on <strong>#{@stage.name}</strong><br>" subject = "#{@user.name} successfully deploy <strong>#{@project.name}</strong> @<a href='#{diff_url}'>#{@deploy.commit}...#{@changeset.try(:previous_commit)}</a> on <strong>#{@stage.name}</strong><br>" if @deploy.job.succeeded? subject = "#{@user.name} failed to <a href='#{deploy_url}'>deploy</a> <strong>#{@project.name}</strong> on <strong>#{@stage.name}</strong><br>" if @deploy.job.failed? || @deploy.job.errored? subject end |
#to_s ⇒ Object
51 52 53 |
# File 'app/models/hipchat_notification.rb', line 51 def to_s content end |