class Rubble::Executor::Local
Public Instance Methods
file_exists?(file)
click to toggle source
# File lib/rubble/executor/local.rb, line 56 def file_exists?(file) Pathname(file).exists? end
mkdir(directory_name)
click to toggle source
# File lib/rubble/executor/local.rb, line 48 def mkdir(directory_name) Pathname(directory_name).mkpath end
run(*command)
click to toggle source
# File lib/rubble/executor/local.rb, line 60 def run(*command) command_str = Shellwords.join(command) @log.debug(command_str) status = nil output = Output.new(@log) Open3.popen3(command_str) do |stdin, stdout, stderr, thread| streams = {stdout => StreamInfo.new(:info, false), stderr => StreamInfo.new(:error, false)} until streams.empty? do selected, = IO::select(streams.keys, nil, nil, 0.1) if not selected.nil? then selected.each do |stream| info = streams[stream] if stream.eof? then streams.delete(stream) if not info.data.empty? then output << Line.new(info.level, info.data) end else data = info.data + stream.readpartial(1024) data.each_line do |line| if line.end_with?("\n") then output << Line.new(info.level, line) else info.data = line end end end if info.autoflush then output.flush end end end end status = thread.value end if status.exitstatus != 0 then output.flush raise "Command failed with exit status #{status.exitstatus}." end end
symlink(source, target)
click to toggle source
# File lib/rubble/executor/local.rb, line 52 def symlink(source, target) Pathname(target).make_symlink(Pathname(source)) end