module EvilSystems::RemoteChrome

Public Class Methods

connected?() click to toggle source

Whether or not the socket could be connected @return [Boolean]

# File lib/evil_systems/remote_chrome.rb, line 31
def self.connected?
  if url.nil?
    false
  else
    Socket.tcp(host, port, connect_timeout: 1).close
    true
  end
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, SocketError
  false
end
host() click to toggle source

Current host @return [String, nil]

# File lib/evil_systems/remote_chrome.rb, line 16
def self.host
  URI.parse(url).yield_self { |uri| uri.host } if url
end
options() click to toggle source

Returns a hash with a :url key / value if a remote chrome url is found. @return [Hash{:url => String, nil}]

# File lib/evil_systems/remote_chrome.rb, line 23
def self.options
  # Check whether the remote chrome is running and configure the Capybara
  # driver for it.
  connected? ? {url: url} : {}
end
port() click to toggle source

Current port @return Integer

# File lib/evil_systems/remote_chrome.rb, line 10
def self.port
  URI.parse(url).yield_self { |uri| uri.port }
end
url() click to toggle source

@return [String, nil]

# File lib/evil_systems/remote_chrome.rb, line 4
def self.url
  ENV["CHROME_URL"]
end