oddb2xml 1.8.3 → 1.8.4

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.
@@ -18,6 +18,18 @@ module Kernel
18
18
  end
19
19
  end
20
20
 
21
+ def check_validation_via_xsd
22
+ @oddb2xml_xsd = File.expand_path(File.join(File.dirname(__FILE__), '..', 'oddb2xml.xsd'))
23
+ File.exists?(@oddb2xml_xsd).should be_true
24
+ files = Dir.glob('*.xml')
25
+ xsd = Nokogiri::XML::Schema(File.read(@oddb2xml_xsd))
26
+ files.each{
27
+ |file|
28
+ doc = Nokogiri::XML(File.read(@article_xml))
29
+ xsd.validate(doc).each do |error| error.message.should be_nil end
30
+ }
31
+ end
32
+
21
33
  describe Oddb2xml::Builder do
22
34
  NrExtendedArticles = 71
23
35
  NrPharmaAndNonPharmaArticles = 61
@@ -34,6 +46,23 @@ describe Oddb2xml::Builder do
34
46
  Dir.chdir @savedDir if @savedDir and File.directory?(@savedDir)
35
47
  end
36
48
 
49
+ context 'XSD-generation: ' do
50
+ let(:cli) do
51
+ opts = {}
52
+ @oddb2xml_xsd = File.expand_path(File.join(File.dirname(__FILE__), '..', 'oddb2xml.xsd'))
53
+ @article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
54
+ @product_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_product.xml'))
55
+ Oddb2xml::Cli.new(opts)
56
+ end
57
+
58
+ it 'should return true when validating oddb_article.xml against oddb_article.xsd' do
59
+ res = buildr_capture(:stdout){ cli.run }
60
+ File.exists?(@article_xml).should be_true
61
+ File.exists?(@product_xml).should be_true
62
+ check_validation_via_xsd
63
+ end
64
+ end
65
+
37
66
  context 'should handle BAG-articles with and without pharmacode' do
38
67
  it {
39
68
  dat = File.read(File.expand_path('../data/Preparations.xml', __FILE__))
@@ -50,12 +79,16 @@ describe Oddb2xml::Builder do
50
79
  Oddb2xml::Cli.new(opts)
51
80
  end
52
81
 
82
+ it 'should pass validating via oddb2xml.xsd' do
83
+ check_validation_via_xsd
84
+ end
85
+
53
86
  it 'should generate a valid oddb_product.xml' do
54
87
  res = buildr_capture(:stdout){ cli.run }
55
88
  res.should match(/products/)
56
- article_filename = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
57
- File.exists?(article_filename).should be_true
58
- article_xml = IO.read(article_filename)
89
+ @article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
90
+ File.exists?(@article_xml).should be_true
91
+ article_xml = IO.read(@article_xml)
59
92
  product_filename = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_product.xml'))
60
93
  File.exists?(product_filename).should be_true
61
94
  unless /1\.8\.7/.match(RUBY_VERSION)
@@ -94,7 +127,8 @@ describe Oddb2xml::Builder do
94
127
  :format => :dat,
95
128
  }
96
129
  Oddb2xml::Cli.new(opts)
97
- end
130
+ end
131
+
98
132
  it 'should generate a valid oddb_with_migel.dat' do
99
133
  res = buildr_capture(:stdout){ cli.run }
100
134
  res.should match(/products/)
@@ -106,6 +140,7 @@ describe Oddb2xml::Builder do
106
140
  end
107
141
  it "pending should match EAN of Desitin. returns 0 at the moment"
108
142
  end
143
+
109
144
  context 'when option -e is given' do
110
145
  let(:cli) do
111
146
  opts = {
@@ -118,18 +153,35 @@ describe Oddb2xml::Builder do
118
153
  Oddb2xml::Cli.new(opts)
119
154
  end
120
155
 
156
+ it 'should pass validating via oddb2xml.xsd' do
157
+ check_validation_via_xsd
158
+ end
159
+
160
+ it 'should not contain veterinary iksnr 47066 CANIPHEDRIN' do
161
+ res = buildr_capture(:stdout){ cli.run }
162
+ res.should match(/NonPharma/i)
163
+ res.should match(/NonPharma products: #{NrPharmaAndNonPharmaArticles}/)
164
+ @article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
165
+ File.exists?(@article_xml).should be_true
166
+ article_xml = IO.read(@article_xml)
167
+ doc = REXML::Document.new File.new(@article_xml)
168
+ dscrds = XPath.match( doc, "//ART" )
169
+ XPath.match( doc, "//BC" ).find_all{|x| x.text.match('47066') }.size.should == 0
170
+ XPath.match( doc, "//DSCRD" ).find_all{|x| x.text.match(/CANIPHEDRIN/) }.size.should == 0
171
+ end
172
+
121
173
  it 'should handle not duplicate pharmacode 5366964' do
122
174
  res = buildr_capture(:stdout){ cli.run }
123
175
  res.should match(/NonPharma/i)
124
176
  res.should match(/NonPharma products: #{NrPharmaAndNonPharmaArticles}/)
125
- article_filename = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
126
- File.exists?(article_filename).should be_true
127
- article_xml = IO.read(article_filename)
128
- doc = REXML::Document.new File.new(article_filename)
177
+ @article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
178
+ File.exists?(@article_xml).should be_true
179
+ article_xml = IO.read(@article_xml)
180
+ doc = REXML::Document.new File.new(@article_xml)
129
181
  dscrds = XPath.match( doc, "//ART" )
130
182
  XPath.match( doc, "//PHAR" ).find_all{|x| x.text.match('5366964') }.size.should == 1
131
183
  dscrds.size.should == NrExtendedArticles
132
- XPath.match( doc, "//PRODNO" ).find_all{|x| true}.size.should == 1
184
+ XPath.match( doc, "//PRODNO" ).find_all{|x| true}.size.should >= 1
133
185
  XPath.match( doc, "//PRODNO" ).find_all{|x| x.text.match('620691') }.size.should == 1
134
186
  end
135
187
 
@@ -137,10 +189,10 @@ describe Oddb2xml::Builder do
137
189
  res = buildr_capture(:stdout){ cli.run }
138
190
  res.should match(/NonPharma/i)
139
191
  res.should match(/NonPharma products: #{NrPharmaAndNonPharmaArticles}/)
140
- article_filename = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
141
- File.exists?(article_filename).should be_true
142
- article_xml = IO.read(article_filename)
143
- doc = REXML::Document.new File.new(article_filename)
192
+ @article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
193
+ File.exists?(@article_xml).should be_true
194
+ article_xml = IO.read(@article_xml)
195
+ doc = REXML::Document.new File.new(@article_xml)
144
196
  dscrds = XPath.match( doc, "//ART" )
145
197
  dscrds.size.should == NrExtendedArticles
146
198
  XPath.match( doc, "//PHAR" ).find_all{|x| x.text.match('1699947') }.size.should == 1 # swissmedic_packages Cardio-Pulmo-Rénal Sérocytol, suppositoire
@@ -166,10 +218,10 @@ describe Oddb2xml::Builder do
166
218
 
167
219
  it 'should emit a correct oddb_article.xml' do
168
220
  res = buildr_capture(:stdout){ cli.run }
169
- article_filename = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
170
- File.exists?(article_filename).should be_true
171
- article_xml = IO.read(article_filename)
172
- doc = REXML::Document.new File.new(article_filename)
221
+ @article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
222
+ File.exists?(@article_xml).should be_true
223
+ article_xml = IO.read(@article_xml)
224
+ doc = REXML::Document.new File.new(@article_xml)
173
225
  unless /1\.8\.7/.match(RUBY_VERSION)
174
226
  # check articles
175
227
  article_xml.should match(/3TC/)
@@ -195,7 +247,7 @@ describe Oddb2xml::Builder do
195
247
  article_xml.should match(/7680555580054/) # ZYVOXID
196
248
  article_xml.should match(/ZYVOXID/i)
197
249
 
198
- doc = REXML::Document.new File.new article_filename
250
+ doc = REXML::Document.new File.new @article_xml
199
251
  dscrds = XPath.match( doc, "//DSCRD" )
200
252
  dscrds.find_all{|x| x.text.match('ZYVOXID Filmtabl 600 mg') }.size.should == 1
201
253
 
@@ -10,3 +10,7 @@
10
10
  1130027447ARTHROSENEX2519120 Salbe 100 g 0012930024300000000000000000000000002
11
11
  1130028470COMPLAMIN RETARD Tabl 500 mg 60 Stk 001817003110300C020430000000000000002
12
12
  11353669641-DAY ACUVUE Moist Tag -2.00dpt BC 8.5 30 Stk 0021170037501000000000000000000000001
13
+ 1122871437CANIPHEDRIN Tabl 20 mg ad us vet. 100 Stk 001266001550400C000000076804706601832
14
+ 1122871443CANIPHEDRIN Tabl 20 mg ad us vet. 500 Stk 004872006910400C000000000000000000002
15
+ 1122871466CANIPHEDRIN Tabl 50 mg ad us vet. 100 Stk 001424001750400C000000076804706604282
16
+ 1122871472CANIPHEDRIN Tabl 50 mg ad us vet. 500 Stk 005443007580400C000000000000000000002
@@ -67,7 +67,7 @@ describe Oddb2xml::SwissmedicInfoExtractor do
67
67
  it {
68
68
  filename = File.join(Oddb2xml::SpecData, 'swissmedic_package.xlsx')
69
69
  @packs = Oddb2xml::SwissmedicExtractor.new(filename, :package).to_hash
70
- expect(@packs.size).to eq(14)
70
+ expect(@packs.size).to eq(16)
71
71
  serocytol = nil
72
72
  @packs.each{|pack|
73
73
  serocytol = pack[1] if pack[0].to_s == '00274001'
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oddb2xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.8.4
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Yasuhiro Asaka, Zeno R.R. Davatz
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
12
+ date: 2014-05-21 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rubyzip
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: archive-tar-minitar
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: mechanize
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: nokogiri
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: savon
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ~>
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ~>
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: spreadsheet
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ~>
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :runtime
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ~>
95
108
  - !ruby/object:Gem::Version
@@ -97,6 +110,7 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: rubyXL
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ~>
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ~>
109
124
  - !ruby/object:Gem::Version
@@ -111,6 +126,7 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: sax-machine
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
131
  - - ~>
116
132
  - !ruby/object:Gem::Version
@@ -118,6 +134,7 @@ dependencies:
118
134
  type: :runtime
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
139
  - - ~>
123
140
  - !ruby/object:Gem::Version
@@ -125,6 +142,7 @@ dependencies:
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: bundler
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
147
  - - ! '>='
130
148
  - !ruby/object:Gem::Version
@@ -132,6 +150,7 @@ dependencies:
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
155
  - - ! '>='
137
156
  - !ruby/object:Gem::Version
@@ -139,6 +158,7 @@ dependencies:
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: rake
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
163
  - - ! '>='
144
164
  - !ruby/object:Gem::Version
@@ -146,6 +166,7 @@ dependencies:
146
166
  type: :development
147
167
  prerelease: false
148
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
149
170
  requirements:
150
171
  - - ! '>='
151
172
  - !ruby/object:Gem::Version
@@ -153,6 +174,7 @@ dependencies:
153
174
  - !ruby/object:Gem::Dependency
154
175
  name: rspec
155
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
156
178
  requirements:
157
179
  - - ! '>='
158
180
  - !ruby/object:Gem::Version
@@ -160,6 +182,7 @@ dependencies:
160
182
  type: :development
161
183
  prerelease: false
162
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
163
186
  requirements:
164
187
  - - ! '>='
165
188
  - !ruby/object:Gem::Version
@@ -167,6 +190,7 @@ dependencies:
167
190
  - !ruby/object:Gem::Dependency
168
191
  name: webmock
169
192
  requirement: !ruby/object:Gem::Requirement
193
+ none: false
170
194
  requirements:
171
195
  - - ! '>='
172
196
  - !ruby/object:Gem::Version
@@ -174,6 +198,7 @@ dependencies:
174
198
  type: :development
175
199
  prerelease: false
176
200
  version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
177
202
  requirements:
178
203
  - - ! '>='
179
204
  - !ruby/object:Gem::Version
@@ -181,6 +206,7 @@ dependencies:
181
206
  - !ruby/object:Gem::Dependency
182
207
  name: rdoc
183
208
  requirement: !ruby/object:Gem::Requirement
209
+ none: false
184
210
  requirements:
185
211
  - - ! '>='
186
212
  - !ruby/object:Gem::Version
@@ -188,6 +214,7 @@ dependencies:
188
214
  type: :development
189
215
  prerelease: false
190
216
  version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
191
218
  requirements:
192
219
  - - ! '>='
193
220
  - !ruby/object:Gem::Version
@@ -221,6 +248,7 @@ files:
221
248
  - lib/oddb2xml/version.rb
222
249
  - lib/oddb2xml/xml_definitions.rb
223
250
  - oddb2xml.gemspec
251
+ - oddb2xml.xsd
224
252
  - spec/builder_spec.rb
225
253
  - spec/cli_spec.rb
226
254
  - spec/compressor_spec.rb
@@ -272,26 +300,27 @@ files:
272
300
  homepage: https://github.com/zdavatz/oddb2xml
273
301
  licenses:
274
302
  - GPL-v2
275
- metadata: {}
276
303
  post_install_message:
277
304
  rdoc_options: []
278
305
  require_paths:
279
306
  - lib
280
307
  required_ruby_version: !ruby/object:Gem::Requirement
308
+ none: false
281
309
  requirements:
282
310
  - - ! '>='
283
311
  - !ruby/object:Gem::Version
284
312
  version: '0'
285
313
  required_rubygems_version: !ruby/object:Gem::Requirement
314
+ none: false
286
315
  requirements:
287
316
  - - ! '>='
288
317
  - !ruby/object:Gem::Version
289
318
  version: '0'
290
319
  requirements: []
291
320
  rubyforge_project:
292
- rubygems_version: 2.2.1
321
+ rubygems_version: 1.8.25
293
322
  signing_key:
294
- specification_version: 4
323
+ specification_version: 3
295
324
  summary: oddb2xml creates xml files.
296
325
  test_files:
297
326
  - spec/builder_spec.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDAzMTE2OWI2MWMzYzE5OTkxMjAzMmJiMzU2OWQyMmI5N2JlMGM1Nw==
5
- data.tar.gz: !binary |-
6
- ZWEyOWE5M2Y0ZDE3OTJlN2NlYmU5Mjg1NDcxZGEwMWQxNzk3NTljYw==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- MDUzZGY0MTIzZWIxYjdmODVlYmYzZGQ2NmVlZmU0YTRjZjM4YjczM2U1MmRm
10
- OWZkMDI4OWQ1YzI4MDNmZWY4NDk5ZDEwNzhjN2VhZGQxM2UxYmM5NWM2MmQy
11
- NDIxNDM5MzRmMWU0NjQzZjcxOWYxYTJmNjU1MGYzY2NmODJlYWQ=
12
- data.tar.gz: !binary |-
13
- ZGQyZWRhMmFmZDM2ZDMyZTFjYzk1MDcyNTM2ZGJjYjMzNTY1ZjExNWJhN2Q1
14
- M2I2N2RhOGQzMGZiM2ZjZDRmZDkyMmM3YjhlNTE2ZWU2ZTdkYzE1OTY2OTc1
15
- OTRlNmE1ZGYwNDcyMGE3OTFjYjAxMTQ2ZTBhYTg5OTMwZGQxMmU=