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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86881b158d69d1aaeea4f5fbee021a3a233c57c12734b5e01ddc41c1cf53db87
4
- data.tar.gz: b163063f0d2f0929633a3d1f91dbb006e4e89491887bdc554316d5e1d7ec915a
3
+ metadata.gz: '09f3d1efd60fb58c951848cfe37121d0956baf61b6fa16b8957e4e53ca889e40'
4
+ data.tar.gz: 54037e462178301985d07781e529af9f023e50973a76b2c3897869284929bbeb
5
5
  SHA512:
6
- metadata.gz: 8bcba07ed66ccf5a524964c30be1bfb532af23d903451a76488e28ef49a581c6407da032509d357cfd73266c79abe0846bbf7fd6d058cffef36a23028c8826db
7
- data.tar.gz: fda63aadee384889304c02677dd0a6431ba68e32bb193028f959ff9b44666303718bf62f2ac7fe634ec8f8a02c293e34ed96d7a63c40ed251224ea3470058f38
6
+ metadata.gz: 586895c140e5f365821b3899e4047b4f04c08a34ce0a60dd8d0b44517864b73639594c75c2b9573b1caf9d73bb362afd884455874c8b043c5f2557a06cc00015
7
+ data.tar.gz: ae00a9feb3de17fa78e3fbf9a58f601c181eb458a4fbebaa8f5e86a0711ec9990daed4a2a4a340ae7b4cd4a588bc3917103ad07a06ea841a21e0772f48b9c879
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- docapurl (0.1.2)
4
+ docapurl (0.2.0)
5
5
  ferrum (~> 0.11)
6
6
  thor
7
7
 
@@ -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
- before_screenshot_func = options.delete :before_screenshot_func
38
- before_screenshot_func.call(self) unless before_screenshot_func.nil?
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)
@@ -1,3 +1,3 @@
1
1
  module Docapurl
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.3
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-04-25 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler