rubyx-debugger/config.ru

37 lines
835 B
Plaintext
Raw Normal View History

2015-07-14 13:08:28 +02:00
require 'bundler'
Bundler.require
2015-08-20 02:14:33 +02:00
require 'tilt/erb'
2015-07-14 13:08:28 +02:00
require "opal"
2015-08-20 00:53:39 +02:00
require 'opal-browser'
Opal.use_gem("rubyx")
2015-10-02 19:25:54 +02:00
Opal.use_gem("ast")
Risc.machine.boot
2015-07-14 13:08:28 +02:00
2015-07-14 15:03:06 +02:00
class DebugServer < Opal::Server
2016-12-22 20:18:10 +01:00
def ball(env)
path = env["REQUEST_PATH"]
return super(env) unless path.include?("json")
route = path[1 .. path.index(".") - 1]
2016-12-22 20:18:10 +01:00
[200, { 'Content-Type' => 'text/json' }, code(route) ]
end
2016-12-22 20:18:10 +01:00
def code at
2015-11-04 15:12:37 +01:00
soml = File.new("codes/#{at}.soml").read
syntax = Parser::Salama.new.parse_with_debug(soml)
parts = Parser::Transform.new.apply(syntax)
[parts.inspect]
end
2015-07-14 15:03:06 +02:00
end
2016-12-22 20:18:10 +01:00
2015-07-14 15:03:06 +02:00
run DebugServer.new { |s|
2015-07-14 13:08:28 +02:00
s.main = 'debugger'
s.append_path 'lib'
2015-08-20 02:14:33 +02:00
s.append_path 'assets'
s.debug = !ENV["DEBUG"].nil?
2016-12-22 20:18:10 +01:00
s.source_map = true
2015-08-20 02:14:33 +02:00
s.index_path = "index.html.erb"
2015-08-20 00:53:39 +02:00
s.sprockets.cache = Sprockets::Cache::MemoryStore.new(5000)
2015-07-14 13:08:28 +02:00
}