Module: Tanakai::BrowserBuilder

Defined in:
lib/tanakai/browser_builder.rb,
lib/tanakai/browser_builder/cuprite_builder.rb,
lib/tanakai/browser_builder/mechanize_builder.rb,
lib/tanakai/browser_builder/apparition_builder.rb,
lib/tanakai/browser_builder/selenium_chrome_builder.rb,
lib/tanakai/browser_builder/selenium_firefox_builder.rb,
lib/tanakai/browser_builder/poltergeist_phantomjs_builder.rb

Defined Under Namespace

Classes: ApparitionBuilder, CupriteBuilder, MechanizeBuilder, PoltergeistPhantomjsBuilder, SeleniumChromeBuilder, SeleniumFirefoxBuilder

Class Method Summary collapse

Class Method Details

.build(engine, config = {}, spider:) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tanakai/browser_builder.rb', line 3

def self.build(engine, config = {}, spider:)
  if config[:browser].present?
    raise "++++++ BrowserBuilder: browser option is depricated. Now all sub-options inside " \
      "`browser` should be placed right into `@config` hash, without `browser` parent key.\n" \
      "See more here: https://github.com/vifreefly/kimuraframework/blob/master/CHANGELOG.md#breaking-changes-110 ++++++"
  end

  begin
    require "tanakai/browser_builder/#{engine}_builder"
  rescue LoadError => e
  end

  builder_class_name = "#{engine}_builder".classify
  builder = "Tanakai::BrowserBuilder::#{builder_class_name}".constantize
  builder.new(config, spider: spider).build
end