class Jive::Shell

Constants

COMMAND_MAP

Public Instance Methods

after_run(tasks) click to toggle source
# File lib/jive/shell.rb, line 22
def after_run(tasks)
  finalizer_fd = 42
  pipe = IO.new(finalizer_fd)
  pipe.puts(tasks.map { |x| x.join(":") }.join("\n"))
rescue Errno::EBADF => e
  puts e
  exit 1
end
execute(command, env: {}) click to toggle source
# File lib/jive/shell.rb, line 18
def execute(command, env: {})
  system(env, expand(command))
end
expand(command) click to toggle source
# File lib/jive/shell.rb, line 31
def expand(command)
  Array(command)
    .flatten
    .map { |x| COMMAND_MAP.fetch(x, x).to_s }
    .join(" ")
end
run_each(tasks) click to toggle source
# File lib/jive/shell.rb, line 12
def run_each(tasks)
  tasks.each do |task|
    break unless execute(task)
  end
end
run_safely() { || ... } click to toggle source
# File lib/jive/shell.rb, line 38
def run_safely
  yield
rescue StandardError => e
  puts e
  after_run([%w[noop noop]])
end