lookalike 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2645f700c7b5a4b5bbb496882b5e3d6f02462865ec7aea872b35936301370a85
4
- data.tar.gz: 11732e15fbec818a7722b64a804a7a04364ca66ebe8d2c96a933d97d8117b95c
3
+ metadata.gz: 5b5401fb8f02a4e3af866911c0bec40212ad6a241839ee561cb273ac67ba96a0
4
+ data.tar.gz: d874ba4ad915dd18b0980ae1924b6da2438b4d6180ab6cbc92540a10aaf94f22
5
5
  SHA512:
6
- metadata.gz: 25bc7d90ac6a7006e4708216342257d05bc233945ebccec94e98f8ce2499ef83493ed3a5122ed46a81ee158369b2ff0f98f687542e3db04a2147c80577237299
7
- data.tar.gz: 1ea8c34a7656597dce2bf9cde88e4209cb3361cdb71a3e906f8225421970669dde8fca1e7fdea3bb925fec83dc4ba2f396946355306b0fccd3e3e0848358cb73
6
+ metadata.gz: 4784115319d7eaca61d9f46a12d51f39bfb8467821c84cd5d1678388f63f3ba10f7849b9019d7e8405e0e3107b8de4f103d8d680baef68a2350af0b115f4e29e
7
+ data.tar.gz: f17eb39d22e355a1ebfae7ce0051aae7b2eac264914b17d06493736204450e47affc18f84228955cc33f4c397f2c4c54a3acfba8465c3b88f8a257769c24590d
data/.codespellignore ADDED
File without changes
data/.yamllint ADDED
@@ -0,0 +1,16 @@
1
+ extends: default
2
+ ignore: |
3
+ build/
4
+ node_modules/
5
+ runtime/build/
6
+ tmp/
7
+ **/*.dSYM/**
8
+
9
+ rules:
10
+ comments:
11
+ min-spaces-from-content: 1
12
+ document-start: disable
13
+ line-length:
14
+ max: 200
15
+ truthy:
16
+ check-keys: false
data/CHANGELOG.md CHANGED
@@ -2,10 +2,14 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.1.2] - 2026-09-26
6
+
7
+ - Count image size differences once and keep snapshot report files distinct.
8
+ - Reject non-finite comparison thresholds.
9
+
5
10
  ## [0.1.1] - 2026-09-25
6
11
 
7
- - Correct the gem author and license attribution.
8
- - Bound the Tessel dependency to compatible major versions.
12
+ - Prevent installation with unsupported major versions of Tessel.
9
13
 
10
14
  ## [0.1.0] - 2026-09-23
11
15
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lookalike
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/lookalike.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "json"
4
4
  require "erb"
5
+ require "digest"
5
6
  require "fileutils"
6
7
  require "tessel"
7
8
 
@@ -261,7 +262,7 @@ module Lookalike
261
262
  max_delta = Integer(max_delta)
262
263
  raise ArgumentError, "max delta must be between 0 and 255" unless max_delta.between?(0, 255)
263
264
  threshold = Float(threshold)
264
- raise ArgumentError, "threshold must not be negative" if threshold.negative?
265
+ raise ArgumentError, "threshold must be finite and non-negative" unless threshold.finite? && !threshold.negative?
265
266
  expected = Input.normalize(expected)
266
267
  actual = Input.normalize(actual)
267
268
  unless expected.width == actual.width && expected.height == actual.height
@@ -271,11 +272,16 @@ module Lookalike
271
272
  padded_actual = Tessel::Image.new(width, height)
272
273
  padded_expected.blit(expected, 0, 0, blend: :copy)
273
274
  padded_actual.blit(actual, 0, 0, blend: :copy)
275
+ overlap_width = [expected.width, actual.width].min
276
+ overlap_height = [expected.height, actual.height].min
277
+ shared_expected = expected.crop(0, 0, overlap_width, overlap_height)
278
+ shared_actual = actual.crop(0, 0, overlap_width, overlap_height)
274
279
  _matched, diff, maximum, box = if mode == :channel
275
- Metrics::Channel.compare(padded_expected, padded_actual, max_delta: max_delta, allowed_pixels: allowed_pixels)
280
+ Metrics::Channel.compare(shared_expected, shared_actual, max_delta: max_delta, allowed_pixels: allowed_pixels)
276
281
  else
277
- Metrics::YIQ.compare(padded_expected, padded_actual, threshold: threshold, allowed_pixels: allowed_pixels, ignore_antialiasing: ignore_antialiasing)
282
+ Metrics::YIQ.compare(shared_expected, shared_actual, threshold: threshold, allowed_pixels: allowed_pixels, ignore_antialiasing: ignore_antialiasing)
278
283
  end
284
+ diff_image = DiffRenderer.render(padded_expected, padded_actual, mode: mode, threshold: threshold, max_delta: max_delta, ignore_antialiasing: ignore_antialiasing)
279
285
  dimension_box = nil
280
286
  dimension_diff = 0
281
287
  (0...height).each do |y|
@@ -283,6 +289,7 @@ module Lookalike
283
289
  next if x < expected.width && y < expected.height && x < actual.width && y < actual.height
284
290
 
285
291
  dimension_diff += 1
292
+ diff_image[x, y] = [255, 0, 0, 255]
286
293
  if dimension_box
287
294
  x0 = [dimension_box[0], x].min
288
295
  y0 = [dimension_box[1], y].min
@@ -307,7 +314,6 @@ module Lookalike
307
314
  box = dimension_box
308
315
  end
309
316
  end
310
- diff_image = DiffRenderer.render(padded_expected, padded_actual, mode: mode, threshold: threshold, max_delta: max_delta)
311
317
  return Result.new(expected: expected, actual: actual, diff_pixels: diff, max_delta: maximum, bounding_box: box, diff_image: diff_image, mode: mode, matched: false)
312
318
  end
313
319
  return Result.new(expected: expected, actual: actual, diff_pixels: 0, max_delta: 0, bounding_box: nil, diff_image: nil, mode: mode, matched: true) if expected.bytes == actual.bytes
@@ -370,8 +376,7 @@ module Lookalike
370
376
  end
371
377
 
372
378
  def record_result(name, result, status:, variant: nil, expected_path:, actual_path:, diff_path: nil)
373
- relative = Store.new(config).send(:safe_name, name).tr("/", "__")
374
- relative = "#{relative}@#{variant}" if variant
379
+ relative = Digest::SHA256.hexdigest(JSON.generate([Store.new(config).send(:safe_name, name), variant&.to_s]))
375
380
  directory = File.join(config.output_dir, "results")
376
381
  FileUtils.mkdir_p(directory)
377
382
  payload = result.to_h.merge("name" => name.to_s, "variant" => variant&.to_s, "status" => status,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookalike
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yudai Takada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-25 00:00:00.000000000 Z
11
+ date: 2026-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tessel
@@ -38,6 +38,8 @@ executables:
38
38
  extensions: []
39
39
  extra_rdoc_files: []
40
40
  files:
41
+ - ".codespellignore"
42
+ - ".yamllint"
41
43
  - CHANGELOG.md
42
44
  - LICENSE.txt
43
45
  - README.md