Module: Kimurai::BrowserBuilder

Defined in:
lib/kimurai/browser_builder.rb,
lib/kimurai/browser_builder/mechanize_builder.rb,
lib/kimurai/browser_builder/selenium_chrome_builder.rb,
lib/kimurai/browser_builder/selenium_firefox_builder.rb,
lib/kimurai/browser_builder/poltergeist_phantomjs_builder.rb

Defined Under Namespace

Classes: 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/kimurai/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 "kimurai/browser_builder/#{engine}_builder"
  rescue LoadError => e
  end

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