Class: KY::DeployGeneration

Inherits:
Object
  • Object
show all
Defined in:
lib/ky/deploy_generation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_output_dir, project_name, configuration = Configuration.new) ⇒ DeployGeneration



3
4
5
6
7
8
9
10
11
12
# File 'lib/ky/deploy_generation.rb', line 3

def initialize(full_output_dir, project_name, configuration=Configuration.new)
  @configuration = configuration
  @proc_commands = File.read(configuration[:procfile_path]).split("\n")
                        .map {|line| line.split(':', 2) }
                        .map {|k, v| [k, ["/bin/bash","-c", v]] }
                        .to_h
  @full_output_dir = full_output_dir
  @project_name = project_name || configuration[:project_name]
  @deployment_yaml = read_deployment_yaml
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



26
27
28
# File 'lib/ky/deploy_generation.rb', line 26

def configuration
  @configuration
end

#deployment_yamlObject (readonly)

Returns the value of attribute deployment_yaml.



26
27
28
# File 'lib/ky/deploy_generation.rb', line 26

def deployment_yaml
  @deployment_yaml
end

#full_output_dirObject (readonly)

Returns the value of attribute full_output_dir.



26
27
28
# File 'lib/ky/deploy_generation.rb', line 26

def full_output_dir
  @full_output_dir
end

#proc_commandsObject (readonly)

Returns the value of attribute proc_commands.



26
27
28
# File 'lib/ky/deploy_generation.rb', line 26

def proc_commands
  @proc_commands
end

#project_nameObject (readonly)

Returns the value of attribute project_name.



26
27
28
# File 'lib/ky/deploy_generation.rb', line 26

def project_name
  @project_name
end

Instance Method Details

#callObject



14
15
16
17
18
# File 'lib/ky/deploy_generation.rb', line 14

def call
  to_h.each do |file_path, deploy_hash|
    File.write(file_path, deploy_hash.to_plain_yaml)
  end
end

#to_hObject



20
21
22
23
24
# File 'lib/ky/deploy_generation.rb', line 20

def to_h
  proc_commands.map do |id, command_array|
    ["#{full_output_dir}/#{id}.deployment.yml", template_hash(id, command_array)]
  end.to_h
end