Class: Teamistrano::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/teamistrano/settings.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Settings

Returns a new instance of Settings.



7
8
9
10
# File 'lib/teamistrano/settings.rb', line 7

def initialize( env )
  @env = env
  @config = @env.fetch( :teamistrano, {} )
end

Instance Method Details

#applicationObject

Get the name of the application being deployed.



43
44
45
# File 'lib/teamistrano/settings.rb', line 43

def application
  @env.fetch( :application, "N/A" )
end

#branchObject

Get the branch being deployed.



38
39
40
# File 'lib/teamistrano/settings.rb', line 38

def branch
  @env.fetch( :branch, "N/A" )
end

#deployerObject

Get the name of the deployer.



33
34
35
# File 'lib/teamistrano/settings.rb', line 33

def deployer
  return @env.fetch( :local_user, get_local_user)
end

#get_local_userObject

Get the local user name.



28
29
30
# File 'lib/teamistrano/settings.rb', line 28

def get_local_user
  return ENV['USER'] || ENV['USERNAME']
end

#showObject

Show the settings. This is a debugging function only.



54
55
56
57
58
59
60
61
62
63
# File 'lib/teamistrano/settings.rb', line 54

def show
  puts "------------------- settings -------------------"
  puts "Application: #{application}"
  puts "Branch: #{branch}"
  puts "Stage: #{stage}"
  puts "Deployer: #{deployer}"
  puts "Local User: #{get_local_user}"
  puts "URL: #{webhook_url}"
  puts "------------------------------------------------"
end

#stageObject

Get the stage of deployment (TEST, PROD).



48
49
50
# File 'lib/teamistrano/settings.rb', line 48

def stage
  @env.fetch( :stage, "N/A" )
end

#use_curl?Boolean

Should we use curl to post the message to teams?

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
# File 'lib/teamistrano/settings.rb', line 18

def use_curl?
  o = @config[ :curl ]
  if o
    return true
  else
    return false
  end
end

#webhook_urlObject

Get the URL for the webhook call.



13
14
15
# File 'lib/teamistrano/settings.rb', line 13

def webhook_url
  return @config[ :webhook ]
end