Sha256: 5935d8ae560df7563337e208e8c67a76240b443d9d2b4c24fa8fa845e774709c

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

require 'screencap'
# require 'smartshot'

module YAMG
  #
  # Screenshot from multiple providers
  #
  class Screenshot
    # include Capybara::DSL
    attr_accessor :url, :size, :command

    # Uses PhantomJS
    def initialize(ss)
      require 'smartshot'
      require 'capybara'
      require 'capybara/poltergeist'
      @name, opts =  *ss
      uri = URI.parse(opts['url'])
      @url = "http://#{uri}"
      @size = opts['size'].split(/\s?,\s?/)
      # @fetcher = Smartshot::Screenshot.new(window_size: @size)
      @fetcher = Screencap::Fetcher.new(@url)

    end

    def work(path)
      # visit(url)
      # page.save_screenshot("#{path}/#{@name}.png")
      # @fetcher.take_screenshot!(url: url, output: "#{path}/#{@name}.png")
      @fetcher.fetch(output: "#{path}/#{@name}.png", width: @size[0], height: @size[1])
      puts Rainbow("SS #{url} #{size}").black
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yamg-0.0.7 lib/yamg/screenshot.rb