Class: DockerCompose
- Inherits:
-
Object
- Object
- DockerCompose
- Defined in:
- lib/egg/docker_compose.rb,
lib/egg/docker_compose/service.rb
Overview
Wraps the generation of Docker Compose file
Defined Under Namespace
Classes: Service
Instance Attribute Summary collapse
-
#docker_compose ⇒ Object
readonly
Returns the value of attribute docker_compose.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
- #configure {|docker_compose| ... } ⇒ Object
-
#initialize(_compose_config = {}) ⇒ DockerCompose
constructor
A new instance of DockerCompose.
- #service(name) ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(_compose_config = {}) ⇒ DockerCompose
Returns a new instance of DockerCompose.
10 11 12 |
# File 'lib/egg/docker_compose.rb', line 10 def initialize(_compose_config = {}) @services = [] end |
Instance Attribute Details
#docker_compose ⇒ Object (readonly)
Returns the value of attribute docker_compose.
7 8 9 |
# File 'lib/egg/docker_compose.rb', line 7 def docker_compose @docker_compose end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
7 8 9 |
# File 'lib/egg/docker_compose.rb', line 7 def services @services end |
Instance Method Details
#configure {|docker_compose| ... } ⇒ Object
14 15 16 |
# File 'lib/egg/docker_compose.rb', line 14 def configure yield docker_compose end |
#service(name) ⇒ Object
27 28 29 30 31 |
# File 'lib/egg/docker_compose.rb', line 27 def service(name) service = Service.new(name) services << service service end |
#to_yaml ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/egg/docker_compose.rb', line 18 def to_yaml output = { "version" => "2" } output["services"] = services.each_with_object({}) do |service, hash| hash[service.name] = service.to_hash end output.to_yaml end |