philiprehberger-differ 0.2.4 → 0.2.8

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: 02a742a524e00b9bece4b1ebf8822e2adf69884edf41a975d6010d5875760d6f
4
- data.tar.gz: 4a8137fab3c31872a9b24cf484fb789c126cf25e08c43592e8c26ecc314ff802
3
+ metadata.gz: 6b373be1315d237effea59c584220c77fb0bd1deb9ba6e238b698e4919e321de
4
+ data.tar.gz: 599f9707141498e91952c4d26fabe62cf1eff4ebd466d485e01403119946f1fa
5
5
  SHA512:
6
- metadata.gz: 6c4cb0be286214b057b24e0ff38746475ca1564758ed592e21f2e0259b8da90f77cc68c1258c0c676c0d5b05a1d9747491823a1eae10ea1667b9a6816edf29cf
7
- data.tar.gz: d5b4f2f4063355b8a7bef68eaf4577f502a85ba2a8d00770730c85cdf7f954822f4b9f6ccf99c4ad741c2cc3a13b860db8a43c190698e71a92e8865df778fadf
6
+ metadata.gz: 7b62b0044c3493e371c44bea5bebd02adf183fc437aec5a8e5b63b92a53cc96a33cca0274329c4bacda38cd44042f1afec6a0de93b4f768615383fd4cc3416f7
7
+ data.tar.gz: 5338d2c13503d74f963f3bd7e8ff4f8488adf739c7a57bfe2d735ab00190ad3052893c5d017014511c1a2c96c78f380384e274d4a427dfbc2c00da3b7c110a02
data/CHANGELOG.md CHANGED
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.8] - 2026-03-31
11
+
12
+ ### Changed
13
+ - Standardize README badges, support section, and license format
14
+
15
+ ## [0.2.7] - 2026-03-26
16
+
17
+ ### Changed
18
+
19
+ - Add Sponsor badge and fix License link format in README
20
+
21
+ ## [0.2.6] - 2026-03-24
22
+
23
+ ### Changed
24
+ - Expand test coverage to 60+ examples covering edge cases and error paths
25
+
26
+ ## [0.2.5] - 2026-03-24
27
+
28
+ ### Fixed
29
+ - Align README one-liner with gemspec summary
30
+
10
31
  ## [0.2.4] - 2026-03-24
11
32
 
12
33
  ### Fixed
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  [![Tests](https://github.com/philiprehberger/rb-differ/actions/workflows/ci.yml/badge.svg)](https://github.com/philiprehberger/rb-differ/actions/workflows/ci.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/philiprehberger-differ.svg)](https://rubygems.org/gems/philiprehberger-differ)
5
- [![License](https://img.shields.io/github/license/philiprehberger/rb-differ)](LICENSE)
5
+ [![Last updated](https://img.shields.io/github/last-commit/philiprehberger/rb-differ)](https://github.com/philiprehberger/rb-differ/commits/main)
6
6
 
7
- Deep structural diff for hashes, arrays, and nested objects in Ruby
7
+ Deep structural diff for hashes, arrays, and nested objects
8
8
 
9
9
  ## Requirements
10
10
 
@@ -160,6 +160,24 @@ bundle exec rspec
160
160
  bundle exec rubocop
161
161
  ```
162
162
 
163
+ ## Support
164
+
165
+ If you find this project useful:
166
+
167
+ ⭐ [Star the repo](https://github.com/philiprehberger/rb-differ)
168
+
169
+ 🐛 [Report issues](https://github.com/philiprehberger/rb-differ/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
170
+
171
+ 💡 [Suggest features](https://github.com/philiprehberger/rb-differ/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement)
172
+
173
+ ❤️ [Sponsor development](https://github.com/sponsors/philiprehberger)
174
+
175
+ 🌐 [All Open Source Projects](https://philiprehberger.com/open-source-packages)
176
+
177
+ 💻 [GitHub Profile](https://github.com/philiprehberger)
178
+
179
+ 🔗 [LinkedIn Profile](https://www.linkedin.com/in/philiprehberger)
180
+
163
181
  ## License
164
182
 
165
- MIT
183
+ [MIT](LICENSE)
@@ -27,13 +27,15 @@ module Philiprehberger
27
27
 
28
28
  def apply(hash)
29
29
  result = deep_dup(hash)
30
- @changes.each { |c| apply_change(result, c) }
30
+ sorted = sort_for_apply(@changes)
31
+ sorted.each { |c| apply_change(result, c) }
31
32
  result
32
33
  end
33
34
 
34
35
  def revert(hash)
35
36
  result = deep_dup(hash)
36
- @changes.each { |c| revert_change(result, c) }
37
+ sorted = sort_for_revert(@changes)
38
+ sorted.each { |c| revert_change(result, c) }
37
39
  result
38
40
  end
39
41
 
@@ -94,6 +96,21 @@ module Philiprehberger
94
96
  hash.keys.any?(Symbol)
95
97
  end
96
98
 
99
+ def sort_for_apply(changes)
100
+ removals, others = changes.partition { |c| c.type == :removed }
101
+ others + removals.sort_by { |c| -(last_index(c.path) || 0) }
102
+ end
103
+
104
+ def sort_for_revert(changes)
105
+ additions, others = changes.partition { |c| c.type == :added }
106
+ others + additions.sort_by { |c| -(last_index(c.path) || 0) }
107
+ end
108
+
109
+ def last_index(path)
110
+ last = path.to_s.split('.').last
111
+ last&.match?(/\A\d+\z/) ? last.to_i : nil
112
+ end
113
+
97
114
  def deep_dup(obj)
98
115
  case obj
99
116
  when Hash then obj.each_with_object({}) { |(k, v), h| h[k] = deep_dup(v) }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module Differ
5
- VERSION = '0.2.4'
5
+ VERSION = '0.2.8'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-differ
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-25 00:00:00.000000000 Z
11
+ date: 2026-03-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby library for deep structural diffing of hashes, arrays, and nested
14
14
  objects with apply/revert, JSON Patch output, similarity scoring, and configurable