docapurl 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5aa0b10bd4486ba6c93c290fb5f3e0ee43197ae56c32f6c9b47352393a2f5eac
4
- data.tar.gz: 6efd81401f6a3e631425fbced1e11bf1506b6c3e34fbb41614fb985c3a35ad7e
3
+ metadata.gz: 86b590bab2ec4319cb20309eb6a8aada80cb75f06518d3a1dc187f975a586c22
4
+ data.tar.gz: 991021e9e09e7fee0bfd2bb2c4c2de68740a6b5f21b271022b223b57876efa49
5
5
  SHA512:
6
- metadata.gz: 921bdbf8311230dabb6869115dc8a1eb34d1b820bbd348747bd77a5690a8d336270d577f71e5f36bef374bd0f9ff7ce9035711ae9b623c6e935059153cae9d45
7
- data.tar.gz: 952f61d8f37051e404716d77fb0f1bebc80232e9bc07f616dae04183eb065a6fb84d9bd47c0bd975f45a420c9d47dc1a3a198e2f14f45e886844bdba009ab738
6
+ metadata.gz: ad15cf9f5f9456b163d1ca8fd6a2cab22eef9d710ad6c5acbd93609c6cd7d2f7a63e256c3875dad1312a352d0d60be5d240612e9c52e7213145ab13bae708b6d
7
+ data.tar.gz: 15c44caa1302a481166441ac3bfb43894248681c8b357752398bedaac55ab293b761d9c1ed75fe8f0c377e782b0db59e4c7f5f2373deff65e96f91e2b6957b0e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- docapurl (0.2.2)
4
+ docapurl (0.2.3)
5
5
  ferrum (~> 0.11)
6
6
  thor
7
7
 
@@ -4,7 +4,7 @@ require 'logger'
4
4
  module Docapurl
5
5
  class Browser
6
6
  SYSTEM_MAX_PAGE_DOWN_TO_BOTTOM = 50
7
- attr_accessor :browser, :save_path, :logger, :context
7
+ attr_accessor :browser, :save_path, :logger, :context, :page
8
8
 
9
9
  def initialize(options)
10
10
  @save_path = options[:save_path]
@@ -14,11 +14,11 @@ module Docapurl
14
14
  @logger = options[:logger] || Logger.new(STDOUT)
15
15
  @browser = Ferrum::Browser.new options
16
16
  @context = browser.contexts.create
17
+ @page = @context.create_page
17
18
  yield(self) if block_given?
18
19
  end
19
20
 
20
21
  def cap(url, options)
21
- page = @context.create_page
22
22
  options[:quality] ||= 90
23
23
  options[:full] = true if options[:full].nil?
24
24
  options[:path] ||= @save_path
@@ -34,7 +34,7 @@ module Docapurl
34
34
  logger.info 'visited'
35
35
  max_pagedown = options[:max_pagedown] || 5
36
36
  pagedown_to_bottom = options.delete :pagedown_to_bottom
37
- visit_whole_page(browser, page: page, max_pagedown: max_pagedown, pagedown_to_bottom: pagedown_to_bottom)
37
+ visit_whole_page(page: page, max_pagedown: max_pagedown, pagedown_to_bottom: pagedown_to_bottom)
38
38
 
39
39
  sleep_before_screen = options.delete :sleep_before_screen
40
40
  logger.info "sleep #{sleep_before_screen.to_i} second before screenshot"
@@ -56,8 +56,7 @@ module Docapurl
56
56
  browser.quit
57
57
  end
58
58
 
59
- def visit_whole_page(browser, page: nil, max_pagedown: nil, pagedown_to_bottom: false)
60
- page ||= browser.page
59
+ def visit_whole_page( page: nil, max_pagedown: nil, pagedown_to_bottom: false)
61
60
  viewport_height = page.viewport_size.last.to_i
62
61
  document_height = page.document_size.last.to_i
63
62
  return if document_height<= viewport_height
@@ -1,3 +1,3 @@
1
1
  module Docapurl
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docapurl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - atpking