Module: DockerCompose

Defined in:
lib/docker_compose_ruby.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.project_nameObject

Returns the value of attribute project_name.



8
9
10
# File 'lib/docker_compose_ruby.rb', line 8

def project_name
  @project_name
end

.yamlObject

Returns the value of attribute yaml.



8
9
10
# File 'lib/docker_compose_ruby.rb', line 8

def yaml
  @yaml
end

.yaml_pathObject

Returns the value of attribute yaml_path.



8
9
10
# File 'lib/docker_compose_ruby.rb', line 8

def yaml_path
  @yaml_path
end

Class Method Details

.compose(command, options) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/docker_compose_ruby.rb', line 40

def compose(command, options)
  case command
  when 'up'
    `docker-compose #{options} #{@yaml_path} #{@project_name} #{command} -d`
  when 'delete'
    `docker-compose #{options} #{@yaml_path} #{@project_name} kill`
    `docker-compose #{options} #{@yaml_path} #{@project_name} rm -f`
  when 'stop', 'start'
    `docker-compose #{options} #{@yaml_path} #{@project_name} #{command}`
  end
end

.delete(options = {}) ⇒ Object



25
26
27
28
# File 'lib/docker_compose_ruby.rb', line 25

def delete(options = {})
  options = nil if options.empty?
  compose('delete',options)
end

.set_project_name(name) ⇒ Object



15
16
17
18
# File 'lib/docker_compose_ruby.rb', line 15

def set_project_name(name)
  @project_name = "-p #{name}"
  name
end

.set_yaml_path(path) ⇒ Object



10
11
12
13
# File 'lib/docker_compose_ruby.rb', line 10

def set_yaml_path(path)
  @yaml_path = "-f #{path}"
  @yaml = YAML.load_file(path)
end

.start(options = {}) ⇒ Object



35
36
37
38
# File 'lib/docker_compose_ruby.rb', line 35

def start(options = {})
  options = nil if options.empty?
  compose('start', options)
end

.stop(options = {}) ⇒ Object



30
31
32
33
# File 'lib/docker_compose_ruby.rb', line 30

def stop(options = {})
  options = nil if options.empty?
  compose('stop', options)
end

.up(options = {}) ⇒ Object



20
21
22
23
# File 'lib/docker_compose_ruby.rb', line 20

def up(options = {})
  options = nil if options.empty?
  compose('up',options)
end

.versionObject



52
53
54
# File 'lib/docker_compose_ruby.rb', line 52

def version
  compose('-v')
end