Class: Wayfarer::Configuration

Inherits:
OpenStruct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/wayfarer/configuration.rb

Constant Summary collapse

DEFAULTS =
{
  # Print full stacktraces?
  print_stacktraces: true,

  # Crash when encountering unhandled exceptions?
  reraise_exceptions: false,

  # Allow processing URIs multiple times?
  allow_circulation: false,

  # How many HTTP connections/Selenium drivers to use
  # 1:1 correspondence with spawned threads
  connection_count: 1,

  # Which HTTP adapter to use. Supported are :net_http and :selenium
  http_adapter: :net_http,

  # Which frontier to use.
  frontier: :memory,

  # How long a thread may hold an HTTP adapter.
  # Threads that exceed this limit fail with an exception.
  connection_timeout: Float::INFINITY,

  # How many 3xx redirects to follow. Has no effect when using Selenium
  max_http_redirects: 3,

  # Argument vector for instantiating Selenium drivers
  selenium_argv: [:firefox],

  # Argument vector for instantiating a Redis connection
  redis_opts: {
    host: "localhost",
    port: 6379
  }.freeze,

  # Size of browser windows
  window_size: [1024, 768],

  # Which Mustermann pattern type to use when matching URI paths
  # TODO: Mention in docs
  mustermann_type: :sinatra,

  # Options for instantiating Bloomfilters
  bloomfilter_opts: {
    size: 100,
    hashes: 2,
    seed: 1,
    bucket: 3,
    raise: false
  },

  # Whether to normalize URIs
  normalize_uris: true,

  # URI normalization options
  # See: https://github.com/rwz/normalize_url
  normalize_uri_options: {}
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(overrides = {}) ⇒ Configuration

Returns a new instance of Configuration.



73
74
75
76
# File 'lib/wayfarer/configuration.rb', line 73

def initialize(overrides = {})
  super(DEFAULTS.merge(overrides))
  @uuid = SecureRandom.uuid
end

Instance Attribute Details

#uuidObject (readonly)

Returns the value of attribute uuid.



71
72
73
# File 'lib/wayfarer/configuration.rb', line 71

def uuid
  @uuid
end

Instance Method Details

#loggerObject



78
79
80
# File 'lib/wayfarer/configuration.rb', line 78

def logger
  @logger ||= Wayfarer.logger.dup
end

#reset!Object



82
83
84
# File 'lib/wayfarer/configuration.rb', line 82

def reset!
  DEFAULTS.each { |key, val| self[key] = val }
end