invoca-utils 0.6.1 → 0.7.0.colin.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: 443126af15b2537b1e27e80293dc05c81304f30ddd26a1af189dc132a46d033e
4
- data.tar.gz: a0846a8f5c9d0b80b5204b08bdead40bb2730f2aa0addb926306cd9da51e50cf
3
+ metadata.gz: 97f9b98c54883da05a6cb68be4bfebd61b858d5f5da7f8374bec356ae38a23b3
4
+ data.tar.gz: a84b9901a7fe50a44036b5f4f4b24367f0530e632e580b91fc6ff0ecec93d3ac
5
5
  SHA512:
6
- metadata.gz: a178753bf9f95c9ba7b5ce2620b987dfd36aa618d7f0ec7660245d242d056a9512b3e7b51b19e45fb790c4159ecfafc910e7b00e6dbe792f005611557d39e555
7
- data.tar.gz: 84e20b7543da792234fe69b90046023d05e3fb24ca109717997b644a6075a05aada044b4f321347d6aa08ec0cd20b911bbb5e3eac5aabb2df90022f8fac95007
6
+ metadata.gz: b69462e99f162f2e22ea4444754ca04e8f42a34ac98aa60ba888d1bd4f6feec83b263ea6f2a0ffbd21f6384446625cf891aebcf191de32a9f34d556af9cd99d9
7
+ data.tar.gz: f6b637a19e6e0fa9ec3bd4ab20950d356a76e4cbae4d4251c2831d18fe718bd06c20e20fcbe7cc96fb6396b21d7ad7c3d21860f8fe42ae38887c45614c1d0c26
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.6
1
+ 3.3.8
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.1.6
1
+ 3.3.8
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
5
  **Note:** This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.7.0] - UNRELEASED
8
+ ### Removed
9
+ - Global `Diff` and `Diffable` constants; use `Invoca::Utils::Diff` and `Invoca::Utils::Diffable` instead
10
+ - Runtime dependency on `diff-lcs`; callers needing `Diff::LCS` should depend on and require `diff-lcs` directly
11
+
7
12
  ## [0.6.1] - 2025-03-27
8
13
  ### Fixed
9
14
  - Fixed a global namespace collision with diff-lcs over the `Diff` constant
@@ -49,10 +54,3 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
49
54
  ### Added
50
55
  - Enumerable::build_hash method ported from HoboSupport
51
56
  - Enumerable::* operator ported from HoboSupport
52
-
53
- [0.5.1]: https://github.com/Invoca/invoca-utils/compare/v0.5.0...v0.5.1
54
- [0.5.0]: https://github.com/Invoca/invoca-utils/compare/v0.4.1...v0.5.0
55
- [0.4.1]: https://github.com/Invoca/invoca-utils/compare/v0.4.0...v0.4.1
56
- [0.4.0]: https://github.com/Invoca/invoca-utils/compare/v0.3.0...v0.4.0
57
- [0.3.0]: https://github.com/Invoca/invoca-utils/compare/v0.2.0...v0.3.0
58
- [0.2.0]: https://github.com/Invoca/invoca-utils/compare/v0.1.1...v0.2.0
data/Gemfile.lock CHANGED
@@ -1,9 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- invoca-utils (0.6.1)
4
+ invoca-utils (0.7.0.colin.1)
5
5
  activesupport (>= 6.0)
6
- diff-lcs (>= 1.6.1)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
data/invoca-utils.gemspec CHANGED
@@ -29,7 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.required_ruby_version = ">= 3.1"
30
30
 
31
31
  spec.add_dependency "activesupport", ">= 6.0"
32
- spec.add_dependency "diff-lcs", ">= 1.6.1"
33
32
 
34
33
  # Specify this gem's development and test dependencies in Gemfile
35
34
  end
@@ -2,14 +2,10 @@
2
2
 
3
3
  # adapted from http://users.cybercity.dk/~dsl8950/ruby/diff-0.3.tar.gz
4
4
 
5
- require "diff/lcs"
6
-
7
5
  module Invoca
8
6
  module Utils
9
7
  class Diff
10
8
 
11
- LCS = ::Diff::LCS
12
-
13
9
  VERSION = 0.3
14
10
 
15
11
  def self.lcs(a, b)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Invoca
4
4
  module Utils
5
- VERSION = "0.6.1"
5
+ VERSION = "0.7.0.colin.1"
6
6
  end
7
7
  end
data/lib/invoca/utils.rb CHANGED
@@ -19,9 +19,3 @@ require "invoca/utils/time"
19
19
  require "invoca/utils/exceptions"
20
20
  require "invoca/utils/guaranteed_utf8_string"
21
21
  require "invoca/utils/version"
22
-
23
- Diff = Invoca::Utils::Diff
24
-
25
- unless defined?(Diffable)
26
- Diffable = Invoca::Utils::Diffable
27
- end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ describe Invoca::Utils::Diff do
6
+ describe ".compare" do
7
+ it "does nothing when identical" do
8
+ expect(described_class.compare(['a', 'b'], ['a', 'b'])).to eq('')
9
+ end
10
+
11
+ it "detects additions" do
12
+ expect(described_class.compare(['a', 'c'], ['a', 'b', 'c'])).to eq(
13
+ " a\n+ b\n c\n"
14
+ )
15
+ end
16
+
17
+ it "detects additions at the front" do
18
+ expect(described_class.compare(['b', 'c'], ['a', 'b', 'c'])).to eq(
19
+ "+ a\n b\n c\n"
20
+ )
21
+ end
22
+
23
+ it "detects additions at the end" do
24
+ expect(described_class.compare(['a', 'b'], ['a', 'b', 'c'])).to eq(
25
+ " a\n b\n+ c\n"
26
+ )
27
+ end
28
+
29
+ it "detects deletions" do
30
+ expect(described_class.compare(['a', 'b', 'c'], ['a', 'c'])).to eq(
31
+ " a\n- b\n c\n"
32
+ )
33
+ end
34
+
35
+ it "detects deletions at the front" do
36
+ expect(described_class.compare(['a', 'b', 'c'], ['b', 'c'])).to eq(
37
+ "- a\n b\n c\n"
38
+ )
39
+ end
40
+
41
+ it "detects deletions at the end" do
42
+ expect(described_class.compare(['a', 'b', 'c'], ['a', 'b'])).to eq(
43
+ " a\n b\n- c\n"
44
+ )
45
+ end
46
+
47
+ it "detects changes" do
48
+ expect(described_class.compare(['a', 'b1', 'c'], ['a', 'b2', 'c'])).to eq(
49
+ " a\n- b1\n+ b2\n c\n"
50
+ )
51
+ end
52
+
53
+ it "detects changes at the front" do
54
+ expect(described_class.compare(['a1', 'b', 'c'], ['a2', 'b', 'c'])).to eq(
55
+ "- a1\n+ a2\n b\n c\n"
56
+ )
57
+ end
58
+
59
+ it "detects changes at the end" do
60
+ expect(described_class.compare(['a', 'b', 'c1'], ['a', 'b', 'c2'])).to eq(
61
+ " a\n b\n- c1\n+ c2\n"
62
+ )
63
+ end
64
+
65
+ it "detects multi-line changes" do
66
+ expect(described_class.compare(['a', 'b1', 'b2', 'd'], ['a', 'c', 'd'])).to eq(
67
+ " a\n- b1\n- b2\n+ c\n d\n"
68
+ )
69
+ end
70
+
71
+ it "detects multi-line changes at the front" do
72
+ expect(described_class.compare(['a1', 'b1', 'd'], ['a2', 'b2', 'b3', 'd'])).to eq(
73
+ "- a1\n- b1\n+ a2\n+ b2\n+ b3\n d\n"
74
+ )
75
+ end
76
+
77
+ it "detects multi-line changes at the end" do
78
+ expect(described_class.compare(['a', 'b', 'd1'], ['a', 'b', 'd2', 'd3'])).to eq(
79
+ " a\n b\n- d1\n+ d2\n+ d3\n"
80
+ )
81
+ end
82
+
83
+ it "uses inspect on complex data types and includes nested diff" do
84
+ expect(described_class.compare(['a', 'b', [1, 2]], ['a', 'b', [1, 2, 3], 'c'])).to eq(
85
+ " a\n b\n- [1, 2]\nNested array diff:\n 1\n 2\n+ 3\n\n+ [1, 2, 3]\n+ c\n"
86
+ )
87
+ end
88
+
89
+ it "includes nested diff on array of hashes" do
90
+ output = described_class.compare(
91
+ ['a', 'b', { a: 1, b: 2 }],
92
+ ['a', 'b', { a: 1, b: 5, c: 3 }]
93
+ )
94
+
95
+ expect(output).to match(/\- \{.*\}/)
96
+ expect(output).to include("Nested hash diff:")
97
+ expect(output).to include("[:b] expected 2, was 5")
98
+ expect(output).to include("[:c] not expected, was 3")
99
+ expect(output).to match(/\+ \{.*\}/)
100
+ end
101
+ end
102
+ end
@@ -1,55 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../spec_helper'
4
- require_relative '../helpers/constant_overrides'
5
4
 
6
5
  describe Invoca::Utils do
7
- include ConstantOverrides
8
-
9
- context "global namespace issues" do
10
- before do
11
- setup_constant_overrides
12
- end
13
-
14
- after do
15
- cleanup_constant_overrides
16
- end
17
-
18
- it "define Diff as Invoca::Utils::Diff" do
19
- expect(Invoca::Utils::Diff).to eq(::Diff)
20
- end
21
-
22
- it "define Diffable as Diffable" do
23
- expect(Invoca::Utils::Diffable).to eq(::Diffable)
24
- end
25
-
26
- context "when Diff is defined in the global namespace" do
27
- before do
28
- @class = Class.new
29
- set_test_const("Diff", @class)
30
- load 'invoca/utils.rb'
31
- end
32
-
33
- it "define Diff as Invoca::Utils::Diff" do
34
- expect(Invoca::Utils::Diff).to eq(::Diff)
35
- end
36
-
37
- it "still allows access to diff-lcs methods" do
38
- expect(defined?(Diff::LCS)).to eq("constant")
39
- expect(Diff::LCS).to respond_to(:diff)
40
- end
41
- end
42
-
43
- context "when Diffable is defined in the global namespace" do
44
- before do
45
- @class = Class.new
46
- set_test_const("Diffable", @class)
47
- load 'invoca/utils.rb'
48
- end
6
+ it "does not define Diff in the global namespace" do
7
+ expect(Object.const_defined?(:Diff)).to be(false)
8
+ end
49
9
 
50
- it "define Diffable as Invoca::Utils::Diffable" do
51
- expect(@class).to eq(::Diffable)
52
- end
53
- end
10
+ it "does not define Diffable in the global namespace" do
11
+ expect(Object.const_defined?(:Diffable)).to be(false)
54
12
  end
55
13
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invoca-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0.colin.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca development
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-03-27 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -24,20 +23,6 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '6.0'
27
- - !ruby/object:Gem::Dependency
28
- name: diff-lcs
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.6.1
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 1.6.1
41
26
  description: A public collection of helpers used in multiple projects
42
27
  email:
43
28
  - development@invoca.com
@@ -81,9 +66,9 @@ files:
81
66
  - lib/invoca/utils/stable_sort.rb
82
67
  - lib/invoca/utils/time.rb
83
68
  - lib/invoca/utils/version.rb
84
- - spec/helpers/constant_overrides.rb
85
69
  - spec/spec_helper.rb
86
70
  - spec/unit/array_spec.rb
71
+ - spec/unit/diff_spec.rb
87
72
  - spec/unit/enumerable_spec.rb
88
73
  - spec/unit/exceptions_spec.rb
89
74
  - spec/unit/guaranteed_utf8_string_spec.rb
@@ -100,7 +85,6 @@ licenses:
100
85
  - MIT
101
86
  metadata:
102
87
  allowed_push_host: https://rubygems.org
103
- post_install_message:
104
88
  rdoc_options: []
105
89
  require_paths:
106
90
  - lib
@@ -115,14 +99,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
99
  - !ruby/object:Gem::Version
116
100
  version: '0'
117
101
  requirements: []
118
- rubygems_version: 3.3.27
119
- signing_key:
102
+ rubygems_version: 3.6.8
120
103
  specification_version: 4
121
104
  summary: A public collection of helpers used in multiple projects
122
105
  test_files:
123
- - spec/helpers/constant_overrides.rb
124
106
  - spec/spec_helper.rb
125
107
  - spec/unit/array_spec.rb
108
+ - spec/unit/diff_spec.rb
126
109
  - spec/unit/enumerable_spec.rb
127
110
  - spec/unit/exceptions_spec.rb
128
111
  - spec/unit/guaranteed_utf8_string_spec.rb
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # The same as https://github.com/Invoca/test_overrides/blob/master/lib/constant_overrides.rb,
4
- # but less coupled to ExceptionHandling and Invoca microservices.
5
-
6
- module ConstantOverrides
7
- def setup_constant_overrides
8
- @constant_overrides = []
9
- end
10
-
11
- def cleanup_constant_overrides
12
- @constant_overrides.reverse.each do |parent_module, k, v|
13
- silence_warnings do
14
- if v == :never_defined
15
- parent_module.send(:remove_const, k)
16
- else
17
- parent_module.const_set(k, v)
18
- end
19
- end
20
- end
21
- end
22
-
23
- def set_test_const(const_name, value)
24
- const_name.is_a?(Symbol) and (const_name = const_name.to_s)
25
- const_name.is_a?(String) or raise "Pass the constant name, not its value!"
26
-
27
- final_parent_module = final_const_name = nil
28
- original_value =
29
- const_name.split('::').reduce(Object) do |parent_module, nested_const_name|
30
- parent_module == :never_defined and raise "You need to set each parent constant earlier! #{nested_const_name}"
31
- final_parent_module = parent_module
32
- final_const_name = nested_const_name
33
- begin
34
- parent_module.const_get(nested_const_name)
35
- rescue
36
- :never_defined
37
- end
38
- end
39
-
40
- @constant_overrides << [final_parent_module, final_const_name, original_value]
41
-
42
- silence_warnings { final_parent_module.const_set(final_const_name, value) }
43
- end
44
- end