Module: DockerCompose::Interactive

Defined in:
lib/capistrano/dockercompose/interactive.rb,
lib/capistrano/dockercompose/interactive/service.rb,
lib/capistrano/dockercompose/interactive/instance.rb

Defined Under Namespace

Classes: Instance, Service

Class Method Summary collapse

Class Method Details

.capture_local_or_remote(cmd) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/capistrano/dockercompose/interactive.rb', line 16

def self.capture_local_or_remote(cmd)
  puts "runnig: docker-compose #{cmd}"
  result = ''
  if local_stage?
    run_locally do
      result = capture "docker-compose #{cmd}"
    end
  else
    on roles fetch(:docker_compose_interactive_roles) do |_host|
      within current_path do
        result = capture "cd #{current_path} && docker-compose #{cmd}"
      end
    end
  end
  result
end

.execute_local_or_remote_interactive(cmd) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/capistrano/dockercompose/interactive.rb', line 33

def self.execute_local_or_remote_interactive(cmd)
  puts "runnig: docker-compose #{cmd}"
  if local_stage?
    system "docker-compose #{cmd}"
  else
    on roles fetch(:docker_compose_interactive_roles) do |host|
      run_interactively host do
        within current_path do
          execute "cd #{current_path} && docker-compose #{cmd}"
        end
      end
    end
  end
end

.instance(file = '', project = '') ⇒ Object



8
9
10
# File 'lib/capistrano/dockercompose/interactive.rb', line 8

def self.instance(file='', project='')
  Instance.new(file, project)
end

.local_stage?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/capistrano/dockercompose/interactive.rb', line 12

def self.local_stage?
  fetch(:local_stage_name, 'local').to_sym == fetch(:stage).to_sym
end