Class: Phase::Configuration
- Inherits:
-
Object
- Object
- Phase::Configuration
- Defined in:
- lib/phase/configuration.rb
Instance Attribute Summary collapse
-
#aws_region ⇒ Object
Returns the value of attribute aws_region.
-
#bastion_role ⇒ Object
Returns the value of attribute bastion_role.
-
#bastion_user ⇒ Object
Returns the value of attribute bastion_user.
-
#use_bastions ⇒ Object
Returns the value of attribute use_bastions.
Instance Method Summary collapse
- #configure_from_yml ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #yml_path ⇒ Object
- #yml_present? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
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_region ⇒ Object
Returns the value of attribute aws_region.
4 5 6 |
# File 'lib/phase/configuration.rb', line 4 def aws_region @aws_region end |
#bastion_role ⇒ Object
Returns the value of attribute bastion_role.
4 5 6 |
# File 'lib/phase/configuration.rb', line 4 def bastion_role @bastion_role end |
#bastion_user ⇒ Object
Returns the value of attribute bastion_user.
4 5 6 |
# File 'lib/phase/configuration.rb', line 4 def bastion_user @bastion_user end |
#use_bastions ⇒ Object
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_yml ⇒ Object
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_path ⇒ Object
36 37 38 39 |
# File 'lib/phase/configuration.rb', line 36 def yml_path # ::Rails.root.join("config", "phase.yml") "" end |
#yml_present? ⇒ Boolean
32 33 34 |
# File 'lib/phase/configuration.rb', line 32 def yml_present? File.exists?(yml_path) end |