Class: SimpleDeploy::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_deploy/notifier.rb,
lib/simple_deploy/notifier/slack.rb,
lib/simple_deploy/notifier/campfire.rb

Defined Under Namespace

Classes: Campfire, Slack

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Notifier

Returns a new instance of Notifier.



6
7
8
9
10
11
# File 'lib/simple_deploy/notifier.rb', line 6

def initialize(args)
  @config = SimpleDeploy.config
  @stack_name = args[:stack_name]
  @environment = args[:environment]
  @notifications = @config.notifications || {}
end

Instance Method Details

#send(message) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/simple_deploy/notifier.rb', line 33

def send(message)
  @notifications.keys.each do |notification|
    case notification
    when 'campfire'
      campfire = Notifier::Campfire.new :stack_name  => @stack_name,
                                        :environment => @environment
      campfire.send message
    when 'slack'
      slack = Notifier::Slack.new
      slack.send message
    end
  end
end

#send_deployment_complete_messageObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/simple_deploy/notifier.rb', line 18

def send_deployment_complete_message
  message = "Deployment to #{@stack_name} in #{@config.region} complete."
  attributes = stack.attributes

  if attributes['app_github_url']
    message += " App: #{attributes['app_github_url']}/commit/#{attributes['app']}"
  end

  if attributes['chef_repo_github_url']
    message += " Chef: #{attributes['chef_repo_github_url']}/commit/#{attributes['chef_repo']}"
  end

  send message
end

#send_deployment_start_messageObject



13
14
15
16
# File 'lib/simple_deploy/notifier.rb', line 13

def send_deployment_start_message
  message = "Deployment to #{@stack_name} in #{@config.region} started."
  send message
end