1 # A simple IPC server for executing arbitrary Ruby program.
2 # The protocol is based on Assuan protocol of GnuPG.
16 return @buf << unescape($')
20 d = "dispatch_#{c.downcase}"
21 if respond_to?(d, true)
26 puts("ERR 103 Unknown command\r\n")
31 def dispatch_cancel(c, r)
32 puts("ERR 100 Not implemented\r\n")
35 def dispatch_bye(c, r)
36 puts("ERR 100 Not implemented\r\n")
39 def dispatch_auth(c, r)
40 puts("ERR 100 Not implemented\r\n")
43 def dispatch_reset(c, r)
44 puts("ERR 100 Not implemented\r\n")
47 def dispatch_end(c, r)
51 def dispatch_help(c, r)
52 puts("ERR 100 Not implemented\r\n")
55 def dispatch_quit(c, r)
56 puts("ERR 100 Not implemented\r\n")
59 def dispatch_eval(c, r)
60 r = deq_data if r.empty?
70 puts("ERR #{$?.exitstatus}\r\n")
80 s.gsub(/[%\r\n]/) {|m| '%%%02X' % m[0]}
84 s.gsub(/%([0-9A-Z][0-9A-Z])/, ['\1'].pack('H*'))
89 r = [d.length, 998].min # 998 = 1000 - CRLF
91 r -= 2 if d[i] =~ /[%\r\n]/
93 puts("D #{escape(d[0 ... r])}\r\n")