14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/mozrepl_client.rb', line 14
def self.run js, options={}
s = TCPSocket::new("localhost", "4242")
initial_crap = self.read s
repl = initial_crap[/repl\d+/] || 'repl'
if options[:tab] s.puts("#{repl}.enter(window.gBrowser.getBrowserAtIndex(#{options[:tab]}).contentDocument)\n;")
self.read s
elsif options[:browser] else s.puts("#{repl}.enter(content.wrappedJSObject)\n;")
self.read s
end
s.puts js
txt = self.read s
s.close
txt.strip
end
|