invoca-utils 0.6.0 → 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: 0c4c3ce7e8a1dbe52aa8ab6c6614d9bc2b6ba8ac2e3f04adf233454cb535128b
4
- data.tar.gz: b604d11003c903c70b0e63646c87547a426d5af1dec8fdfabff802e4c4ceb8f7
3
+ metadata.gz: 97f9b98c54883da05a6cb68be4bfebd61b858d5f5da7f8374bec356ae38a23b3
4
+ data.tar.gz: a84b9901a7fe50a44036b5f4f4b24367f0530e632e580b91fc6ff0ecec93d3ac
5
5
  SHA512:
6
- metadata.gz: 655134641dc1abd112340418b18c7a1910adf662230f9bfff997de68c03ca70835186beae2ec243a1061d3ce8bec4302dc942f402b798af13034a389c0170223
7
- data.tar.gz: e621f9c450234d24d5725f5186e159cfa6e6ea620c45ccd255202f8de00e2cccfc7baf10bbcc90b223c31fdc2c91e1ddac591808bf5f0939b5c1c75a4b020e91
6
+ metadata.gz: b69462e99f162f2e22ea4444754ca04e8f42a34ac98aa60ba888d1bd4f6feec83b263ea6f2a0ffbd21f6384446625cf891aebcf191de32a9f34d556af9cd99d9
7
+ data.tar.gz: f6b637a19e6e0fa9ec3bd4ab20950d356a76e4cbae4d4251c2831d18fe718bd06c20e20fcbe7cc96fb6396b21d7ad7c3d21860f8fe42ae38887c45614c1d0c26
@@ -1,36 +1,8 @@
1
- ---
2
1
  name: Pipeline
3
-
4
- on: [push]
5
-
2
+ on:
3
+ push:
4
+ schedule:
5
+ - cron: '0 1 * * 1' # Every Monday at 1AM UTC
6
6
  jobs:
7
7
  tests:
8
- runs-on: ubuntu-latest
9
-
10
- strategy:
11
- fail-fast: false
12
- matrix:
13
- ruby: [3.1, 3.2, 3.3]
14
- gemfile:
15
- - Gemfile
16
- - gemfiles/activesupport_6_0.gemfile
17
- - gemfiles/activesupport_6_1.gemfile
18
- - gemfiles/activesupport_7_0.gemfile
19
- - gemfiles/activesupport_7_1.gemfile
20
-
21
- env:
22
- BUNDLE_GEMFILE: ${{ matrix.gemfile }}
23
-
24
- name: Unit Tests (${{ matrix.ruby }} - ${{ matrix.gemfile }})
25
-
26
- steps:
27
- - name: Check out
28
- uses: actions/checkout@v2
29
- - name: Set up Ruby ${{ matrix.ruby }}
30
- uses: ruby/setup-ruby@v1
31
- with:
32
- ruby-version: ${{ matrix.ruby }}
33
- bundler: 2.2.29
34
- bundler-cache: true
35
- - name: Run Tests
36
- run: bundle exec rspec
8
+ uses: Invoca/ruby-test-matrix-workflow/.github/workflows/ruby-test-matrix.yml@main
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/Appraisals CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'appraisal/matrix'
4
4
 
5
- appraisal_matrix(activesupport: "6.0")
5
+ appraisal_matrix(activesupport: "7.0")
data/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ 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
+
12
+ ## [0.6.1] - 2025-03-27
13
+ ### Fixed
14
+ - Fixed a global namespace collision with diff-lcs over the `Diff` constant
15
+
16
+ ### Added
17
+ - Loading `invoca/utils/diff` now gives access to both `invoca-utils` and `diff-lcs` diff helpers
18
+
7
19
  ## [0.6.0] - 2024-07-10
8
20
  ### Added
9
21
  - Require Ruby > 3.1
@@ -42,10 +54,3 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
42
54
  ### Added
43
55
  - Enumerable::build_hash method ported from HoboSupport
44
56
  - Enumerable::* operator ported from HoboSupport
45
-
46
- [0.5.1]: https://github.com/Invoca/invoca-utils/compare/v0.5.0...v0.5.1
47
- [0.5.0]: https://github.com/Invoca/invoca-utils/compare/v0.4.1...v0.5.0
48
- [0.4.1]: https://github.com/Invoca/invoca-utils/compare/v0.4.0...v0.4.1
49
- [0.4.0]: https://github.com/Invoca/invoca-utils/compare/v0.3.0...v0.4.0
50
- [0.3.0]: https://github.com/Invoca/invoca-utils/compare/v0.2.0...v0.3.0
51
- [0.2.0]: https://github.com/Invoca/invoca-utils/compare/v0.1.1...v0.2.0
data/Gemfile CHANGED
@@ -14,3 +14,10 @@ gem "rspec_junit_formatter", "~> 0.4"
14
14
  # minitest, which is a transitive dependency of activesupport,
15
15
  # version should support ruby 2.5 which is the minimum github pipeline targets
16
16
  gem "minitest", "~> 5.10.0"
17
+
18
+
19
+ gem "concurrent-ruby", "~> 1.3", "< 1.3.5"
20
+
21
+ gem "base64", ">= 0.2.0"
22
+ gem "bigdecimal", ">= 3.1"
23
+ gem "mutex_m", ">= 0.2.0"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- invoca-utils (0.6.0)
4
+ invoca-utils (0.7.0.colin.1)
5
5
  activesupport (>= 6.0)
6
6
 
7
7
  GEM
@@ -27,7 +27,7 @@ GEM
27
27
  bigdecimal (3.1.8)
28
28
  concurrent-ruby (1.3.3)
29
29
  connection_pool (2.4.1)
30
- diff-lcs (1.5.1)
30
+ diff-lcs (1.6.1)
31
31
  drb (2.2.1)
32
32
  i18n (1.14.5)
33
33
  concurrent-ruby (~> 1.0)
@@ -40,7 +40,7 @@ GEM
40
40
  rspec-mocks (~> 3.13.0)
41
41
  rspec-core (3.13.0)
42
42
  rspec-support (~> 3.13.0)
43
- rspec-expectations (3.13.1)
43
+ rspec-expectations (3.13.3)
44
44
  diff-lcs (>= 1.2.0, < 2.0)
45
45
  rspec-support (~> 3.13.0)
46
46
  rspec-mocks (3.13.1)
@@ -61,11 +61,15 @@ PLATFORMS
61
61
  DEPENDENCIES
62
62
  appraisal (~> 2.4)
63
63
  appraisal-matrix
64
+ base64 (>= 0.2.0)
65
+ bigdecimal (>= 3.1)
66
+ concurrent-ruby (~> 1.3, < 1.3.5)
64
67
  invoca-utils!
65
68
  minitest (~> 5.10.0)
69
+ mutex_m (>= 0.2.0)
66
70
  rake (~> 13.0)
67
71
  rspec (~> 3.0)
68
72
  rspec_junit_formatter (~> 0.4)
69
73
 
70
74
  BUNDLED WITH
71
- 2.2.29
75
+ 2.6.3
data/catalog-info.yaml CHANGED
@@ -19,6 +19,8 @@ metadata:
19
19
  tags:
20
20
  - ruby
21
21
  - gem
22
+ - public
23
+ - rails-dependent
22
24
  annotations:
23
25
  buildkite.com/project-slug: Invoca/invoca-utils
24
26
  github.com/project-slug: Invoca/invoca-utils
@@ -8,6 +8,10 @@ gem "rake", "~> 13.0"
8
8
  gem "rspec", "~> 3.0"
9
9
  gem "rspec_junit_formatter", "~> 0.4"
10
10
  gem "minitest", "~> 5.10.0"
11
+ gem "concurrent-ruby", "~> 1.3", "< 1.3.5"
12
+ gem "base64", ">= 0.2.0"
13
+ gem "bigdecimal", ">= 3.1"
14
+ gem "mutex_m", ">= 0.2.0"
11
15
  gem "activesupport", "~> 7.0.0"
12
16
 
13
17
  gemspec path: "../"
@@ -8,6 +8,10 @@ gem "rake", "~> 13.0"
8
8
  gem "rspec", "~> 3.0"
9
9
  gem "rspec_junit_formatter", "~> 0.4"
10
10
  gem "minitest", "~> 5.10.0"
11
+ gem "concurrent-ruby", "~> 1.3", "< 1.3.5"
12
+ gem "base64", ">= 0.2.0"
13
+ gem "bigdecimal", ">= 3.1"
14
+ gem "mutex_m", ">= 0.2.0"
11
15
  gem "activesupport", "~> 7.1.0"
12
16
 
13
17
  gemspec path: "../"
@@ -8,6 +8,10 @@ gem "rake", "~> 13.0"
8
8
  gem "rspec", "~> 3.0"
9
9
  gem "rspec_junit_formatter", "~> 0.4"
10
10
  gem "minitest", "~> 5.10.0"
11
- gem "activesupport", "~> 6.0.0"
11
+ gem "concurrent-ruby", "~> 1.3", "< 1.3.5"
12
+ gem "base64", ">= 0.2.0"
13
+ gem "bigdecimal", ">= 3.1"
14
+ gem "mutex_m", ">= 0.2.0"
15
+ gem "activesupport", "~> 7.2.0"
12
16
 
13
17
  gemspec path: "../"
@@ -8,6 +8,10 @@ gem "rake", "~> 13.0"
8
8
  gem "rspec", "~> 3.0"
9
9
  gem "rspec_junit_formatter", "~> 0.4"
10
10
  gem "minitest", "~> 5.10.0"
11
- gem "activesupport", "~> 6.1.0"
11
+ gem "concurrent-ruby", "~> 1.3", "< 1.3.5"
12
+ gem "base64", ">= 0.2.0"
13
+ gem "bigdecimal", ">= 3.1"
14
+ gem "mutex_m", ">= 0.2.0"
15
+ gem "activesupport", "~> 8.0.0"
12
16
 
13
17
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Invoca
4
4
  module Utils
5
- VERSION = "0.6.0"
5
+ VERSION = "0.7.0.colin.1"
6
6
  end
7
7
  end
data/lib/invoca/utils.rb CHANGED
@@ -19,11 +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
- unless defined?(Diff)
24
- Diff = Invoca::Utils::Diff
25
- end
26
-
27
- unless defined?(Diffable)
28
- Diffable = Invoca::Utils::Diffable
29
- 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,50 +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 "not define Diff as Invoca::Utils::Diff" do
34
- expect(@class).to eq(::Diff)
35
- end
36
- end
37
-
38
- context "when Diffable is defined in the global namespace" do
39
- before do
40
- @class = Class.new
41
- set_test_const("Diffable", @class)
42
- load 'invoca/utils.rb'
43
- end
6
+ it "does not define Diff in the global namespace" do
7
+ expect(Object.const_defined?(:Diff)).to be(false)
8
+ end
44
9
 
45
- it "define Diffable as Invoca::Utils::Diffable" do
46
- expect(@class).to eq(::Diffable)
47
- end
48
- end
10
+ it "does not define Diffable in the global namespace" do
11
+ expect(Object.const_defined?(:Diffable)).to be(false)
49
12
  end
50
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.0
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: 2024-07-10 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
@@ -46,11 +45,10 @@ files:
46
45
  - README.md
47
46
  - Rakefile
48
47
  - catalog-info.yaml
49
- - gemfiles/activesupport_6_0.gemfile
50
- - gemfiles/activesupport_6_1.gemfile
51
- - gemfiles/activesupport_7.gemfile
52
48
  - gemfiles/activesupport_7_0.gemfile
53
49
  - gemfiles/activesupport_7_1.gemfile
50
+ - gemfiles/activesupport_7_2.gemfile
51
+ - gemfiles/activesupport_8_0.gemfile
54
52
  - invoca-utils.gemspec
55
53
  - lib/invoca/utils.rb
56
54
  - lib/invoca/utils/array.rb
@@ -68,9 +66,9 @@ files:
68
66
  - lib/invoca/utils/stable_sort.rb
69
67
  - lib/invoca/utils/time.rb
70
68
  - lib/invoca/utils/version.rb
71
- - spec/helpers/constant_overrides.rb
72
69
  - spec/spec_helper.rb
73
70
  - spec/unit/array_spec.rb
71
+ - spec/unit/diff_spec.rb
74
72
  - spec/unit/enumerable_spec.rb
75
73
  - spec/unit/exceptions_spec.rb
76
74
  - spec/unit/guaranteed_utf8_string_spec.rb
@@ -87,7 +85,6 @@ licenses:
87
85
  - MIT
88
86
  metadata:
89
87
  allowed_push_host: https://rubygems.org
90
- post_install_message:
91
88
  rdoc_options: []
92
89
  require_paths:
93
90
  - lib
@@ -102,14 +99,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
99
  - !ruby/object:Gem::Version
103
100
  version: '0'
104
101
  requirements: []
105
- rubygems_version: 3.3.27
106
- signing_key:
102
+ rubygems_version: 3.6.8
107
103
  specification_version: 4
108
104
  summary: A public collection of helpers used in multiple projects
109
105
  test_files:
110
- - spec/helpers/constant_overrides.rb
111
106
  - spec/spec_helper.rb
112
107
  - spec/unit/array_spec.rb
108
+ - spec/unit/diff_spec.rb
113
109
  - spec/unit/enumerable_spec.rb
114
110
  - spec/unit/exceptions_spec.rb
115
111
  - spec/unit/guaranteed_utf8_string_spec.rb
@@ -1,12 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal", "~> 2.4"
6
- gem "rake", "~> 13.0"
7
- gem "rspec", "~> 3.0"
8
- gem "rspec_junit_formatter", "~> 0.4"
9
- gem "minitest", "~> 5.10.0"
10
- gem "activesupport", "~> 7.0"
11
-
12
- gemspec path: "../"
@@ -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