vulture 1.0.0a → 1.0.1
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/vulture.rb +16 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab1c0b8ef4cae9c39fcf0cca526d0259f6a9a85b778ff02bc6857fd556d60322
|
4
|
+
data.tar.gz: a0775c686deea416155d117b4bbad1f586ef64b540611a5879defddd8a175e67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13673f540c542c56503e249ae14febdb26c2010a5b31e8c64566458d375cd0b1c154cc2153c3a5e3deb84d5f56d1ff65adaf2a3e163d16c1fd5cf97c3b9d652f
|
7
|
+
data.tar.gz: 94994cc6a6138848cebbd3024c00208227f74035a0a5253fc8a6a708acd8e416988f5549ef31c607f5a9b3bdd98a4acef97ca15986a1bfecdc9120cbc1f1f37a
|
data/vulture.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
|
2
3
|
require 'capybara'
|
3
4
|
require 'capybara/dsl'
|
4
5
|
require 'selenium-webdriver'
|
@@ -25,6 +26,9 @@ end
|
|
25
26
|
def compare_images(img1_path, img2_path, diff_output_path, threshold)
|
26
27
|
img1 = ChunkyPNG::Image.from_file(img1_path)
|
27
28
|
img2 = ChunkyPNG::Image.from_file(img2_path)
|
29
|
+
|
30
|
+
raise 'Images are not the same size!' unless img1.dimension == img2.dimension
|
31
|
+
|
28
32
|
diff = ChunkyPNG::Image.new(img1.width, img1.height, ChunkyPNG::Color::TRANSPARENT)
|
29
33
|
diff_count = 0
|
30
34
|
|
@@ -38,7 +42,7 @@ def compare_images(img1_path, img2_path, diff_output_path, threshold)
|
|
38
42
|
end
|
39
43
|
|
40
44
|
diff.save(diff_output_path)
|
41
|
-
diff_percentage = (diff_count.to_f / (img1.
|
45
|
+
diff_percentage = (diff_count.to_f / (img1.pixels.length)) * 100
|
42
46
|
|
43
47
|
puts "Comparison complete: #{diff_count} pixels differ (#{diff_percentage.round(2)}%)."
|
44
48
|
exit(1) if diff_percentage > threshold
|
@@ -50,25 +54,27 @@ def generate_report(diffs)
|
|
50
54
|
File.open('report.html', 'w') { |file| file.write(renderer.result(binding)) }
|
51
55
|
end
|
52
56
|
|
57
|
+
def formatted_path(base, resolution, url)
|
58
|
+
"#{base}/#{resolution}_#{url.gsub(%r{https?://}, '').gsub('/', '_')}.png"
|
59
|
+
end
|
60
|
+
|
53
61
|
if ARGV.length != 2
|
54
62
|
puts "Usage: vulture <url1> <url2>"
|
55
|
-
exit
|
63
|
+
exit(1)
|
56
64
|
end
|
57
65
|
|
58
|
-
url1 = ARGV
|
59
|
-
url2 = ARGV[1]
|
66
|
+
url1, url2 = ARGV
|
60
67
|
|
61
|
-
diffs = []
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
diff_path = "screenshots/diff/#{resolution}_#{url1.gsub(%r{https?://}, '').gsub('/', '_')}_diff.png"
|
68
|
+
diffs = config['resolutions'].map do |resolution|
|
69
|
+
baseline_path = formatted_path('screenshots/baseline', resolution, url1)
|
70
|
+
latest_path = formatted_path('screenshots/latest', resolution, url2)
|
71
|
+
diff_path = formatted_path('screenshots/diff', resolution, "#{url1}_diff")
|
66
72
|
|
67
73
|
capture_screenshot(url1, resolution, baseline_path)
|
68
74
|
capture_screenshot(url2, resolution, latest_path)
|
69
75
|
|
70
76
|
compare_images(baseline_path, latest_path, diff_path, config['threshold'])
|
71
|
-
|
77
|
+
{ url: url1, resolution: resolution, diff_path: diff_path }
|
72
78
|
end
|
73
79
|
|
74
80
|
generate_report(diffs)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vulture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zeusssz
|
@@ -121,9 +121,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- - "
|
124
|
+
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
126
|
+
version: '0'
|
127
127
|
requirements: []
|
128
128
|
rubygems_version: 3.3.27
|
129
129
|
signing_key:
|