Class: Instance
- Inherits:
-
Object
- Object
- Instance
- Defined in:
- lib/capistrano/dockercompose/interactive/instance.rb
Instance Method Summary collapse
- #config ⇒ 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.
6 7 8 9 |
# File 'lib/capistrano/dockercompose/interactive/instance.rb', line 6 def initialize(file='', project=nil) @file = file @project = project end |
Instance Method Details
#config ⇒ Object
11 12 13 14 15 |
# File 'lib/capistrano/dockercompose/interactive/instance.rb', line 11 def config return @config if @config raw_config = execute_compose_command('config', true) @config = YAML.load(raw_config) end |
#execute_compose_command(cmd, capture = false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/capistrano/dockercompose/interactive/instance.rb', line 17 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 |
#service(name) ⇒ Object
29 30 31 |
# File 'lib/capistrano/dockercompose/interactive/instance.rb', line 29 def service(name) Service.new(self, name, config()['services'][name]) end |