Class: Blinkr::PhantomJSWrapper

Inherits:
Object
  • Object
show all
Includes:
HttpUtils
Defined in:
lib/blinkr/phantomjs_wrapper.rb

Direct Known Subclasses

SlimerJSWrapper

Constant Summary collapse

SNAP_JS =
File.expand_path('snap.js', File.dirname(__FILE__))

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HttpUtils

#retry?, #sanitize

Constructor Details

#initialize(config, context) ⇒ PhantomJSWrapper

Returns a new instance of PhantomJSWrapper.



17
18
19
20
21
22
# File 'lib/blinkr/phantomjs_wrapper.rb', line 17

def initialize config, context
  @config = config.validate
  @context = context
  @count = 0
  @cache = Blinkr::Cache.new
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



15
16
17
# File 'lib/blinkr/phantomjs_wrapper.rb', line 15

def count
  @count
end

Instance Method Details

#commandObject



38
39
40
# File 'lib/blinkr/phantomjs_wrapper.rb', line 38

def command
  'phantomjs'
end

#nameObject



34
35
36
# File 'lib/blinkr/phantomjs_wrapper.rb', line 34

def name
  'phantomjs'
end

#process(url, limit, opts = {}, &block) ⇒ Object



30
31
32
# File 'lib/blinkr/phantomjs_wrapper.rb', line 30

def process url, limit, opts = {}, &block
  _process url, limit, limit, opts, &block
end

#process_all(urls, limit, opts = {}, &block) ⇒ Object



24
25
26
27
28
# File 'lib/blinkr/phantomjs_wrapper.rb', line 24

def process_all urls, limit, opts = {}, &block
  Parallel.each(urls, :in_threads => (@config.phantomjs_threads || Parallel.processor_count * 2)) do |url|
    process url, limit, opts, &block
  end
end