assay 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1cd843e332e66543d082f330bfe235b485adcb0108922705bbffe4f464d3357
4
- data.tar.gz: 9b709e135cf23e1528c9f3af28dcb6c0a4ac5e084ede0099104be81ab68890ed
3
+ metadata.gz: c35151f3b2a465e249b0700fe61389803993e32bd5803e46ae9951145836c392
4
+ data.tar.gz: 4c250ff84fb21cb015d915c5e3b29586f66c398b12f406df1fe83f4cac21c95d
5
5
  SHA512:
6
- metadata.gz: b5f0f62e5ad8b60e6a1722d51d6039a12f470b8a85c84c9d17eba961a099ecefd21fb8ebe519782f4aa4393ccf1a0ece2c656f02aefe0708623041f51bb0303b
7
- data.tar.gz: ac391305763a9894254489aa7d72d0bd4f3f39d49d6580114652046ff492301f078923f4eca0a29dfde9e11b39fdbb457a476f3abe70252cb296838d102c48b4
6
+ metadata.gz: c8cdd4af975c2ca97bf3369ab6f25ac4290d26f70cdc8074c685f24f875f41aaf4e2f64d116050ee9ebb913161f69bdfed6eb24ad0d5741cfb01f52122d69c18
7
+ data.tar.gz: 10f2e587dbe381a251389ce957178a30068b1dc212b3c44d2f19f0a6c7b817be0d94da68963a374ca85e6b57999a5549b3e86badb81457647add22e4423dc3d7
data/HISTORY.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # HISTORY
2
2
 
3
+ ## 0.5.1 | 2026-11-24
4
+
5
+ * Fix a `NameError` (`uninitialized constant ANSI::Diff`) raised in
6
+ place of a failed comparison when the values are long and color is
7
+ on but was not turned on with `Assay.color = true`. That is the usual
8
+ case under Rubytest, since the ANSI gem turns color on when it loads.
9
+ It affected `EqualAssay`, `UnequalAssay` and the AE notation.
10
+
3
11
  ## 0.5.0 | 2026-11-23
4
12
 
5
13
  Assay is one library again. The notations that were spun off as separate
@@ -417,9 +417,7 @@ module Assay::AE
417
417
  operator = COMPARISON_OPERATORS[operator] if @negated
418
418
  if a.size > 13 or b.size > 13
419
419
  if defined?($ansi) && $ansi && a.size * b.size <= DIFF_LIMIT
420
- diff = ::ANSI::Diff.new(a,b)
421
- a = diff.diff1
422
- b = diff.diff2
420
+ a, b = ::Assay.color_diff(a, b)
423
421
  end
424
422
  "a #{operator} b\na) " + a + "\nb) " + b
425
423
  else
@@ -22,8 +22,7 @@ class EqualAssay < LikeAssay
22
22
 
23
23
  if a.size > SIZE_LIMIT or b.size > SIZE_LIMIT
24
24
  if $ansi
25
- d = ANSI::Diff.new(a, b)
26
- a, b = d.diff1, d.diff2 # *d.to_a
25
+ a, b = Assay.color_diff(a, b)
27
26
  end
28
27
  "a == b\na) #{a}\nb) #{b}"
29
28
  else
@@ -24,8 +24,7 @@ class UnequalAssay < EqualAssay
24
24
 
25
25
  if a.size > SIZE_LIMIT or b.size > SIZE_LIMIT
26
26
  if $ansi
27
- d = ANSI::Diff.new(a, b)
28
- a, b = d.diff1, d.diff2 # *d.to_a
27
+ a, b = Assay.color_diff(a, b)
29
28
  end
30
29
  "a != b\na) #{a}\nb) #{b}"
31
30
  else
data/lib/assay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Assay
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
data/lib/assay.rb CHANGED
@@ -34,6 +34,20 @@ module Assay
34
34
  end
35
35
  end
36
36
 
37
+ #
38
+ # Two inspected values with the differences between them colored, for
39
+ # failure messages when color is on. Color can be turned on from
40
+ # outside Assay (the ANSI gem sets `$ansi` when it loads), so the diff
41
+ # library is loaded here, where it is used.
42
+ #
43
+ # @return [Array<String>] the two values, colored
44
+ #
45
+ def self.color_diff(a, b)
46
+ require 'ansi/diff'
47
+ diff = ::ANSI::Diff.new(a, b)
48
+ return diff.diff1, diff.diff2
49
+ end
50
+
37
51
  #
38
52
  # Lookup assay class by operator or name.
39
53
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Sawyer