module RuWEB::Execute

Executes the code

Public Instance Methods

init(code) click to toggle source
# File lib/ruweb/execute.rb, line 10
def init(code)
  index = 1
  code.each do |e|
    cmd = merge(e[:cmd], e[:data])
    system(cmd)
    next unless $CHILD_STATUS.exitstatus.positive?

    file = "ruweb_log#{index}"
    puts "🕷️ ruweb: something went wrong on top: saving #{file}"
    File.write(file, e[:data])
    index += 1
  end
end

Private Instance Methods

merge(cmd, data) click to toggle source
# File lib/ruweb/execute.rb, line 26
def merge(cmd, data)
  cmd =~ /%/ ? cmd.gsub('%', data) : "#{cmd} <<'EOS'\n#{data}\nEOS"
end