Sha256: 284460a8409845a05cb50a4bb6b9857e9a79bb4d7117705df9400ab8a8886af5

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require_relative './docapurl/version'
require_relative './docapurl/browser'
begin
  require 'byebug'
rescue
end
require 'thor'

module Docapurl
  class Error < StandardError; end

  # Your code goes here...
  class Cli < Thor
    desc 'cap [url]', 'cap url'
    method_option :browser_path, type: :string, desc: 'specify chrome browser path', required: false
    method_option :max_pagedown, type: :numeric, default: 5,
                                 desc: 'max page down press when page height overs the viewport height'
    method_option :pagedown_to_bottom, type: :boolean, default: false, desc: 'page down press until down to bottom'
    method_option :sleep_before_screen, type: :numeric, default: 0, desc: 'sleep second before_screen'
    method_option :xvfb, type: :boolean, default: false, desc: 'xvfb needed'
    method_option :headless, type: :boolean, default: true, desc: 'run in headless'
    def cap(url, path = nil)
      browser_options = {
        xvfb: options.xvfb,
        headless: options.headless,
        browser_path: options.browser_path
      }.reject { |_, v| v.nil? }

      Docapurl::Browser.cap(url, path, browser_options,
                            { max_pagedown: options.max_pagedown,
                              sleep_before_screen: options.sleep_before_screen,
                              pagedown_to_bottom: options.pagedown_to_bottom })
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
docapurl-0.1.0 lib/docapurl.rb