class Lexicon::Common::ShellExecutor
Public Class Methods
new()
click to toggle source
# File lib/lexicon/common/shell_executor.rb, line 8 def initialize @command_dir = Dir.mktmpdir end
Public Instance Methods
execute(command)
click to toggle source
@param [String] command @return [String]
# File lib/lexicon/common/shell_executor.rb, line 14 def execute(command) cmd = Tempfile.new('command-', @command_dir) cmd.write <<~BASH #!/usr/bin/env bash set -e #{command} BASH cmd.close `bash #{cmd.path}` ensure cmd.close cmd.unlink end
finalize()
click to toggle source
# File lib/lexicon/common/shell_executor.rb, line 30 def finalize if !@command_dir.nil? FileUtils.rm_rf(@command_dir) end end