rubyx-debugger/config.ru

45 lines
1.1 KiB
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 15:03:06 +02:00
require_relative "lib/parse_task"
2015-07-14 13:08:28 +02:00
require "opal"
2015-08-20 00:53:39 +02:00
require 'opal-browser'
2015-07-14 13:08:28 +02:00
Opal.use_gem("salama")
2015-10-02 19:25:54 +02:00
Opal.use_gem("ast")
2015-08-19 22:34:39 +02:00
Opal.use_gem("salama-arm")
Virtual.machine.boot
2015-07-14 13:08:28 +02:00
2015-07-14 15:03:06 +02:00
class DebugServer < Opal::Server
def call(env)
path = env["REQUEST_PATH"]
return super(env) unless path.include?("json")
route = path[1 .. path.index(".") - 1]
if( route == "codes")
[200, { 'Content-Type' => 'text/json' }, codes ]
2015-07-14 15:03:06 +02:00
else
[200, { 'Content-Type' => 'text/json' }, code(route) ]
2015-07-14 15:03:06 +02:00
end
end
def codes
[Dir["codes/*.psol"].collect{|f| f.sub("codes/","").sub(".psol","")}.join("----")]
end
def code at
phisol = File.new("codes/#{at}.psol").read
syntax = Parser::Salama.new.parse_with_debug(phisol)
parts = Parser::Transform.new.apply(syntax)
[parts.inspect]
end
2015-07-14 15:03:06 +02:00
end
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?
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
}