rexle-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: 2a519555cefb568fc4678efaca42b3eb9b032b99
4
- data.tar.gz: bd91eb9278b84f3509c1d3fc4e1e3be116a7e1b0
3
+ metadata.gz: 8a675539f847a170d94f7653c99a86627fcc85db
4
+ data.tar.gz: 6fe3c1a83a83fc2542b433f43adf334bff19d157
5
5
  SHA512:
6
- metadata.gz: c4bb5b88d2dfce46cfe59113cc6f33235b0881c55f32cbc8c9f229250e2568cf13a9d4b130299d829414a35c6178defe1f571cc09c5e358f2bbfe3f1b457ddd6
7
- data.tar.gz: 5b21648944c4f5b825bb1192931526ded6ab8d9ab6ba5157c69275900e0bd0b9e7e9020b966737d30167c168995b7c5bb2a5a8bf3d885aeb6bf419ba283d0857
6
+ metadata.gz: 43c0e3901ae77037b9d8393929b4ef354b42d127002f5b2eb82825b8cd7386d468be5a6dbfc8c4a58cae096ac3fd80aa4e2af64a68c1b142260e99623c62aded
7
+ data.tar.gz: 5d0a51434c1dbdbe70c3b339fa0dce3d488b90be8f92c701562689e85a590402c28426d6384c2d8b738c7224e25d563e8f1245387cff0d47cf4d0f080f15c794
checksums.yaml.gz.sig CHANGED
@@ -1,4 +1,2 @@
1
- Mܡ���a29��u�i5��s7�\ԫVP1t4KVtIn8ݚυ�d4��:�bg=�6+���yh��>1U�/��lSy�P9߮@K�'w� ��t^{ ���D�owB8U�^�S��=#��K=��[G��^r��K�׽��@�ˆ ��TU��� I�v@;��#����
2
- ñ�w!H7�!nvdO���F�D
3
- ���ݰl��`=�td�82��I1�jJ����|;a�
4
- ��㘇/JlX�
1
+ ��[K�����o,�fÀ��V �޾�Qc4MbqP\��˳x�&YD���rl���$Q"LmQdnk����9�j2�׼;��qu��z���^7W6pHu]eP�ɍ#5I|��������F
2
+ _�����\܄>1����]��N��qa������ɔ��q��miC��x�� �-H'AaC�2�+���f}�����L�g���'8���0T� L��I�՘*�M9�g.6.���p��4
data/lib/rexle-diff.rb CHANGED
@@ -20,20 +20,31 @@ class RexleDiff
20
20
 
21
21
  private
22
22
 
23
-
23
+ # Returns an array of MD5 hashed strings representing each child node itself
24
+ #
24
25
  def hashedxml(node)
25
26
 
26
27
  node.elements.map do |element|
27
28
 
28
29
  attributes = element.attributes.clone
29
- attributes.delete :created
30
- val = [element.name, attributes, element.text].to_s
30
+
31
+ # Although attribute last_modified isn't used by rexle-diff it is
32
+ # created by Dynarex whenever a record is created or updated.
33
+ # This would of course cause the record to be flagged as changed even
34
+ # when the element value itself hashn't changed.
35
+ #
36
+ %i(created last_modified).each {|x| attributes.delete x}
37
+ val = [element.name, attributes, element.text.to_s.strip].to_s
31
38
 
32
39
  h = Digest::MD5.new << val
33
40
  h.to_s
34
41
  end
35
42
  end
36
43
 
44
+
45
+ # Returns an array of indexes of the nodes from the newer document which
46
+ # have been added or changed
47
+ #
37
48
  def added(hxlist, hxlist2)
38
49
 
39
50
  added_or_changed = hxlist2 - hxlist
@@ -42,13 +53,15 @@ class RexleDiff
42
53
 
43
54
  end
44
55
 
56
+ # The main method for comparing the newest document node with the
57
+ # older document node
58
+ #
45
59
  def compare(node, node2)
46
-
60
+
47
61
  hxlist, hxlist2 = hashedxml(node), hashedxml(node2)
48
62
 
49
63
  # elements which may have been modified are also
50
- # added to the added_indexes list
51
-
64
+ # added to the added_indexes list
52
65
  added_indexes = added(hxlist, hxlist2)
53
66
 
54
67
  added_indexes.each do |i|
@@ -62,19 +75,28 @@ class RexleDiff
62
75
 
63
76
  end
64
77
  end
65
-
78
+
66
79
  deleted_indexes = deleted(hxlist, hxlist2)
67
80
 
68
81
  unchanged_indexes = unchanged(hxlist, hxlist2)
69
-
82
+
70
83
  unchanged_indexes.each do |i, i2|
71
84
 
72
85
  compare(node.elements[i+1], node2.elements[i2+1]) if node\
73
86
  .elements[i+1].has_elements?
87
+ attributes2 = node2.elements[i2+1].attributes
88
+
89
+ if attributes2[:created].nil? then
90
+ attributes = node.elements[i+1].attributes
91
+ attributes2[:created] = attributes[:created] if attributes[:created]
92
+ end
74
93
  end
75
94
 
76
95
  end
77
96
 
97
+ # Returns an array of indexes pointing to the nodes which were removed from
98
+ # the original document's relative parent node
99
+ #
78
100
  def deleted(list, list2)
79
101
 
80
102
  result = list - list2
@@ -82,6 +104,9 @@ class RexleDiff
82
104
 
83
105
  end
84
106
 
107
+ # Returns an array of indexes from both original and new nodes which
108
+ # identifies which nodes did not change.
109
+ #
85
110
  def unchanged(list, list2)
86
111
 
87
112
  result = list & list2
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexle-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
  - James Robertson
metadata.gz.sig CHANGED
Binary file