Sha256: eedbbbfb2ca50c76126a241238d251cfa0ce222464416218c15fd76d697c1f43

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

require 'schmooze'

class Grover
  #
  # Processor helper class for calling out to Puppeteer NodeJS library
  #
  class Processor < Schmooze::Base
    dependencies puppeteer: 'puppeteer'

    def self.launch_params
      ENV['CI'] == 'true' ? "{args: ['--no-sandbox', '--disable-setuid-sandbox']}" : ''
    end
    private_class_method :launch_params

    method :convert_pdf, Utils.squish(<<-FUNCTION)
      async (url, options) => {
        let browser;
        try {
          browser = await puppeteer.launch(#{launch_params});
          const page = await browser.newPage();
          await page.goto(url, { waitUntil: 'networkidle2' });
          return await page.pdf(options);
        } finally {
          if (browser) {
            await browser.close();
          }
        }
      }
    FUNCTION
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grover-0.1.2 lib/grover/processor.rb
grover-0.1.1 lib/grover/processor.rb