Class: Grover::Processor

Inherits:
Object show all
Defined in:
lib/grover/processor.rb

Overview

Processor helper class for calling out to Puppeteer NodeJS library

Heavily based on the Schmooze library github.com/Shopify/schmooze

Instance Method Summary collapse

Constructor Details

#initialize(app_root) ⇒ Processor

Returns a new instance of Processor.



13
14
15
# File 'lib/grover/processor.rb', line 13

def initialize(app_root)
  @app_root = app_root
end

Instance Method Details

#convert(method, url_or_html, options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/grover/processor.rb', line 17

def convert(method, url_or_html, options)
  spawn_process
  ensure_packages_are_initiated
  result = call_js_method method, url_or_html, options
  return unless result
  return result if result.is_a?(String)

  result['data'].pack('C*')
ensure
  cleanup_process if stdin
end