Class: Scruber::Core::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/scruber/core/configuration.rb

Overview

Configuration class

Author:

  • Ivan Goncharov

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



25
26
27
28
29
30
31
32
33
34
# File 'lib/scruber/core/configuration.rb', line 25

def initialize
  @fetcher_adapter = :typhoeus_fetcher
  @fetcher_options = {}
  @fetcher_agent_adapter = :memory
  @fetcher_agent_options = {}
  @queue_adapter = :memory
  @queue_options = {}
  @autoload_paths = []
  @silent = false
end

Instance Attribute Details

#autoload_pathsArray<String>

Array with paths for autoloading classes

Returns:

  • (Array<String>)

    the current value of autoload_paths



15
16
17
# File 'lib/scruber/core/configuration.rb', line 15

def autoload_paths
  @autoload_paths
end

#fetcher_adapterSymbol

Fetcher adapter name

Returns:

  • (Symbol)

    the current value of fetcher_adapter



15
16
17
# File 'lib/scruber/core/configuration.rb', line 15

def fetcher_adapter
  @fetcher_adapter
end

#fetcher_agent_adapterSymbol

Fetcher agent adapter name

Returns:

  • (Symbol)

    the current value of fetcher_agent_adapter



15
16
17
# File 'lib/scruber/core/configuration.rb', line 15

def fetcher_agent_adapter
  @fetcher_agent_adapter
end

#fetcher_agent_optionsHash

Returns:

  • (Hash)

    the current value of fetcher_agent_options



15
16
17
# File 'lib/scruber/core/configuration.rb', line 15

def fetcher_agent_options
  @fetcher_agent_options
end

#fetcher_optionsHash

Fetcher options, see FetcherAdapters::AbstractAdapter options

Returns:

  • (Hash)

    the current value of fetcher_options



15
16
17
# File 'lib/scruber/core/configuration.rb', line 15

def fetcher_options
  @fetcher_options
end

#queue_adapterSymbol

Queue adapter name

Returns:

  • (Symbol)

    the current value of queue_adapter



15
16
17
# File 'lib/scruber/core/configuration.rb', line 15

def queue_adapter
  @queue_adapter
end

#queue_optionsHash

Queue options, see QueueAdapters::AbstractAdapter

Returns:

  • (Hash)

    the current value of queue_options



15
16
17
# File 'lib/scruber/core/configuration.rb', line 15

def queue_options
  @queue_options
end

#silentBoolean

Don’t output anything if true

Returns:

  • (Boolean)

    the current value of silent



15
16
17
# File 'lib/scruber/core/configuration.rb', line 15

def silent
  @silent
end

Instance Method Details

#merge_options(options) ⇒ void

This method returns an undefined value.

Merge options from hash

Parameters:

  • options (Hash)

    options



41
42
43
44
45
46
47
48
49
50
# File 'lib/scruber/core/configuration.rb', line 41

def merge_options(options)
  @fetcher_adapter = options.fetch(:fetcher_adapter){ @fetcher_adapter }
  @fetcher_options.merge! options.fetch(:fetcher_options){ {} }
  @fetcher_agent_adapter = options.fetch(:fetcher_agent_adapter){ @fetcher_agent_adapter }
  @fetcher_agent_options.merge! options.fetch(:fetcher_agent_options){ {} }
  @queue_adapter = options.fetch(:queue_adapter){ @queue_adapter }
  @queue_options.merge! options.fetch(:queue_options){ {} }
  @autoload_paths += options.fetch(:autoload_paths){ [] }
  @silent = options.fetch(:silent){ false }
end