Class: Nib::Exec

Inherits:
Object
  • Object
show all
Includes:
Command, History
Defined in:
lib/nib/exec.rb

Constant Summary

Constants included from History

History::PATH

Instance Method Summary collapse

Methods included from Command

#alternate_compose_file, #entrypoint, #execute, included, #initialize

Methods included from History

#alternate_compose_file, #irbrc, prepended, #pryrc, #wrap

Instance Method Details

#actionObject



15
16
17
# File 'lib/nib/exec.rb', line 15

def action
  @command.to_s.empty? ? '' : "-c '#{@command}'"
end

#commandObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/nib/exec.rb', line 19

def command
  "
    if hash bash 2>/dev/null ; then
      bash #{action}
    elif hash ash 2>/dev/null ; then
      ash #{action}
    else
      sh #{action}
    fi
  "
end

#scriptObject



5
6
7
8
9
10
11
12
13
# File 'lib/nib/exec.rb', line 5

def script
  @script ||= <<-SCRIPT
    docker-compose \
      exec \
      #{options} \
      #{service} \
      #{command}
  SCRIPT
end