Class: Ludwig::Composer
- Inherits:
-
Struct
- Object
- Struct
- Ludwig::Composer
- Defined in:
- lib/ludwig/composer.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config
2 3 4 |
# File 'lib/ludwig/composer.rb', line 2 def config @config end |
Instance Method Details
#generate_yaml ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ludwig/composer.rb', line 13 def generate_yaml config["available_projects"].each_with_object({}) do |project, new_compose_data| data = YAML.load_file("../#{project}/docker-compose.yml") data.each do |service_name, service_data| service = Service.new(project, service_name, service_data, config) new_compose_data["#{sanitize(project)}_#{service_name}"] = service.generate_yaml end end.to_yaml end |
#sanitize(input) ⇒ Object
9 10 11 |
# File 'lib/ludwig/composer.rb', line 9 def sanitize(input) input.gsub(/-/, "_") end |
#write_yaml ⇒ Object
3 4 5 6 7 |
# File 'lib/ludwig/composer.rb', line 3 def write_yaml File.open('docker-compose.yml','w') do |h| h.write generate_yaml end end |