Class: OpsDeploy::CLI::Notifier::Slack
- Defined in:
- lib/ops_deploy/cli/notifier.rb
Instance Attribute Summary collapse
-
#slack_notifier ⇒ Object
Returns the value of attribute slack_notifier.
Instance Method Summary collapse
- #failure_notify(message) ⇒ Object
-
#initialize(stack, options) ⇒ Slack
constructor
A new instance of Slack.
- #notify(message) ⇒ Object
- #stack_link(stack) ⇒ Object
- #success_notify(message) ⇒ Object
Constructor Details
#initialize(stack, options) ⇒ Slack
Returns a new instance of Slack.
60 61 62 63 64 65 |
# File 'lib/ops_deploy/cli/notifier.rb', line 60 def initialize(stack, ) @stack = stack @options = @options[:username] = "OpsDeploy" unless @options[:username] @slack_notifier = Slack::Notifier.new @options[:webhook_url], @options end |
Instance Attribute Details
#slack_notifier ⇒ Object
Returns the value of attribute slack_notifier.
58 59 60 |
# File 'lib/ops_deploy/cli/notifier.rb', line 58 def slack_notifier @slack_notifier end |
Instance Method Details
#failure_notify(message) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ops_deploy/cli/notifier.rb', line 92 def failure_notify() = .gsub(/\[[0-9;]+?m/, "") @slack_notifier.ping "", channel: @options[:channel], attachments: [ { fallback: , text: "#{} <!channel>", author_name: @stack.name, author_link: stack_link(@stack), color: "danger" } ] end |
#notify(message) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ops_deploy/cli/notifier.rb', line 67 def notify() = .gsub(/\[[0-9;]+?m/, "") @slack_notifier.ping "", channel: @options[:channel], attachments: [ { fallback: , author_name: @stack.name, author_link: stack_link(@stack), text: } ] end |
#stack_link(stack) ⇒ Object
105 106 107 108 |
# File 'lib/ops_deploy/cli/notifier.rb', line 105 def stack_link(stack) region = OpsDeploy::CLI.argument("aws-region", "AWS_REGION") || "us-east-1" "https://console.aws.amazon.com/opsworks/home?region=#{region}#/stack/#{stack.stack_id}/stack" end |
#success_notify(message) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ops_deploy/cli/notifier.rb', line 79 def success_notify() = .gsub(/\[[0-9;]+?m/, "") @slack_notifier.ping "", channel: @options[:channel], attachments: [ { fallback: , text: , author_name: @stack.name, author_link: stack_link(@stack), color: "good" } ] end |