2015-07-22 15:17:25 +02:00
|
|
|
# config.ru
|
|
|
|
require 'bundler'
|
|
|
|
Bundler.require
|
2015-07-23 13:59:29 +02:00
|
|
|
require "opal/parser"
|
|
|
|
|
2015-07-22 22:08:36 +02:00
|
|
|
Opal.use_gem "salama"
|
|
|
|
Opal.use_gem "salama-arm"
|
2015-07-22 15:17:25 +02:00
|
|
|
|
2015-07-23 13:59:29 +02:00
|
|
|
require "tilt/erb"
|
|
|
|
require "json"
|
2015-07-22 15:17:25 +02:00
|
|
|
require "react/source"
|
|
|
|
|
2015-07-23 13:59:29 +02:00
|
|
|
class DebugServer < Opal::Server
|
|
|
|
|
|
|
|
def parse(num)
|
|
|
|
string_input = '"Hello again".putstring()'
|
|
|
|
parser = Parser::Salama.new
|
|
|
|
out = parser.parse(string_input)
|
|
|
|
parts = Parser::Transform.new.apply(out)
|
|
|
|
parts.to_basic
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
if env['PATH_INFO'].include? "/parse.json"
|
|
|
|
parse_out = parse(1).to_s
|
|
|
|
[200, { 'Content-Type' => 'text/json' }, [parse_out]]
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
2015-07-22 15:17:25 +02:00
|
|
|
|
2015-07-23 13:59:29 +02:00
|
|
|
end
|
|
|
|
run DebugServer.new {|s|
|
2015-07-22 15:26:46 +02:00
|
|
|
s.append_path 'app'
|
2015-07-23 12:15:44 +02:00
|
|
|
s.append_path 'lib'
|
2015-07-22 15:17:25 +02:00
|
|
|
s.append_path File.dirname(::React::Source.bundled_path_for("react-with-addons.js"))
|
2015-07-23 13:59:29 +02:00
|
|
|
s.main = 'main'
|
2015-07-22 15:17:25 +02:00
|
|
|
s.debug = true
|
|
|
|
s.source_map = true
|
2015-07-22 16:10:50 +02:00
|
|
|
s.index_path = "index.html.erb"
|
2015-07-22 15:17:25 +02:00
|
|
|
}
|