Class: DockerCompose::Interactive::Instance
- Inherits:
-
Object
- Object
- DockerCompose::Interactive::Instance
- Defined in:
- lib/capistrano/dockercompose/interactive/instance.rb
Instance Method Summary collapse
- #config ⇒ Object
- #execute(cmd, capture = false) ⇒ Object
- #execute_compose_command(cmd, capture = false) ⇒ Object
-
#initialize(file = '', project = nil) ⇒ Instance
constructor
A new instance of Instance.
- #service(name) ⇒ Object
Constructor Details
#initialize(file = '', project = nil) ⇒ Instance
Returns a new instance of Instance.
7 8 9 10 |
# File 'lib/capistrano/dockercompose/interactive/instance.rb', line 7 def initialize(file='', project=nil) @file = file @project = project end |
Instance Method Details
#config ⇒ Object
12 13 14 15 16 |
# File 'lib/capistrano/dockercompose/interactive/instance.rb', line 12 def config return @config if @config raw_config = execute_compose_command('config', true) @config = YAML.load(raw_config) end |
#execute(cmd, capture = false) ⇒ Object
18 19 20 |
# File 'lib/capistrano/dockercompose/interactive/instance.rb', line 18 def execute(cmd, capture = false) execute_compose_command(cmd, capture) end |
#execute_compose_command(cmd, capture = false) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/capistrano/dockercompose/interactive/instance.rb', line 22 def execute_compose_command(cmd, capture = false) project = @project.empty? ? "" : "-p #{@project}" file = @file.empty? ? "" : "--file #{@file}" cmd = "#{file} #{project} #{cmd}" if capture return DockerCompose::Interactive.capture_local_or_remote cmd else DockerCompose::Interactive.execute_local_or_remote_interactive cmd end end |