Class: Unmagic::Browser::Configuration
- Inherits:
-
Object
- Object
- Unmagic::Browser::Configuration
- 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
-
#default_driver ⇒ Object
The driver used when new is called without one, in every environment except development.
-
#logger ⇒ Logger
Where the gem narrates what it's doing.
-
#navigation_timeout ⇒ Object
Seconds a single navigation is given.
-
#timeout ⇒ Object
Seconds a locator keeps looking, and a Session#wait_for waits, before giving up.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
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_driver ⇒ Object
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 |
#logger ⇒ Logger
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.
40 41 42 |
# File 'lib/unmagic/browser/configuration.rb', line 40 def logger @logger ||= default_logger end |
#navigation_timeout ⇒ Object
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 end |
#timeout ⇒ Object
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 |