class WollokQueryHook

Public Instance Methods

compile_program(r) click to toggle source
# File lib/query_hook.rb, line 34
  def compile_program(r)
<<WLK
#{r.extra}
#{r.content}
object mumukiPrettyPrinter {
  method prettyPrint(anObject) {
    if (anObject != null && anObject != void)
      console.println('=> '  + anObject.toString())
    else
      console.println('=>')
  }
}

object mumukiConsole {
  method println(anObject) {
     console.println(anObject)
  }
}

program mumuki {
  #{build_cookie_code(r)}
  #{
    if %w(var const).any? { |it| r.query.strip.start_with? it }
      "#{r.query}\nmumukiPrettyPrinter.prettyPrint(void)"
    else
      "mumukiPrettyPrinter.prettyPrint(#{r.query})"
    end
  }
}
WLK
  end
program_type() click to toggle source
# File lib/query_hook.rb, line 30
def program_type
  'wpgm'
end
transform_response(response) click to toggle source
# File lib/query_hook.rb, line 18
def transform_response(response)
  if errored? response
    [extract_compilation_errors(response), :errored]
  elsif response['consoleOutput'].present?
    [trim_cookie_output(response['consoleOutput']), :passed]
  elsif response['runtimeError'].present?
    [response['runtimeError']['message'], :failed]
  else
    [response.to_s, :errored]
  end
end