Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created May 11, 2012 09:59
Show Gist options
  • Save jugyo/2658708 to your computer and use it in GitHub Desktop.
Save jugyo/2658708 to your computer and use it in GitHub Desktop.
remote console using druby
require 'drb'
require 'readline'
DRb.start_service
server = DRbObject.new_with_uri("druby://localhost:9898")
while buf = Readline.readline('> ', true)
buf = buf.strip
case buf
when 'exit'
exit
else
begin
puts " => #{server.eval(buf).inspect}"
rescue => e
puts e.message
end
end
end
require "drb/drb"
class Evaluator
def initialize(i)
@i = i
end
def eval(*args)
@i.instance_eval(*args)
end
end
DRb.start_service('druby://localhost:9898', Evaluator.new(self))
DRb.thread.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment