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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/vulture.rb +16 -10
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1ebd96f1d894309b29f50810621af5b69fc25673ac74b080c76560748d3eb4b
4
- data.tar.gz: '0986065eb99b0fe08b51a749b78f6493d91f5c29fcf308d84ff8f4fd67e92db3'
3
+ metadata.gz: ab1c0b8ef4cae9c39fcf0cca526d0259f6a9a85b778ff02bc6857fd556d60322
4
+ data.tar.gz: a0775c686deea416155d117b4bbad1f586ef64b540611a5879defddd8a175e67
5
5
  SHA512:
6
- metadata.gz: 03d829a45e25384a4c29f97ce5219c9d4194a6c3b68effa6773b5bb51f34406095339805c4ae5cd72741c844cbfc4e85bf36f39fe3626f4d33ebdf3f6b6e746c
7
- data.tar.gz: 43cf87860b11276bc160195ad7790efa5760bc69e00e6e5e0960e6f974d8d7dcaf7684ee0938b371ef6172ffe3b32919b2d1a556cbb1220891fdbe8724f44a68
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.width * img1.height)) * 100
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[0]
59
- url2 = ARGV[1]
66
+ url1, url2 = ARGV
60
67
 
61
- diffs = []
62
- config['resolutions'].each do |resolution|
63
- baseline_path = "screenshots/baseline/#{resolution}_#{url1.gsub(%r{https?://}, '').gsub('/', '_')}.png"
64
- latest_path = "screenshots/latest/#{resolution}_#{url2.gsub(%r{https?://}, '').gsub('/', '_')}.png"
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
- diffs << { url: url1, resolution: resolution, diff_path: diff_path }
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.0a
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: 1.3.1
126
+ version: '0'
127
127
  requirements: []
128
128
  rubygems_version: 3.3.27
129
129
  signing_key: