Class: OpsDeploy::CLI::Notifier
- Inherits:
-
Object
- Object
- OpsDeploy::CLI::Notifier
- Defined in:
- lib/ops_deploy/cli/notifier.rb
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.
-
#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.
6 7 8 9 10 11 |
# File 'lib/ops_deploy/cli/notifier.rb', line 6 def initialize() = .delete(:slack) if [:slack].nil? or [:slack][:webhook_url].nil? = OpsDeploy::CLI::Notifier::Messages.new @notification_type = :info end |
Instance Attribute Details
#messages ⇒ Object
Returns the value of attribute messages.
3 4 5 |
# File 'lib/ops_deploy/cli/notifier.rb', line 3 def end |
#notification_type ⇒ Object
Returns the value of attribute notification_type.
4 5 6 |
# File 'lib/ops_deploy/cli/notifier.rb', line 4 def notification_type @notification_type end |
#options ⇒ Object
Returns the value of attribute options.
2 3 4 |
# File 'lib/ops_deploy/cli/notifier.rb', line 2 def end |
Instance Method Details
#failure_notify(stack, message) ⇒ Object
34 35 36 |
# File 'lib/ops_deploy/cli/notifier.rb', line 34 def failure_notify(stack, ) OpsDeploy::CLI::Notifier::Slack.new(stack, [:slack]).failure_notify() if [:slack] end |
#info_notify(stack, message) ⇒ Object
26 27 28 |
# File 'lib/ops_deploy/cli/notifier.rb', line 26 def info_notify(stack, ) OpsDeploy::CLI::Notifier::Slack.new(stack, [:slack]).notify() if [:slack] end |
#notify(stack) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ops_deploy/cli/notifier.rb', line 13 def notify(stack) if @notification_type == :failure = .failure.join("\n") failure_notify(stack, ) elsif @notification_type == :success = .success.join("\n") success_notify(stack, ) else = .info.join("\n") info_notify(stack, ) end end |
#reset ⇒ Object
38 39 40 41 |
# File 'lib/ops_deploy/cli/notifier.rb', line 38 def reset = OpsDeploy::CLI::Notifier::Messages.new @notification_type = :info end |
#success_notify(stack, message) ⇒ Object
30 31 32 |
# File 'lib/ops_deploy/cli/notifier.rb', line 30 def success_notify(stack, ) OpsDeploy::CLI::Notifier::Slack.new(stack, [:slack]).success_notify() if [:slack] end |