Class: Seijaku::BashExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/seijaku/executors/bash.rb

Overview

executes ‘bash` commands

Instance Method Summary collapse

Constructor Details

#initialize(raw, variables) ⇒ BashExecutor

Returns a new instance of BashExecutor.



8
9
10
11
# File 'lib/seijaku/executors/bash.rb', line 8

def initialize(raw, variables)
  @command = ["bash", "-c", "'#{raw}'"]
  @variables = variables
end

Instance Method Details

#run!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/seijaku/executors/bash.rb', line 13

def run!
  stdout, stderr, exit_status = Open3.capture3(
    @variables,
    @command.join(" ")
  )

  {
    stdout: stdout.chomp,
    stderr: stderr.chomp,
    exit_status: exit_status.exitstatus,
    command: @command.join(" ")
  }
end