jsondiff 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/jsondiff/array_diff.rb +2 -6
- data/lib/jsondiff/version.rb +1 -1
- data/spec/diff_spec.rb +12 -0
- metadata +4 -4
data/README.md
CHANGED
data/lib/jsondiff/array_diff.rb
CHANGED
@@ -6,16 +6,12 @@ module JsonDiff
|
|
6
6
|
if array1.size < array2.size
|
7
7
|
array2[(array1.size..array2.size)].each_with_index do |value, index|
|
8
8
|
index += array1.size
|
9
|
-
|
10
|
-
result << add_op(prefix, index, value)
|
11
|
-
end
|
9
|
+
result << add_op(prefix, index, value)
|
12
10
|
end
|
13
11
|
elsif array1.size > array2.size
|
14
12
|
array1[(array2.size..array1.size)].reverse.each_with_index do |value, index|
|
15
13
|
index = array1.size - 1 - index
|
16
|
-
|
17
|
-
result << remove_op(prefix, index)
|
18
|
-
end
|
14
|
+
result << remove_op(prefix, index)
|
19
15
|
end
|
20
16
|
end
|
21
17
|
array2.each_with_index do |value, index|
|
data/lib/jsondiff/version.rb
CHANGED
data/spec/diff_spec.rb
CHANGED
@@ -32,6 +32,12 @@ describe JsonDiff do
|
|
32
32
|
{ op: :add, path: "/foo/2", value: :baz }]
|
33
33
|
end
|
34
34
|
|
35
|
+
it "add null elements in array" do
|
36
|
+
subject.generate({foo: [:bar]},
|
37
|
+
{foo: [:bar, nil]})
|
38
|
+
.should == [{ op: :add, path: "/foo/1", value: nil }]
|
39
|
+
end
|
40
|
+
|
35
41
|
it "on nested member object" do
|
36
42
|
subject.generate({foo: :bar},
|
37
43
|
{foo: :bar, child: {grandchild: {}}})
|
@@ -76,6 +82,12 @@ describe JsonDiff do
|
|
76
82
|
.should == [{ op: :remove, path: "/foo/2" },
|
77
83
|
{ op: :remove, path: "/foo/1" }]
|
78
84
|
end
|
85
|
+
|
86
|
+
it "remove null elements in array" do
|
87
|
+
subject.generate({foo: [:bar, nil]},
|
88
|
+
{foo: [:bar]})
|
89
|
+
.should == [{ op: :remove, path: "/foo/1" }]
|
90
|
+
end
|
79
91
|
end
|
80
92
|
|
81
93
|
context "replace op" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsondiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &16622500 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.13.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16622500
|
25
25
|
description: Generate a JSON Patch from 2 ruby hash
|
26
26
|
email:
|
27
27
|
- francois@2metz.fr
|