Class: KY::DeployGeneration

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of 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 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