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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +5 -0
- data/lib/philiprehberger/differ/changeset.rb +40 -0
- data/lib/philiprehberger/differ/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e8573d84ddf309e3d702cb9b90d1b407c8963cd84cf62235e6620d586949437
|
|
4
|
+
data.tar.gz: 79ddab362109ba0b8b7958ba77fe9242426a403904082e81b2c8db2f6246a2c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
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.
|
|
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-
|
|
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
|