Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 38 lines (31 sloc) 782 Bytes
#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), 'lib', 'raspmod.rb')
class DRbRepl
attr_reader :result
def initialize
@repl = Rasp::REPL.new
@original_stdout = $stdout
@original_stderr = $stderr
end
def run(str)
if str == "--restart" || str == "-r"
@repl = Rasp::REPL.new
@result = "Rasp REPL restarted"
return
end
File.open("output", "w") do |f|
$stdout = $stderr = f
begin
@repl.server_repl(str)
ensure
$stdout = @original_stdout
$stderr = @original_stderr
end
end
@result = open('output').read.chomp
end # run(str)
end
DRb.start_service 'druby://:9000', DRbRepl.new
puts "Server running at #{DRb.uri}"
trap("INT") { DRb.stop_service }
DRb.thread.join