class WebTools::Workspace
Public Class Methods
description()
click to toggle source
# File lib/web_tools/workspace.rb, line 6 def self.description 'Code workspace' end
Public Instance Methods
debug_on_exception() { || ... }
click to toggle source
Run block in a separate thread, which gets suspended if an error occurs.
# File lib/web_tools/workspace.rb, line 44 def debug_on_exception response = nil client = Thread.start do begin response = yield rescue Exception => e entry = Support::ErrorLog.add :thread => Thread.current, :exception => e response = json("errorType" => entry.exception.class.inspect, "description" => entry.exception.message, "oop" => entry.object_id) Thread.stop end end sleep 0.2 until client.stop? response end
run_evaluation(text)
click to toggle source
# File lib/web_tools/workspace.rb, line 61 def run_evaluation(text) value = eval(params["text"]) result = { "klass" => value.class.inspect, "string" => value.inspect } if value.is_a? Module result["dict"] = "" result["name"] = value.inspect result["cat"] = "" end json(result) rescue SyntaxError => e json("errorType" => "compileError", "errorDetails" => [[1031, 1, e.message, nil, nil]]) end