Class: Heroploy::Config::DeploymentConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/heroploy/config/deployment_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ DeploymentConfig

Returns a new instance of DeploymentConfig.



18
19
20
21
22
23
24
25
26
27
# File 'lib/heroploy/config/deployment_config.rb', line 18

def initialize(attrs = {})
  @travis_repo = attrs['travis_repo']
  unless attrs['environments'].nil?
    @environments = attrs['environments'].map { |name, env_attrs| Environment.new(name, env_attrs) }
  end
  unless attrs['load_configs'].nil?
    @remote_configs = attrs['load_configs'].map { |name, remote_config_attrs| RemoteConfig.new(name, remote_config_attrs) }
  end
  @shared_env = SharedEnv.new(attrs['common'])
end

Instance Attribute Details

#environmentsObject

Returns the value of attribute environments.



10
11
12
# File 'lib/heroploy/config/deployment_config.rb', line 10

def environments
  @environments
end

#remote_configsObject

Returns the value of attribute remote_configs.



12
13
14
# File 'lib/heroploy/config/deployment_config.rb', line 12

def remote_configs
  @remote_configs
end

#shared_envObject

Returns the value of attribute shared_env.



11
12
13
# File 'lib/heroploy/config/deployment_config.rb', line 11

def shared_env
  @shared_env
end

#travis_repoObject

Returns the value of attribute travis_repo.



9
10
11
# File 'lib/heroploy/config/deployment_config.rb', line 9

def travis_repo
  @travis_repo
end

Class Method Details

.load(filename = 'config/heroploy.yml') ⇒ Object



29
30
31
# File 'lib/heroploy/config/deployment_config.rb', line 29

def self.load(filename = 'config/heroploy.yml')
  DeploymentConfig.new(YAML::load(File.open(filename)))
end

Instance Method Details

#[](env_name) ⇒ Object



14
15
16
# File 'lib/heroploy/config/deployment_config.rb', line 14

def [](env_name)
  environments.select{ |env| env.name == env_name }.first
end

#merge_config(deployment_config) ⇒ Object



33
34
35
36
37
# File 'lib/heroploy/config/deployment_config.rb', line 33

def merge_config(deployment_config)
  deployment_config.environments.each do |env_config|
    self[env_config.name].variables.merge!(env_config.variables)
  end
end