rexle-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
- checksums.yaml.gz.sig +2 -4
- data/lib/rexle-diff.rb +33 -8
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a675539f847a170d94f7653c99a86627fcc85db
|
4
|
+
data.tar.gz: 6fe3c1a83a83fc2542b433f43adf334bff19d157
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43c0e3901ae77037b9d8393929b4ef354b42d127002f5b2eb82825b8cd7386d468be5a6dbfc8c4a58cae096ac3fd80aa4e2af64a68c1b142260e99623c62aded
|
7
|
+
data.tar.gz: 5d0a51434c1dbdbe70c3b339fa0dce3d488b90be8f92c701562689e85a590402c28426d6384c2d8b738c7224e25d563e8f1245387cff0d47cf4d0f080f15c794
|
checksums.yaml.gz.sig
CHANGED
@@ -1,4 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
���ݰl��`=�td�82��I1�jJ����|;a�
|
4
|
-
��㘇/JlX�
|
1
|
+
��[�K�����o,�fÀ��V ��Qc4Mbq�P\��˳x�&YD���rl���$Q"�L�m�Qdnk����9�j2�;��qu��z���^7�W�6pH�u]e�P�ɍ#5I|��������F
|
2
|
+
_�����\܄>1����]��N��qa������ɔ��q��mi�C��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
|
-
|
30
|
-
|
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
metadata.gz.sig
CHANGED
Binary file
|