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 13 |
# File 'lib/egg/docker_compose.rb', line 10 def initialize(_compose_config = {}) @services = [] print "Use of docker_compose is deprecated. Please craft the docker-compose.yml file yourself. This module will be dropped in a future egg." 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
15 16 17 |
# File 'lib/egg/docker_compose.rb', line 15 def configure yield docker_compose end |
#service(name) ⇒ Object
28 29 30 31 32 |
# File 'lib/egg/docker_compose.rb', line 28 def service(name) service = Service.new(name) services << service service end |
#to_yaml ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/egg/docker_compose.rb', line 19 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 |