elibri_xml_versions 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -1
- data/lib/elibri_xml_versions.rb +29 -12
- data/lib/elibri_xml_versions/version.rb +1 -1
- data/spec/elibri_xml_versions_spec.rb +4 -4
- metadata +12 -4
data/.travis.yml
CHANGED
data/lib/elibri_xml_versions.rb
CHANGED
@@ -105,20 +105,37 @@ module Elibri
|
|
105
105
|
end
|
106
106
|
# if a.map(&:id) != b.map(&:id)
|
107
107
|
if a_m != b_m
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
108
|
+
if a.all? { |x| x.respond_to?(:eid) } && b.all? { |x| x.respond_to?(:eid) }
|
109
|
+
deleted_ids = a.map(&:eid) - b.map(&:eid)
|
110
|
+
added_ids = b.map(&:eid) - a.map(&:eid)
|
111
|
+
deleted_ids.each do |eid|
|
112
|
+
if a.find { |x| x.eid == eid } && !a.find { |x| x.eid == eid }.blank?
|
113
|
+
deleted << a.find { |x| x.eid == eid }
|
114
|
+
a.delete(a.find { |x| x.eid == eid })
|
115
|
+
end
|
114
116
|
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
117
|
+
added_ids.each do |eid|
|
118
|
+
if b.find { |x| x.eid == eid } && !b.find { |x| x.eid == eid }.blank?
|
119
|
+
added << b.find { |x| x.eid == eid }
|
120
|
+
b.delete(b.find { |x| x.eid == eid })
|
121
|
+
end
|
120
122
|
end
|
121
|
-
|
123
|
+
else
|
124
|
+
deleted_ids = a.map(&:id) - b.map(&:id)
|
125
|
+
added_ids = b.map(&:id) - a.map(&:id)
|
126
|
+
deleted_ids.each do |id|
|
127
|
+
if a.find { |x| x.id == id } && !a.find { |x| x.id == id }.blank?
|
128
|
+
deleted << a.find { |x| x.id == id }
|
129
|
+
a.delete(a.find { |x| x.id == id })
|
130
|
+
end
|
131
|
+
end
|
132
|
+
added_ids.each do |eid|
|
133
|
+
if b.find { |x| x.id == id } && !b.find { |x| x.id == id }.blank?
|
134
|
+
added << b.find { |x| x.id == id }
|
135
|
+
b.delete(b.find { |x| x.id == id })
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
122
139
|
end
|
123
140
|
#obsługa różnych elementów w arrayu
|
124
141
|
a.each_with_index do |element, i|
|
@@ -39,8 +39,8 @@ describe Elibri::XmlVersions do
|
|
39
39
|
it "should return change in author on same basic elibri objects" do
|
40
40
|
author = Elibri::XmlMocks::Examples.contributor_mock(:id => 2167055520)
|
41
41
|
author_2 = Elibri::XmlMocks::Examples.contributor_mock(:last_name => 'Waza', :id => 2167055520)
|
42
|
-
generated_product = onix_from_mock(:
|
43
|
-
generated_product_2 = onix_from_mock(:
|
42
|
+
generated_product = onix_from_mock(:basic_product, :record_reference => 'fdb8fa072be774d97a97', :contributors => [author])
|
43
|
+
generated_product_2 = onix_from_mock(:basic_product, :record_reference => 'fdb8fa072be774d97a97', :contributors => [author_2])
|
44
44
|
@elibri_xml_versions = Elibri::XmlVersions.new(generated_product.products.first, generated_product_2.products.first)
|
45
45
|
diff = @elibri_xml_versions.diff
|
46
46
|
diff[:deleted].should eq([])
|
@@ -267,7 +267,7 @@ describe Elibri::XmlVersions do
|
|
267
267
|
generated_product = onix_from_mock(:basic_product, {:imprint => imprint})
|
268
268
|
generated_product_2 = onix_from_mock(:basic_product, {:imprint => imprint_2})
|
269
269
|
@elibri_xml_versions = Elibri::XmlVersions.new(generated_product.products.first, generated_product_2.products.first)
|
270
|
-
@elibri_xml_versions.diff[:changes].should include(
|
270
|
+
@elibri_xml_versions.diff[:changes].should include(:imprint_name)
|
271
271
|
end
|
272
272
|
|
273
273
|
it "should detect change in object inside book product" do
|
@@ -276,6 +276,6 @@ describe Elibri::XmlVersions do
|
|
276
276
|
generated_product = onix_from_mock(:book_example, RAW_EXTRAS.merge({:imprint => imprint}))
|
277
277
|
generated_product_2 = onix_from_mock(:book_example, RAW_EXTRAS.merge({:imprint => imprint_2}))
|
278
278
|
@elibri_xml_versions = Elibri::XmlVersions.new(generated_product.products.first, generated_product_2.products.first)
|
279
|
-
@elibri_xml_versions.diff[:changes].should include(
|
279
|
+
@elibri_xml_versions.diff[:changes].should include(:imprint_name)
|
280
280
|
end
|
281
281
|
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.8
|
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:
|
12
|
+
date: 2013-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -125,16 +125,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
125
|
- - ! '>='
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
hash: 191043771001115544
|
128
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
132
|
none: false
|
130
133
|
requirements:
|
131
134
|
- - ! '>='
|
132
135
|
- !ruby/object:Gem::Version
|
133
136
|
version: '0'
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
hash: 191043771001115544
|
134
140
|
requirements: []
|
135
141
|
rubyforge_project: elibri_xml_versions
|
136
|
-
rubygems_version: 1.8.
|
142
|
+
rubygems_version: 1.8.25
|
137
143
|
signing_key:
|
138
144
|
specification_version: 3
|
139
145
|
summary: Gem created for comparing eLibri xml objects.
|
140
|
-
test_files:
|
146
|
+
test_files:
|
147
|
+
- spec/elibri_xml_versions_spec.rb
|
148
|
+
- spec/spec_helper.rb
|