Class: OpsDeploy::CLI::Notifier
- Inherits:
-
Object
- Object
- OpsDeploy::CLI::Notifier
- Defined in:
- lib/ops_deploy/cli/notifier.rb
Overview
Notifier
Defined Under Namespace
Classes: Generic, Messages, Slack
Instance Attribute Summary collapse
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#notification_type ⇒ Object
Returns the value of attribute notification_type.
-
#notify_user ⇒ Object
Returns the value of attribute notify_user.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #failure_notify(stack, message) ⇒ Object
- #info_notify(stack, message) ⇒ Object
-
#initialize(options) ⇒ Notifier
constructor
A new instance of Notifier.
- #notify(stack) ⇒ Object
- #reset ⇒ Object
- #success_notify(stack, message) ⇒ Object
Constructor Details
#initialize(options) ⇒ Notifier
Returns a new instance of Notifier.
8 9 10 11 12 13 14 |
# File 'lib/ops_deploy/cli/notifier.rb', line 8 def initialize() @options = @options.delete(:slack) if @options[:slack].nil? || @options[:slack][:webhook_url].nil? @messages = OpsDeploy::CLI::Notifier::Messages.new @notification_type = :info @notify_user = @options[:slack] ? @options[:slack][:notify_user] : nil end |
Instance Attribute Details
#messages ⇒ Object
Returns the value of attribute messages.
4 5 6 |
# File 'lib/ops_deploy/cli/notifier.rb', line 4 def @messages end |
#notification_type ⇒ Object
Returns the value of attribute notification_type.
5 6 7 |
# File 'lib/ops_deploy/cli/notifier.rb', line 5 def notification_type @notification_type end |
#notify_user ⇒ Object
Returns the value of attribute notify_user.
6 7 8 |
# File 'lib/ops_deploy/cli/notifier.rb', line 6 def notify_user @notify_user end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/ops_deploy/cli/notifier.rb', line 3 def @options end |
Instance Method Details
#failure_notify(stack, message) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/ops_deploy/cli/notifier.rb', line 43 def failure_notify(stack, ) return unless @options[:slack] OpsDeploy::CLI::Notifier::Slack.new(stack, @options[:slack]) .failure_notify() if @options[:slack] end |
#info_notify(stack, message) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ops_deploy/cli/notifier.rb', line 29 def info_notify(stack, ) return unless @options[:slack] OpsDeploy::CLI::Notifier::Slack.new(stack, @options[:slack]) .notify() end |
#notify(stack) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ops_deploy/cli/notifier.rb', line 16 def notify(stack) if @notification_type == :failure = @messages.failure.join("\n") failure_notify(stack, ) elsif @notification_type == :success = @messages.success.join("\n") success_notify(stack, ) else = @messages.info.join("\n") info_notify(stack, ) end end |