Class: Orchparty::Plugin::DockerComposeV1

Inherits:
Object
  • Object
show all
Defined in:
lib/orchparty/plugins/docker_compose_v1.rb

Class Method Summary collapse

Class Method Details

.define_flags(c) ⇒ Object



9
10
11
# File 'lib/orchparty/plugins/docker_compose_v1.rb', line 9

def self.define_flags(c)
  c.flag [:output,:o], :desc => 'Set the output file'
end

.descObject



5
6
7
# File 'lib/orchparty/plugins/docker_compose_v1.rb', line 5

def self.desc
  "generate docker-compose v1 file"
end

.generate(ast, options) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/orchparty/plugins/docker_compose_v1.rb', line 13

def self.generate(ast, options)
  output = output(ast)
  if options[:output]
    File.write(options[:output], output)
  else
    puts output
  end
end

.output(ast) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/orchparty/plugins/docker_compose_v1.rb', line 22

def self.output(ast)
  ast.services.map do |name, service|
    service = service.to_h
    service.delete(:mix)
    [service.delete(:name), HashUtils.deep_stringify_keys(service.to_h)]
  end.to_h.to_yaml(line_width: -1)
end