Class: Capybara::Webkit::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/webkit/connection.rb

Constant Summary collapse

SERVER_PATH =
File.expand_path("../../../../bin/webkit_server", __FILE__)
WEBKIT_SERVER_START_TIMEOUT =
15

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Connection

Returns a new instance of Connection.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/capybara/webkit/connection.rb', line 13

def initialize(options = {})
  @socket = nil
  @socket_class = options[:socket_class] || TCPSocket
  if options.has_key?(:stderr)
    @output_target = options[:stderr]
  elsif options.has_key?(:stdout)
    warn '[DEPRECATION] The Capybara::Webkit::Connection `stdout` option ' \
      'is deprecated. Please use `stderr` instead.'
    @output_target = options[:stdout]
  else
    @output_target = $stderr
  end
  start_server
  connect
end

Instance Attribute Details

#pidObject (readonly)

Returns the value of attribute pid.



11
12
13
# File 'lib/capybara/webkit/connection.rb', line 11

def pid
  @pid
end

#portObject (readonly)

Returns the value of attribute port.



11
12
13
# File 'lib/capybara/webkit/connection.rb', line 11

def port
  @port
end

Instance Method Details

#getsObject



37
38
39
# File 'lib/capybara/webkit/connection.rb', line 37

def gets
  @socket.gets
end


33
34
35
# File 'lib/capybara/webkit/connection.rb', line 33

def print(string)
  @socket.print string
end

#puts(string) ⇒ Object



29
30
31
# File 'lib/capybara/webkit/connection.rb', line 29

def puts(string)
  @socket.puts string
end

#read(length) ⇒ Object



41
42
43
# File 'lib/capybara/webkit/connection.rb', line 41

def read(length)
  @socket.read(length)
end