rexle-diff 0.5.2 → 0.5.4

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: 7d5b70c7254facf4a001b1b3289b8c17763e071e
4
- data.tar.gz: 083a67e79eb662d53d54c75a628dff685c48f1e5
3
+ metadata.gz: 0cacd13616e246a126d280ddd34ff167a474332c
4
+ data.tar.gz: 622523d2364cb42d517f715f8c754c6e96595016
5
5
  SHA512:
6
- metadata.gz: d548ba5c5ba92a04d332482edb1f6acc6fe78296e0ec7e2533ed2f68cf8140c81cd65c47ebe5019aa97953f4798264dbe414625397215bdf433e1924b5b9fddc
7
- data.tar.gz: 8a07843aaec45a1bd28ee99ffafb8f074c2699bb3cd19f84d773fc05fa19aeccdfb1e19b39f64e6ba2e23acc58a220185d44af41dc0397be2b5be44edb21f6b7
6
+ metadata.gz: fc4d7c3b59cdebd84711c0c2431a3e8e14c9efa2edc5d877ca6968c2bebb722ef3ba27f69cf888b56b65326039dd01e5a3eabf910834acca18d8414298612517
7
+ data.tar.gz: db785ddb56d09026f7f30078d5ae7e70c94102ab8a0b0ec6cdf09d4c7cb68a643247b87d5fcb76cd2b60c05f4145896761cf2472d52c9b1d69674f73f76fa57b
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rexle-diff.rb CHANGED
@@ -10,8 +10,9 @@ class RexleDiff
10
10
 
11
11
  attr_reader :to_doc
12
12
 
13
- def initialize(source1, source2)
13
+ def initialize(source1, source2, fuzzy_match: false)
14
14
 
15
+ @fuzzy_match = fuzzy_match
15
16
  doc1, doc2 = Rexle.new(source1), Rexle.new(source2)
16
17
  compare(doc1.root, doc2.root)
17
18
 
@@ -62,31 +63,9 @@ class RexleDiff
62
63
  # elements which may have been modified are also
63
64
  # added to the added_indexes list
64
65
  added_or_changed_indexes = added(hxlist, hxlist2)
65
-
66
- # is the added index item a new entry or an entry modification?
67
- updated_indexes, added_indexes = added_or_changed_indexes.partition do |i|
68
-
69
- e1 = node.elements[i+1]
70
- next unless e1
71
-
72
- fm = FuzzyMatch.new [e1.text]
73
- result, score1, score2 = fm.find_with_score node2.elements[i+1].text
74
- #puts "result: %s score1: %s score2: %s" % [result, score1, score2]
75
-
76
- result and score1 >= 0.5
77
-
78
- end
79
-
80
-
81
- updated_indexes.each do |i|
82
-
83
- attributes2 = node2.elements[i+1].attributes
84
- attributes2[:last_modified] = Time.now.to_s
85
-
86
- attributes = node.elements[i+1].attributes
87
- attributes2[:created] = attributes[:created] if attributes[:created]
88
- end
89
-
66
+ added_indexes, updated_indexes = @fuzzy_match ? \
67
+ fuzzy_match(added_or_changed_indexes, node, node2) : \
68
+ [added_or_changed_indexes, []]
90
69
  added_indexes.each do |i|
91
70
 
92
71
  attributes = node2.elements[i+1].attributes
@@ -125,7 +104,35 @@ class RexleDiff
125
104
  result = list - list2
126
105
  indexes = result.map {|x| list.index x}
127
106
 
128
- end
107
+ end
108
+
109
+ def fuzzy_match(added_or_changed_indexes, node, node2)
110
+
111
+ # is the added index item a new entry or an entry modification?
112
+ updated_indexes, added_indexes = added_or_changed_indexes.partition do |i|
113
+
114
+ e1 = node.elements[i+1]
115
+ next unless e1
116
+
117
+ fm = FuzzyMatch.new [e1.text]
118
+ result, score1, score2 = fm.find_with_score node2.elements[i+1].text
119
+ #puts "result: %s score1: %s score2: %s" % [result, score1, score2]
120
+
121
+ result and score1 >= 0.5
122
+
123
+ end
124
+
125
+ updated_indexes.each do |i|
126
+
127
+ attributes2 = node2.elements[i+1].attributes
128
+ attributes2[:last_modified] = Time.now.to_s
129
+
130
+ attributes = node.elements[i+1].attributes
131
+ attributes2[:created] = attributes[:created] if attributes[:created]
132
+ end
133
+
134
+ [added_indexes, updated_indexes]
135
+ end
129
136
 
130
137
  # Returns an array of indexes from both original and new nodes which
131
138
  # identifies which nodes did not change.
data.tar.gz.sig CHANGED
@@ -1,6 +1,2 @@
1
-
2
- ~�Ù_ ���\�S�:[2V��Ckˆ����}�,T���0Iq���K��}J2��<6%�3eA^
3
- f��@ G��Z���
4
- ����̀ �чv�nۡN�6�� ��.7P���R�"kr" ���ۊd�?�������p�|��"�|�:�omчIh�E� 5j���K��T��2����� �߲�ն�����i
5
- ��vkN}(C
6
- ̹�M?׶��a_��c�`�.ƻeٶ��6�Zੑ�8it����Rn�����
1
+ }4z��3@7��.H�u��X9��q�=Ψ[�'�yi��䣁\����+z3 \ H����� ;q��fw��/�dl��)ė�t�G�Bc c� I@'�;k���{ڐ�iȈT��� �#�s��V�zB����.~
2
+ n������1��ߺsg�U�]������eU�Hñ��o�]���92��aȍi�!��s�rf�v�߭3Eu�/��EעC=��A� ���w����E ��P���~�J���q*z?ע(���x
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.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  1dtvoSgugum4cZlSFYiRyLXuJz4nZeMJGod1r8cOFR0dwx7yOdvKZybPd4FXWVjG
32
32
  EozQjWbvhzsspQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-03-26 00:00:00.000000000 Z
34
+ date: 2015-03-27 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexle
metadata.gz.sig CHANGED
Binary file