Class: Phase::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/phase/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/phase/configuration.rb', line 10

def initialize
  @use_bastions = false
  @bastion_role = nil
  @bastion_user = nil

  @aws_region   = "us-east-1"

  ::SSHKit.config.backend = SSH::Backend

  configure_from_yml if defined?(::Rails) && yml_present?
end

Instance Attribute Details

#aws_regionObject

Returns the value of attribute aws_region.



4
5
6
# File 'lib/phase/configuration.rb', line 4

def aws_region
  @aws_region
end

#bastion_roleObject

Returns the value of attribute bastion_role.



4
5
6
# File 'lib/phase/configuration.rb', line 4

def bastion_role
  @bastion_role
end

#bastion_userObject

Returns the value of attribute bastion_user.



4
5
6
# File 'lib/phase/configuration.rb', line 4

def bastion_user
  @bastion_user
end

#use_bastionsObject

Returns the value of attribute use_bastions.



4
5
6
# File 'lib/phase/configuration.rb', line 4

def use_bastions
  @use_bastions
end

Instance Method Details

#configure_from_ymlObject



22
23
24
25
26
27
28
29
30
# File 'lib/phase/configuration.rb', line 22

def configure_from_yml
  yml_config = ::YAML.load_file(yml_path) || {}

  @use_bastions = yml_config[:use_bastions] if yml_config.has_key(:use_bastions)
  @bastion_role = yml_config[:bastion_role] if yml_config.has_key(:bastion_role)
  @bastion_user = yml_config[:bastion_user] if yml_config.has_key(:bastion_user)

  @aws_region = yml_config[:aws_region] if yml_config.has_key(:aws_region)
end

#yml_pathObject



36
37
38
39
# File 'lib/phase/configuration.rb', line 36

def yml_path
  # ::Rails.root.join("config", "phase.yml")
  ""
end

#yml_present?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/phase/configuration.rb', line 32

def yml_present?
  File.exists?(yml_path)
end