philiprehberger-differ 0.3.0 → 0.4.0

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: 501adf50f677014ce90da4bc0222ca212f6a36d091e6612e1a93a3feab001867
4
- data.tar.gz: 28e1bf4f0c0f662f7c8f7d19cb22c24271c709f45a22d7646f86857e586764ff
3
+ metadata.gz: 9e8573d84ddf309e3d702cb9b90d1b407c8963cd84cf62235e6620d586949437
4
+ data.tar.gz: 79ddab362109ba0b8b7958ba77fe9242426a403904082e81b2c8db2f6246a2c2
5
5
  SHA512:
6
- metadata.gz: 6aaaf8bb2c8717bcba57ee14cad6386113c20c815d270fc135da8991dbfc3fa3796389e4bee2ccf1c79b63b443dc926218f4a55a7eca8748a4005a501a3be0ad
7
- data.tar.gz: 7a70fb5815b3a8eb3a6150a521a130ea2c795298d97e522a14bba4bc58c18845199ea3c06cc3797914cad6d476357c2fd86ef89627763805226eac9add84e4cf
6
+ metadata.gz: 585f857fb63da7b81aad2ded9a2948e4cf27b5d996c6afa76480a0ff41397d3181ab02cad53ab285a8d629f15df669c6372d2d7d220b68d27168dac72f8993be
7
+ data.tar.gz: 20e291749bdbec14d58031833b02c9de65dc5f40bd3675407b478ce8dce20efeeb613ca9e28062b97628fd8a32cf44eb98df5e781964b5f70ac85fe1a09a6618
data/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.0] - 2026-04-10
11
+
12
+ ### Added
13
+ - `Changeset` now includes `Enumerable` for direct iteration over changes
14
+ - `Changeset#count` returning the number of changes
15
+ - `Changeset#paths` returning all changed paths
16
+ - `Changeset#include?(path)` to check if a specific path was changed
17
+ - `Changeset#summary` returning `{ added:, removed:, changed: }` counts
18
+
10
19
  ## [0.3.0] - 2026-04-01
11
20
 
12
21
  ### Added
data/README.md CHANGED
@@ -154,6 +154,11 @@ Returns a Float between 0.0 (completely different) and 1.0 (identical).
154
154
  | Method | Description |
155
155
  |---|---|
156
156
  | `changed?` | Returns `true` if any differences exist |
157
+ | `count` | Number of changes |
158
+ | `paths` | Array of all changed paths |
159
+ | `include?(path)` | Check if a specific path was changed |
160
+ | `summary` | `{ added:, removed:, changed: }` counts |
161
+ | `each` | Iterate over changes (includes `Enumerable`) |
157
162
  | `changes` | All `Change` objects |
158
163
  | `added` | Changes where `type == :added` |
159
164
  | `removed` | Changes where `type == :removed` |
@@ -3,12 +3,52 @@
3
3
  module Philiprehberger
4
4
  module Differ
5
5
  class Changeset
6
+ include Enumerable
7
+
6
8
  attr_reader :changes
7
9
 
8
10
  def initialize(changes = [])
9
11
  @changes = changes
10
12
  end
11
13
 
14
+ # Iterate over each Change.
15
+ #
16
+ # @yield [Change] each change
17
+ # @return [Enumerator] if no block given
18
+ def each(&)
19
+ @changes.each(&)
20
+ end
21
+
22
+ # Number of changes.
23
+ #
24
+ # @return [Integer]
25
+ def count
26
+ @changes.length
27
+ end
28
+
29
+ # Array of all changed paths.
30
+ #
31
+ # @return [Array<String>]
32
+ def paths
33
+ @changes.map(&:path)
34
+ end
35
+
36
+ # Check if a specific path was changed.
37
+ #
38
+ # @param path [String, Symbol] the path to check
39
+ # @return [Boolean]
40
+ def include?(path)
41
+ path_s = path.to_s
42
+ @changes.any? { |c| c.path.to_s == path_s }
43
+ end
44
+
45
+ # Summary counts by change type.
46
+ #
47
+ # @return [Hash{Symbol => Integer}] { added:, removed:, changed: }
48
+ def summary
49
+ { added: added.length, removed: removed.length, changed: changed.length }
50
+ end
51
+
12
52
  def changed?
13
53
  !@changes.empty?
14
54
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module Differ
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
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.3.0
4
+ version: 0.4.0
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-04-01 00:00:00.000000000 Z
11
+ date: 2026-04-10 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