json-diff 0.3.1 → 0.3.2
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/lib/json-diff/diff.rb +1 -6
- data/lib/json-diff/version.rb +1 -1
- data/spec/json-diff/diff_spec.rb +14 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 654d73d87ae08ffa4d070f14d320563bee63e21e
|
4
|
+
data.tar.gz: 380d639aa659830cec67be1a49d08be14d5864ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1bc607ce29b614eb86e047c46c77cd6a8685f0343ba6ed904f1d3e83a6bd6b4802342bd7c7dd6dfb5324b1873164b0f26b0a16f5b5838bd695d7ebd1584b9dc
|
7
|
+
data.tar.gz: d6de49305acd3dabed20c7e2e011f93145a1404de37a7e6e30432bc9720adebcf619047a8532bfc27d16f2f1e8196fde48be46213efc72b1723a40e6c2a11dd5
|
data/lib/json-diff/diff.rb
CHANGED
@@ -311,15 +311,10 @@ module JsonDiff
|
|
311
311
|
while i < len
|
312
312
|
ni = (i + 1) % len # next i
|
313
313
|
if ring[i] != ring[ni]
|
314
|
-
pairs << [ring[i], ring[ni], orig_ring[i][0], orig_ring[ni][1]]
|
314
|
+
pairs << [ring_map.map(ring[i]), ring[ni], orig_ring[i][0], orig_ring[ni][1]]
|
315
315
|
end
|
316
316
|
ring_map.removal(ring[i])
|
317
317
|
ring_map.addition(ring[ni])
|
318
|
-
j = i + 1
|
319
|
-
while j < len
|
320
|
-
ring[j] = ring_map.map(ring[j])
|
321
|
-
j += 1
|
322
|
-
end
|
323
318
|
i += 1
|
324
319
|
end
|
325
320
|
end
|
data/lib/json-diff/version.rb
CHANGED
data/spec/json-diff/diff_spec.rb
CHANGED
@@ -57,6 +57,20 @@ describe JsonDiff do
|
|
57
57
|
])
|
58
58
|
end
|
59
59
|
|
60
|
+
it "should be able to diff a ring switch" do
|
61
|
+
diff = JsonDiff.diff([1, 2, 3], [2, 3, 1], include_was: true)
|
62
|
+
expect(diff).to eql([{"op" => "move", "from" => "/0", "path" => "/2"}])
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be able to diff a ring switch with removals and additions" do
|
66
|
+
diff = JsonDiff.diff([1, 2, 3, 4], [5, 3, 4, 2], include_was: true)
|
67
|
+
expect(diff).to eql([
|
68
|
+
{"op" => "remove", "path" => "/0", "was" => 1},
|
69
|
+
{"op" => "move", "from" => "/0", "path" => "/2"},
|
70
|
+
{"op" => "add", "path" => "/0", "value" => 5},
|
71
|
+
])
|
72
|
+
end
|
73
|
+
|
60
74
|
it "should be able to diff two arrays with mixed content" do
|
61
75
|
diff = JsonDiff.diff(["laundry", 12, {'pillar' => 0}, true], [true, {'pillar' => 1}, 3, 12], include_was: true)
|
62
76
|
expect(diff).to eql([
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thaddée Tyl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Take two Ruby objects that can be serialized to JSON. Output an array
|
14
14
|
of operations (additions, deletions, moves) that would convert the first one to
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
version: '0'
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
|
-
rubygems_version: 2.5.1
|
59
|
+
rubygems_version: 2.4.5.1
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Compute the difference between two JSON-serializable Ruby objects.
|