elibri_xml_versions 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/elibri_xml_versions/version.rb +1 -1
- data/lib/elibri_xml_versions.rb +25 -9
- metadata +4 -4
data/lib/elibri_xml_versions.rb
CHANGED
@@ -55,7 +55,8 @@ module Elibri
|
|
55
55
|
end
|
56
56
|
diffs
|
57
57
|
=end
|
58
|
-
check_tree(@a, @b)
|
58
|
+
@stored_diff ||= check_tree(@a, @b)
|
59
|
+
@stored_diff
|
59
60
|
end
|
60
61
|
|
61
62
|
|
@@ -158,14 +159,18 @@ module Elibri
|
|
158
159
|
next if SKIPPED_ATTRIBS.include? attrib
|
159
160
|
attrib = attrib.to_s.gsub("@", "").to_sym if attrib.is_a?(String)
|
160
161
|
if a.send(attrib).is_a? Array
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
162
|
+
if is_all_simple?(a.send(attrib))
|
163
|
+
changes << attrib if a.send(attrib) != b.send(attrib)
|
164
|
+
else
|
165
|
+
ret = check_tree(a.send(attrib), b.send(attrib))
|
166
|
+
#TODO: otestować to
|
167
|
+
changes << {attrib => ret[:changes]} if !ret[:changes].blank?
|
168
|
+
added << {attrib => ret[:added]} if !ret[:added].blank?
|
169
|
+
deleted << {attrib => ret[:deleted]} if !ret[:deleted].blank?
|
170
|
+
end
|
166
171
|
else
|
167
|
-
if (
|
168
|
-
|
172
|
+
if (is_simple_type?(a.send(attrib)) || b.send(attrib).is_a?(NilClass) ||
|
173
|
+
b.send(attrib).is_a?(TrueClass) || b.send(attrib).is_a?(FalseClass) )
|
169
174
|
changes << attrib if a.send(attrib) != b.send(attrib)
|
170
175
|
else
|
171
176
|
#klasa zlozona
|
@@ -197,7 +202,7 @@ module Elibri
|
|
197
202
|
attrib = attrib.to_s.gsub("@", "").to_sym if attrib.is_a?(String)
|
198
203
|
if object.send(attrib).is_a? Array
|
199
204
|
result << calculate_hash(object.send(attrib))
|
200
|
-
elsif
|
205
|
+
elsif is_simple_type?(object.send(attrib))
|
201
206
|
result << object.send(attrib)
|
202
207
|
else
|
203
208
|
result << calculate_hash(object.send(attrib))
|
@@ -215,6 +220,17 @@ module Elibri
|
|
215
220
|
end
|
216
221
|
end
|
217
222
|
|
223
|
+
def is_simple_type?(obj)
|
224
|
+
obj.is_a?(String) || obj.is_a?(Numeric) ||
|
225
|
+
obj.is_a?(NilClass) || obj.is_a?(TrueClass) ||
|
226
|
+
obj.is_a?(FalseClass) || obj.is_a?(Date) ||
|
227
|
+
obj.is_a?(Symbol) || obj.is_a?(Fixnum)
|
228
|
+
end
|
229
|
+
|
230
|
+
def is_all_simple?(arr)
|
231
|
+
arr.all? {|e| is_simple_type?(e) }
|
232
|
+
end
|
233
|
+
|
218
234
|
end
|
219
235
|
|
220
236
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elibri_xml_versions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
segments:
|
129
129
|
- 0
|
130
|
-
hash:
|
130
|
+
hash: -3513691374160647720
|
131
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
132
|
none: false
|
133
133
|
requirements:
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
segments:
|
138
138
|
- 0
|
139
|
-
hash:
|
139
|
+
hash: -3513691374160647720
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project: elibri_xml_versions
|
142
142
|
rubygems_version: 1.8.25
|