Class: Unmagic::Browser::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/unmagic/browser/configuration.rb

Overview

Global defaults, set once with configure. Anything a caller passes to #initialize or to a session wins over what's here.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



28
29
30
31
32
33
# File 'lib/unmagic/browser/configuration.rb', line 28

def initialize
  @default_driver = :cloudflare
  @timeout = 10
  @navigation_timeout = 30
  @logger = nil
end

Instance Attribute Details

#default_driverObject

The driver used when Unmagic::Browser.new is called without one, in every environment except development. A symbol (:local, :remote, :cloudflare) or a driver instance.



14
15
16
# File 'lib/unmagic/browser/configuration.rb', line 14

def default_driver
  @default_driver
end

#loggerLogger

Where the gem narrates what it's doing. Defaults to Rails.logger in a Rails app, and to a silent logger everywhere else — a library shouldn't write to a host app's stdout unasked.

Returns:

  • (Logger)


40
41
42
# File 'lib/unmagic/browser/configuration.rb', line 40

def logger
  @logger ||= default_logger
end

Seconds a single navigation is given. Longer than #timeout because a cold page on a slow network legitimately takes a while, and there's nothing to retry against in the meantime.



24
25
26
# File 'lib/unmagic/browser/configuration.rb', line 24

def navigation_timeout
  @navigation_timeout
end

#timeoutObject

Seconds a locator keeps looking, and a Session#wait_for waits, before giving up. Deliberately short: a verb that can't find its element is usually wrong rather than early.



19
20
21
# File 'lib/unmagic/browser/configuration.rb', line 19

def timeout
  @timeout
end