Class: MozreplSocket
- Inherits:
-
FirefoxSocket
- Object
- FirefoxSocket
- MozreplSocket
- Defined in:
- lib/vapir-firefox/firefox_socket/mozrepl.rb
Overview
A MozreplSocket represents a connection to Firefox over a socket opened to the MozRepl extension.
Constant Summary
Constants inherited from FirefoxSocket
Instance Attribute Summary
Attributes inherited from FirefoxSocket
Class Method Summary collapse
-
.command_line_flags(options = {}) ⇒ Object
returns an array of command line flags that should be used to invoke firefox for mozrepl.
Instance Method Summary collapse
Methods inherited from FirefoxSocket
#Components, #assert_socket, #assign, #assign_json, #call, #call_function, #call_json, #configuration_parent, #function, #handle, #handle_json, #handling_connection_error, #host, #initialize, #inspect, #instanceof, #object, #object_in_temp, #parse_json, #port, #root, to_javascript, #typeof, #value, #value_json
Constructor Details
This class inherits a constructor from FirefoxSocket
Class Method Details
.command_line_flags(options = {}) ⇒ Object
returns an array of command line flags that should be used to invoke firefox for mozrepl
11 12 13 14 |
# File 'lib/vapir-firefox/firefox_socket/mozrepl.rb', line 11 def self.command_line_flags(={}) = config.defined_hash.merge() ['-repl', ['port']] end |
Instance Method Details
#eat_welcome_message ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vapir-firefox/firefox_socket/mozrepl.rb', line 16 def read=read_value if !read @expecting_extra_maybe=true raise FirefoxSocketUnableToStart, "Something went wrong initializing - no response" elsif read !~ /Welcome to MozRepl/ @expecting_extra_maybe=true raise FirefoxSocketUnableToStart, "Something went wrong initializing - message #{read.inspect}" end if read =~ /yours will be named "([^"]+)"/ @replname=$1 else @replname='repl' end @prompt="#{@replname}> " @expecting_prompt = read !~ /#{Regexp.escape(@prompt)}\z/ end |
#initialize_environment ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/vapir-firefox/firefox_socket/mozrepl.rb', line 33 def initialize_environment # change the prompt mode to something less decorative #send_and_read("#{@replname}.home()") send_and_read("#{@replname}.setenv('printPrompt', false)") @prompt="\n" @expecting_prompt=false send_and_read("#{@replname}.setenv('inputMode', 'multiline')") @input_terminator = "--end-remote-input\n" # set up objects that are needed: nativeJSON_encode_length, VapirTemp, and Vapir ret=send_and_read(%Q((function(the_repl, context) { context.nativeJSON_encode_length=function(object) { var encoded=JSON.stringify(object); the_repl.print(encoded.length.toString()+"\\n"+encoded, false); } context.VapirTemp = {}; context.Vapir = {}; return 'done!'; })(#{@replname}, this))) if ret !~ /done!/ @expecting_extra_maybe=true raise FirefoxSocketError, "Something went wrong initializing environment - message #{ret.inspect}" end end |