json-diff 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a49d9630f57ff6fc69869d27d2a6cee854b4b09e
4
- data.tar.gz: cb67cc7d6abff730cfd6bb5fe8856196da4c94e2
3
+ metadata.gz: 654d73d87ae08ffa4d070f14d320563bee63e21e
4
+ data.tar.gz: 380d639aa659830cec67be1a49d08be14d5864ad
5
5
  SHA512:
6
- metadata.gz: 89cd581b2d433f35f38e8d4b03116e0d77d04d5a0b11cd5594492850aed1b24a8bea03440f0e09b83ba9c57c8af31cd013753d46605d13b32d7676b2bd9c40ff
7
- data.tar.gz: c997bfdd2fc503857a522949bfd30bfc39a2ac73f0784109ca9035467276e07d734e233095df55ce572046dd52c44b775b2fb522e3a6c52c6baa479cd2c8e462
6
+ metadata.gz: f1bc607ce29b614eb86e047c46c77cd6a8685f0343ba6ed904f1d3e83a6bd6b4802342bd7c7dd6dfb5324b1873164b0f26b0a16f5b5838bd695d7ebd1584b9dc
7
+ data.tar.gz: d6de49305acd3dabed20c7e2e011f93145a1404de37a7e6e30432bc9720adebcf619047a8532bfc27d16f2f1e8196fde48be46213efc72b1723a40e6c2a11dd5
@@ -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
@@ -1,3 +1,3 @@
1
1
  module JsonDiff
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -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.1
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-08-24 00:00:00.000000000 Z
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.