watchdoge 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/watchdoge/compare/dsl.rb +16 -1
- data/lib/watchdoge/compare.rb +2 -1
- data/lib/watchdoge/version.rb +1 -1
- data/lib/watchdoge/worker.rb +25 -33
- data/watchdoge.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '095e7358893894c7ce398fc669beafd1485e1fcb8429d47753c25f91774945a5'
|
4
|
+
data.tar.gz: a36c206bda55ded961f0e6440eb8415e28980361b1d8f867a997374f859b351c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad40e175dbdec71e2629091a1244a39cb9ea08d747c878c6afb6346c40a66a190d141689d182e6eea25f0f9725833fd8c75046d476edfcc4f08a0858bdee0a81
|
7
|
+
data.tar.gz: 976e99c48d5c34005c05d34732944b419f36dff3944e1191f54f17d29112dc9dd5a33f299143f4cc999a41ddd8e9312bfd7e787d433f2e28519fe499644521de
|
@@ -15,8 +15,15 @@ module WatchDoge
|
|
15
15
|
sign_out_proc.call(@worker, resoruce)
|
16
16
|
end
|
17
17
|
|
18
|
+
def with_viewport **kwargs
|
19
|
+
@view_port = kwargs
|
20
|
+
yield
|
21
|
+
@view_port = {}
|
22
|
+
end
|
23
|
+
|
18
24
|
def compare path, **kwargs
|
19
25
|
path = URI.join(WatchDoge.configuration.compare_host, path).to_s
|
26
|
+
|
20
27
|
@reference_file_name =
|
21
28
|
if kwargs[:with]
|
22
29
|
kwargs[:with]
|
@@ -36,7 +43,15 @@ module WatchDoge
|
|
36
43
|
|
37
44
|
@worker.goto path
|
38
45
|
|
39
|
-
|
46
|
+
if kwargs[:wait]
|
47
|
+
@view_port.merge!({
|
48
|
+
wait: kwargs[:wait]
|
49
|
+
})
|
50
|
+
end
|
51
|
+
|
52
|
+
@worker.resize_by_document(@view_port) do
|
53
|
+
@compare_proc.call(@worker)
|
54
|
+
end
|
40
55
|
|
41
56
|
@teardown_proc.call if @teardown_proc
|
42
57
|
end
|
data/lib/watchdoge/compare.rb
CHANGED
data/lib/watchdoge/version.rb
CHANGED
data/lib/watchdoge/worker.rb
CHANGED
@@ -1,23 +1,5 @@
|
|
1
1
|
module WatchDoge
|
2
|
-
module PDFUtil
|
3
|
-
def pdf_screenshot
|
4
|
-
# no such thing as on_loaded for gecko pdf-viewer
|
5
|
-
sleep 3
|
6
|
-
|
7
|
-
firefox_pdf_viewer_id = 'viewer'
|
8
|
-
firefox_scaler_id = 'scaleSelect'
|
9
|
-
scale_factor = '0.75'
|
10
|
-
|
11
|
-
#resize to 75%
|
12
|
-
@core.select({id: firefox_scaler_id}).select(scale_factor)
|
13
|
-
|
14
|
-
fullpage_screenshot({id: firefox_pdf_viewer_id})
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
2
|
class Worker
|
19
|
-
include WatchDoge::PDFUtil
|
20
|
-
|
21
3
|
def initialize uuid, opt={}
|
22
4
|
_before_initialize
|
23
5
|
|
@@ -47,8 +29,8 @@ module WatchDoge
|
|
47
29
|
end
|
48
30
|
|
49
31
|
def fullpage_screenshot **kwargs
|
50
|
-
|
51
|
-
return
|
32
|
+
resize_by_document(kwargs) do |resize|
|
33
|
+
return resize.screenshot
|
52
34
|
end
|
53
35
|
end
|
54
36
|
|
@@ -72,6 +54,29 @@ module WatchDoge
|
|
72
54
|
@core
|
73
55
|
end
|
74
56
|
|
57
|
+
def resize_by_document **kwargs
|
58
|
+
width, height = [@core.body.width, @core.body.height]
|
59
|
+
|
60
|
+
width += (kwargs.delete :width).to_i
|
61
|
+
height += (kwargs.delete :height).to_i
|
62
|
+
sleep_sec = (kwargs.delete :wait).to_i
|
63
|
+
|
64
|
+
unless kwargs.empty?
|
65
|
+
puts " -> wait rendering #{sleep_sec} sec"
|
66
|
+
sleep sleep_sec
|
67
|
+
target = @core.element(kwargs)
|
68
|
+
width += target.width
|
69
|
+
height += target.height
|
70
|
+
end
|
71
|
+
|
72
|
+
@core.window.resize_to [width, 5000].min, [height, 20000].min
|
73
|
+
sleep sleep_sec
|
74
|
+
@core.screenshot.save 'test.png'
|
75
|
+
|
76
|
+
yield(@core)
|
77
|
+
@core.window.resize_to @width, @height
|
78
|
+
end
|
79
|
+
|
75
80
|
private
|
76
81
|
# callbacks before/after init
|
77
82
|
def _before_initialize
|
@@ -96,19 +101,6 @@ module WatchDoge
|
|
96
101
|
@cookie_loaded = true
|
97
102
|
end
|
98
103
|
|
99
|
-
def _resize_by_document **kwargs
|
100
|
-
target =
|
101
|
-
if kwargs.empty?
|
102
|
-
@core.body
|
103
|
-
else
|
104
|
-
@core.element(**kwargs)
|
105
|
-
end
|
106
|
-
|
107
|
-
@core.window.resize_to [target.width, 5000].min, [target.height, 20000].min
|
108
|
-
yield
|
109
|
-
@core.window.resize_to @width, @height
|
110
|
-
end
|
111
|
-
|
112
104
|
# try delegate all methods to @core
|
113
105
|
def method_missing(method_name, *args)
|
114
106
|
result = @core.__send__(method_name, *args)
|
data/watchdoge.gemspec
CHANGED