lineup 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/lineup +1 -5
- data/lib/controller/browser.rb +2 -2
- data/lib/lineup.rb +14 -66
- data/lib/lineup/version.rb +1 -1
- data/tests/rspec/lineup_spec.rb +9 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07ab8f60bcebca9b0488e5c73d3ccbade289a521
|
4
|
+
data.tar.gz: 3dc3452596572439cc9e7f1342c496c93c7f487b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ffe89fd8929d9c4bb7ad910acbb1d3bb90bcd08ba8480f8a679b187de182bcd228434067c22521d877752e52e8aacc5fede9ce23e3f3379e92f52b1533bd416
|
7
|
+
data.tar.gz: 9fa37586804eff1aa5d75a097333f6df8464ca811eff5ba7c0cb340da6c58f590e5295f89b4e993f6368f7a7e81cd6ce17f20aa646698293c8cf7bfed5591d96
|
data/bin/lineup
CHANGED
@@ -4,11 +4,7 @@ require '../lib/lineup'
|
|
4
4
|
|
5
5
|
puts("This is an example. And a benchmark.")
|
6
6
|
|
7
|
-
lineup = Lineup::Screenshot.new('https://
|
8
|
-
lineup.urls("/,multimedia,moebel,damenmode,mittesten")
|
9
|
-
lineup.cookies([{"name"=>"trackingDisabled","value"=>"true","secure"=>false,"path"=>"/","domain"=>".otto.de"},
|
10
|
-
{"name"=>"survey","value"=>"1","secure"=>false,"path"=>"/","domain"=>".otto.de"}])
|
11
|
-
lineup.localStorage(["us_customerServiceWidget"=>"{'customerServiceWidgetNotificationHidden':{'value':true,'timestamp':1467723066080}}"])
|
7
|
+
lineup = Lineup::Screenshot.new('https://google.de')
|
12
8
|
lineup.resolutions("600,800,1200")
|
13
9
|
lineup.use_phantomjs false
|
14
10
|
lineup.wait_for_asynchron_pages(2)
|
data/lib/controller/browser.rb
CHANGED
@@ -77,9 +77,9 @@ class Browser
|
|
77
77
|
end
|
78
78
|
|
79
79
|
if @localStorage.any?
|
80
|
-
@localStorage.each do |
|
80
|
+
@localStorage.each do |key, value|
|
81
81
|
# Generate javascript for localStorage.setItem, escaping single quotes in key and value
|
82
|
-
stmt = "localStorage.setItem('" +
|
82
|
+
stmt = "localStorage.setItem('" + key.gsub("'", "\\\\'") + "','" + value.gsub("'", "\\\\'") + "')";
|
83
83
|
@browser.execute_script(stmt)
|
84
84
|
end
|
85
85
|
end
|
data/lib/lineup.rb
CHANGED
@@ -170,40 +170,11 @@ module Lineup
|
|
170
170
|
@difference_path = path
|
171
171
|
end
|
172
172
|
|
173
|
-
|
174
|
-
def cookie_for_experiment(cookie)
|
175
|
-
|
176
|
-
# a hash for a cookie can be set here. this is optional.
|
177
|
-
#
|
178
|
-
# e.g {name: 'experiment', value: 'experiment_value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
|
179
|
-
#
|
180
|
-
# if it is not nil it has to be an array:
|
181
|
-
if cookie
|
182
|
-
# generate :symbol => "value" hash map from "symbol" => "value"
|
183
|
-
cookie = cookie.inject({}) { |element, (symbol, value)| element[symbol.to_sym] = value; element }
|
184
|
-
|
185
|
-
#Validation
|
186
|
-
(raise "Cookie must be a hash of format
|
187
|
-
{name: 'experiment', value: 'experiment_value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
|
188
|
-
" unless cookie.is_a? Hash)
|
189
|
-
|
190
|
-
raise "cookie must have value for :name" unless (cookie[:name]).is_a? String
|
191
|
-
raise "cookie must have value for :value" unless (cookie[:value]).is_a? String
|
192
|
-
raise "cookie must have value for :domain" unless (cookie[:domain]).is_a? String
|
193
|
-
raise "cookie must have value for :path" unless (cookie[:path]).is_a? String
|
194
|
-
raise "cookie must have value for :secure" if (cookie[:secure]) == nil
|
195
|
-
end
|
196
|
-
|
197
|
-
# assign the variable
|
198
|
-
|
199
|
-
@cookie_for_experiment = cookie
|
200
|
-
end
|
201
|
-
|
202
173
|
def cookies(cookies)
|
203
174
|
|
204
175
|
# a hash for cookies can be set here. this is optional.
|
205
176
|
#
|
206
|
-
# e.g {name: '
|
177
|
+
# e.g {name: 'name', value: 'value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
|
207
178
|
#
|
208
179
|
# if it is not nil it has to be an array:
|
209
180
|
|
@@ -215,7 +186,7 @@ module Lineup
|
|
215
186
|
|
216
187
|
#Validation
|
217
188
|
(raise "Cookie must be a hash of format
|
218
|
-
{name: '
|
189
|
+
{name: 'name', value: 'value', domain: 'domain.com', path: '/', expires: <Time>, secure: false}
|
219
190
|
" unless cookie.is_a? Hash)
|
220
191
|
|
221
192
|
raise "cookie must have value for :name" unless (cookie[:name]).is_a? String
|
@@ -238,23 +209,19 @@ module Lineup
|
|
238
209
|
#
|
239
210
|
# if it is not nil it has to be an array:
|
240
211
|
|
241
|
-
@localStorage =
|
212
|
+
@localStorage = {}
|
242
213
|
if localStorage
|
243
|
-
|
244
|
-
|
245
|
-
#keyValue = keyValue.inject({}) { |element, (symbol, value)| element[symbol.to_sym] = value; element }
|
246
|
-
|
247
|
-
#Validation
|
248
|
-
(raise "LocalStorage Key Value pair must be a hash of format
|
214
|
+
#Validation
|
215
|
+
(raise "LocalStorage must be a hash of format
|
249
216
|
{'key'=>'value'}
|
250
|
-
" unless
|
217
|
+
" unless localStorage.is_a? Hash)
|
251
218
|
|
252
|
-
|
253
|
-
raise "LocalStorage
|
254
|
-
raise "LocalStorage
|
255
|
-
raise "LocalStorage
|
219
|
+
localStorage.each do |key, value|
|
220
|
+
raise "LocalStorage must have a string as key" if (key).empty?
|
221
|
+
raise "LocalStorage key must be a string" unless (key).is_a? String
|
222
|
+
raise "LocalStorage value must be a string" unless (value).is_a? String
|
256
223
|
|
257
|
-
@localStorage
|
224
|
+
@localStorage[key] = value
|
258
225
|
end
|
259
226
|
end
|
260
227
|
|
@@ -293,23 +260,13 @@ module Lineup
|
|
293
260
|
use_phantomjs(configuration["use_phantomjs"])
|
294
261
|
difference_path(configuration["difference_path"])
|
295
262
|
wait_for_asynchron_pages(configuration["wait_for_asynchron_pages"])
|
296
|
-
cookie_for_experiment(configuration["cookie_for_experiment"])
|
297
263
|
cookies(configuration["cookies"])
|
298
264
|
localStorage(configuration["localStorage"])
|
299
265
|
|
300
|
-
if @cookies
|
301
|
-
cookies_merged= @cookies.inject([]) { |a, element| a << element.dup }
|
302
|
-
else
|
303
|
-
cookies_merged = []
|
304
|
-
end
|
305
|
-
if @cookie_for_experiment
|
306
|
-
cookies_merged.push(@cookie_for_experiment)
|
307
|
-
end
|
308
|
-
|
309
266
|
# the method calls set the variables for the parameters, we return an array with all of them.
|
310
267
|
# for the example above it is:
|
311
268
|
# [["/multimedia", "/sport"], [600, 800, 1200], "~/images/", true, "#/images/diff"]
|
312
|
-
[@urls, @resolutions, @screenshots_path, @headless, @difference_path, @wait_for_asynchron_pages,
|
269
|
+
[@urls, @resolutions, @screenshots_path, @headless, @difference_path, @wait_for_asynchron_pages, @cookies, @localStorage]
|
313
270
|
end
|
314
271
|
|
315
272
|
|
@@ -325,16 +282,7 @@ module Lineup
|
|
325
282
|
# and saves the screenshot in the file
|
326
283
|
# @screenshot_path
|
327
284
|
|
328
|
-
|
329
|
-
cookies_merged= @cookies.inject([]) { |a, element| a << element.dup }
|
330
|
-
else
|
331
|
-
cookies_merged = []
|
332
|
-
end
|
333
|
-
if @cookie_for_experiment
|
334
|
-
cookies_merged.push(@cookie_for_experiment)
|
335
|
-
end
|
336
|
-
|
337
|
-
browser = Browser.new(@baseurl, @urls, @resolutions, @screenshots_path, @headless, @wait_for_asynchron_pages, cookies_merged, @localStorage)
|
285
|
+
browser = Browser.new(@baseurl, @urls, @resolutions, @screenshots_path, @headless, @wait_for_asynchron_pages, @cookies, @localStorage)
|
338
286
|
# the only argument missing is if this is the "base" or "new" screenshot, this can be
|
339
287
|
# passed as an argument. The value does not need to be "base" or "new", but can be anything
|
340
288
|
browser.record(version)
|
@@ -358,7 +306,7 @@ module Lineup
|
|
358
306
|
@urls.each { |url|
|
359
307
|
@resolutions.each { |resolution|
|
360
308
|
#threads[i] = Thread.new {
|
361
|
-
|
309
|
+
@comparer.push(Comparer.new(base, new, @difference_path, @baseurl, [url], [resolution], @screenshots_path))
|
362
310
|
#}
|
363
311
|
#i+=1;
|
364
312
|
}
|
data/lib/lineup/version.rb
CHANGED
data/tests/rspec/lineup_spec.rb
CHANGED
@@ -30,7 +30,7 @@ describe '#screeshot_recorder' do
|
|
30
30
|
# Then
|
31
31
|
expect(
|
32
32
|
lineup.load_json_config(file)
|
33
|
-
).to eq([['page1'], [13], 'screenshots/path', true, 'screenshots/path/difference', 5, [],
|
33
|
+
).to eq([['page1'], [13], 'screenshots/path', true, 'screenshots/path/difference', 5, [], {}])
|
34
34
|
|
35
35
|
# cleanup:
|
36
36
|
FileUtils.rm file if (File.exists? file)
|
@@ -46,13 +46,6 @@ describe '#screeshot_recorder' do
|
|
46
46
|
"use_phantomjs":true,
|
47
47
|
"difference_path":"screenshots/path/difference",
|
48
48
|
"wait_for_asynchron_pages":5,
|
49
|
-
"cookie_for_experiment":{
|
50
|
-
"name":"cookie1",
|
51
|
-
"value":"11111",
|
52
|
-
"domain":".google.de",
|
53
|
-
"path":"/",
|
54
|
-
"secure":false
|
55
|
-
},
|
56
49
|
"cookies" : [{
|
57
50
|
"name":"cookie2",
|
58
51
|
"value":"22222",
|
@@ -67,7 +60,7 @@ describe '#screeshot_recorder' do
|
|
67
60
|
"path":"/",
|
68
61
|
"secure":false
|
69
62
|
}],
|
70
|
-
"localStorage":
|
63
|
+
"localStorage":{"myKey1":"myValue1","myKey2":"myValue2"}
|
71
64
|
}'
|
72
65
|
save_json(json, file)
|
73
66
|
|
@@ -79,9 +72,8 @@ describe '#screeshot_recorder' do
|
|
79
72
|
lineup.load_json_config(file)
|
80
73
|
).to eq([['page1', 'page2'], [13,42], 'screenshots/path', true, 'screenshots/path/difference', 5,
|
81
74
|
[{:name=>"cookie2", :value=>"22222", :domain=>".google.de", :path=>"/", :secure=>false},
|
82
|
-
{:name=>"cookie3", :value=>"33333", :domain=>".google.de", :path=>"/", :secure=>false},
|
83
|
-
|
84
|
-
[{"myKey1"=>"myValue1"}, {"myKey2"=>"myValue2"}]])
|
75
|
+
{:name=>"cookie3", :value=>"33333", :domain=>".google.de", :path=>"/", :secure=>false}],
|
76
|
+
{"myKey1"=>"myValue1", "myKey2"=>"myValue2"}])
|
85
77
|
|
86
78
|
# cleanup:
|
87
79
|
FileUtils.rm file if (File.exists? file)
|
@@ -195,12 +187,12 @@ describe '#screeshot_recorder' do
|
|
195
187
|
lineup.resolutions('400')
|
196
188
|
lineup.wait_for_asynchron_pages(5)
|
197
189
|
lineup.use_phantomjs(true)
|
198
|
-
cookie =
|
190
|
+
cookie = [{"name" => "CONSENT",
|
199
191
|
"value" => "YES+DE.de+V7",
|
200
192
|
"domain" => ".google.de",
|
201
193
|
"path" => "/",
|
202
|
-
"secure" => false}
|
203
|
-
lineup.
|
194
|
+
"secure" => false}]
|
195
|
+
lineup.cookies(cookie)
|
204
196
|
|
205
197
|
lineup.record_screenshot('base')
|
206
198
|
lineup.record_screenshot('new')
|
@@ -225,13 +217,6 @@ describe '#screeshot_recorder' do
|
|
225
217
|
"use_phantomjs":true,
|
226
218
|
"difference_path":"screenshots/path/difference",
|
227
219
|
"wait_for_asynchron_pages":5,
|
228
|
-
"cookie_for_experiment":{
|
229
|
-
"name":"CONSENT",
|
230
|
-
"value":"YES+DE.de+V7",
|
231
|
-
"domain":".google.de",
|
232
|
-
"path":"/",
|
233
|
-
"secure":false
|
234
|
-
},
|
235
220
|
"cookies" : [{
|
236
221
|
"name":"cookie2",
|
237
222
|
"value":"22222",
|
@@ -277,7 +262,7 @@ describe '#screeshot_recorder' do
|
|
277
262
|
"use_phantomjs":true,
|
278
263
|
"difference_path":"screenshots/path/difference",
|
279
264
|
"wait_for_asynchron_pages":5,
|
280
|
-
"localStorage":
|
265
|
+
"localStorage": {"{\'mySpecialKey\'}":"{\'myvalue\':{\'value\':test,\'timestamp\':1467723066092}}"}
|
281
266
|
}'
|
282
267
|
save_json(json, file)
|
283
268
|
lineup = Lineup::Screenshot.new(BASE_URL)
|
@@ -302,7 +287,7 @@ describe '#screeshot_recorder' do
|
|
302
287
|
"use_phantomjs":true,
|
303
288
|
"difference_path":"screenshots/path/difference",
|
304
289
|
"wait_for_asynchron_pages":5,
|
305
|
-
"localStorage":
|
290
|
+
"localStorage":{"\'myKey\'":"{\'myValue\'}","myKey2":"myValue2"}
|
306
291
|
}'
|
307
292
|
save_json(json, file)
|
308
293
|
lineup = Lineup::Screenshot.new(BASE_URL)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lineup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Finn
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-07-
|
12
|
+
date: 2016-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|