Class: Orchparty::Generators::DockerComposeV2
- Inherits:
-
Object
- Object
- Orchparty::Generators::DockerComposeV2
- Defined in:
- lib/orchparty/generators/docker_compose_v2.rb
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
Instance Method Summary collapse
-
#initialize(ast) ⇒ DockerComposeV2
constructor
A new instance of DockerComposeV2.
- #output(application_name) ⇒ Object
- #transform_to_yaml(hash) ⇒ Object
Constructor Details
#initialize(ast) ⇒ DockerComposeV2
Returns a new instance of DockerComposeV2.
6 7 8 |
# File 'lib/orchparty/generators/docker_compose_v2.rb', line 6 def initialize(ast) @ast = ast end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
5 6 7 |
# File 'lib/orchparty/generators/docker_compose_v2.rb', line 5 def ast @ast end |
Instance Method Details
#output(application_name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/orchparty/generators/docker_compose_v2.rb', line 15 def output(application_name) application = ast.applications[application_name] {"version" => "2", "services" => application.services.map do |name,service| service = service.to_h [service.delete(:name), HashUtils.deep_stringify_keys(service.to_h)] end.to_h, "volumes" => transform_to_yaml(application.volumes), "networks" => transform_to_yaml(application.networks), }.to_yaml end |
#transform_to_yaml(hash) ⇒ Object
10 11 12 13 |
# File 'lib/orchparty/generators/docker_compose_v2.rb', line 10 def transform_to_yaml(hash) hash = hash.deep_transform_values{|v| v.is_a?(Hash) ? v.to_h : v } HashUtils.deep_stringify_keys(hash) end |