jsondiff 0.0.4 → 0.0.5

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.
data/README.md CHANGED
@@ -27,6 +27,8 @@ JsonDiff.generate({foo: :bar}, {foo: :plop})
27
27
 
28
28
  ## Changelog
29
29
 
30
+ - 0.0.5:
31
+ - Fix nil value in arrays
30
32
  - 0.0.4:
31
33
  - Don't modify input objects
32
34
  - Fix the order when removing entry in an array
@@ -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
- if array1[index] != value
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
- if array2[index] != value
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|
@@ -1,3 +1,3 @@
1
1
  module JsonDiff
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -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
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-16 00:00:00.000000000 Z
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: &13856960 !ruby/object:Gem::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: *13856960
24
+ version_requirements: *16622500
25
25
  description: Generate a JSON Patch from 2 ruby hash
26
26
  email:
27
27
  - francois@2metz.fr