Class: Keel::Notifier::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/keel/notifier/base.rb

Overview

Base class to be inherited for notifiers that are used to send any notifications when a deployment is complete.

Direct Known Subclasses

NewRelic

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env:, sha:) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
17
18
19
# File 'lib/keel/notifier/base.rb', line 12

def initialize env:, sha:
  @env = env
  @sha = sha

  @cli = GCloud::Cli.new

  set_user
end

Instance Attribute Details

#cliObject

Returns the value of attribute cli.



10
11
12
# File 'lib/keel/notifier/base.rb', line 10

def cli
  @cli
end

#envObject

Returns the value of attribute env.



10
11
12
# File 'lib/keel/notifier/base.rb', line 10

def env
  @env
end

#shaObject

Returns the value of attribute sha.



10
11
12
# File 'lib/keel/notifier/base.rb', line 10

def sha
  @sha
end

#userObject

Returns the value of attribute user.



10
11
12
# File 'lib/keel/notifier/base.rb', line 10

def user
  @user
end

Instance Method Details

#notifyObject

:nodoc:

Raises:



34
35
36
# File 'lib/keel/notifier/base.rb', line 34

def notify # :nodoc:
  raise NotImplemented
end

#set_userObject

Determines the user id to be sent with the nofications based on the ENV variable if set, otherwise on the system user.



25
26
27
28
29
30
31
32
# File 'lib/keel/notifier/base.rb', line 25

def set_user
  unless ENV['DEPLOY_USERNAME'].nil? || ENV['DEPLOY_USERNAME'] == ''
    return @user = ENV['DEPLOY_USERNAME']
  end

  whoami  = @cli.execute 'whoami'
  @user   = whoami.chomp
end