docapurl 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/docapurl/browser.rb +15 -2
- data/lib/docapurl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09f3d1efd60fb58c951848cfe37121d0956baf61b6fa16b8957e4e53ca889e40'
|
4
|
+
data.tar.gz: 54037e462178301985d07781e529af9f023e50973a76b2c3897869284929bbeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 586895c140e5f365821b3899e4047b4f04c08a34ce0a60dd8d0b44517864b73639594c75c2b9573b1caf9d73bb362afd884455874c8b043c5f2557a06cc00015
|
7
|
+
data.tar.gz: ae00a9feb3de17fa78e3fbf9a58f601c181eb458a4fbebaa8f5e86a0711ec9990daed4a2a4a340ae7b4cd4a588bc3917103ad07a06ea841a21e0772f48b9c879
|
data/Gemfile.lock
CHANGED
data/lib/docapurl/browser.rb
CHANGED
@@ -24,7 +24,11 @@ module Docapurl
|
|
24
24
|
options[:path] ||= "screenshot-#{host.to_s == '' ? '' : "#{host}-"}#{Time.now.strftime('%F-%T')}.jpg"
|
25
25
|
logger.info "browser begin to visit url #{url}"
|
26
26
|
|
27
|
+
set_callback("before_visit_func", options)
|
27
28
|
browser.go_to(url)
|
29
|
+
set_callback("after_visit_func", options)
|
30
|
+
|
31
|
+
|
28
32
|
logger.info 'visited'
|
29
33
|
max_pagedown = options[:max_pagedown] || 5
|
30
34
|
pagedown_to_bottom = options.delete :pagedown_to_bottom
|
@@ -34,9 +38,10 @@ module Docapurl
|
|
34
38
|
logger.info "sleep #{sleep_before_screen.to_i} second before screenshot"
|
35
39
|
sleep(sleep_before_screen.to_i)
|
36
40
|
|
37
|
-
|
38
|
-
before_screenshot_func
|
41
|
+
|
42
|
+
set_callback("before_screenshot_func", options)
|
39
43
|
browser.screenshot(**options)
|
44
|
+
set_callback("after_screenshot_func", options)
|
40
45
|
|
41
46
|
logger.info "screenshot ended, path = #{options[:path]}"
|
42
47
|
end
|
@@ -70,6 +75,14 @@ module Docapurl
|
|
70
75
|
browser.keyboard.type(:Home)
|
71
76
|
end
|
72
77
|
|
78
|
+
private
|
79
|
+
|
80
|
+
def set_callback(name, options)
|
81
|
+
the_funcion = options.delete name
|
82
|
+
the_funcion.call(self) unless the_funcion.nil?
|
83
|
+
end
|
84
|
+
|
85
|
+
|
73
86
|
class << self
|
74
87
|
def cap(url, path = nil, browser_options = {}, cap_options = {})
|
75
88
|
browser = new(browser_options)
|
data/lib/docapurl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docapurl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- atpking
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|