oddb2xml 2.3.6 → 2.3.7

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: b279006b7a02bc2158a4c4648cf8085558ba461c
4
- data.tar.gz: 05670f47dd650124d5b09eae09189dfcb664c155
3
+ metadata.gz: f372d02cc0e7829efac3ae2dfda2f85f031d78f6
4
+ data.tar.gz: a5ef791e8e1e3afc811c823b2d407bdcbf3a8e26
5
5
  SHA512:
6
- metadata.gz: 0e4335f32a05b00def36dcbba9816e69f518a9e5d15af88610eff955b651ae154ada3e046ec0d3c8dd0073993b729607305869928e5e23b55d1c45bedfe33542
7
- data.tar.gz: 21b5c2dfaa6b45eec587d86ced6499f67b6404d6f7c4a42dec5e264dcbb56a37a81541b56eeac6e74c9cd0346463295d2e9c3c295e3d932d184c1eb3ad1432a9
6
+ metadata.gz: a443f4fce853675f60aeddad4044a862e341597be1d3d1554f5f7dccb73ada07ed15aff04261e0adda1f86ab6154c580efd270e816d852dc1bb4173331b96678
7
+ data.tar.gz: bb8c5bebdb782b2f62aa976e57bc6880f1fbda0c58cea16b274fb5b634c100e25facc3a88169e2ef3138abbd383956d1073b3ca215964623c53318b432af5995
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oddb2xml (2.3.6)
4
+ oddb2xml (2.3.7)
5
5
  archive-tar-minitar
6
6
  httpi (>= 2.4.1)
7
7
  mechanize
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 2.3.7 /4.04.2016
2
+
3
+ * Emit version of oddb2xml which generated the XML-file
4
+ * Fix NBR_RECORD in generated oddb_product.xml
5
+ * Remove unused variables length in builder.rb
6
+
1
7
  === 2.3.6 /16.03.2016
2
8
 
3
9
  * Generate always a PRODNO with 7 digits (5 from ISKNR, 2 from SEQNR)
@@ -32,6 +32,7 @@ module Oddb2xml
32
32
  'CREATION_DATETIME' => Time.new.strftime('%FT%T%z'),
33
33
  'PROD_DATE' => Time.new.strftime('%FT%T%z'),
34
34
  'VALID_DATE' => Time.new.strftime('%FT%T%z'),
35
+ 'GENERATED_BY' => "oddb2xml #{VERSION}"
35
36
  }
36
37
  class Builder
37
38
  attr_accessor :subject, :refdata, :items, :flags, :lppvs,
@@ -458,7 +459,7 @@ module Oddb2xml
458
459
  prepare_interactions
459
460
  prepare_codes
460
461
  add_missing_products_from_swissmedic
461
- nbr_records = 0
462
+ nbr_products = 0
462
463
  Oddb2xml.log "build_product #{@products.size+@missing.size} products"
463
464
  _builder = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
464
465
  xml.doc.tag_suffix = @tag_suffix
@@ -466,15 +467,14 @@ module Oddb2xml
466
467
  emitted = []
467
468
  xml.PRODUCT(XML_OPTIONS) {
468
469
  list = []
469
- length = 0
470
470
  @missing.each do |obj|
471
471
  next if /^Q/i.match(obj[:atc])
472
472
  if obj[:prodno]
473
473
  next if emitted.index(obj[:prodno])
474
474
  emitted << obj[:prodno]
475
475
  end
476
- length += 1
477
476
  xml.PRD('DT' => obj[:last_change]) {
477
+ nbr_products += 1
478
478
  ean = obj[:ean].to_i
479
479
  xml.GTIN ean
480
480
  xml.PRODNO obj[:prodno] if obj[:prodno]
@@ -498,8 +498,8 @@ module Oddb2xml
498
498
  @products.each do |ean13, obj|
499
499
  next if /^Q/i.match(obj[:atc])
500
500
  seq = obj[:seq]
501
- length += 1
502
501
  xml.PRD('DT' => obj[:last_change]) do
502
+ nbr_products += 1
503
503
  ean = obj[:ean]
504
504
  xml.GTIN ean
505
505
  ppac = ((_ppac = @packs[ean.to_s[4..11].intern] and !_ppac[:is_tier]) ? _ppac : {})
@@ -616,12 +616,11 @@ module Oddb2xml
616
616
  xml.EinheitSwissmedic obj[:eht] unless obj[:eht].empty?
617
617
  xml.SubstanceSwissmedic obj[:sub] unless obj[:sub].empty?
618
618
  xml.CompositionSwissmedic obj[:comp] unless obj[:comp].empty?
619
- nbr_records += 1
620
619
  end
621
620
  end
622
621
  xml.RESULT {
623
622
  xml.OK_ERROR 'OK'
624
- xml.NBR_RECORD nbr_records
623
+ xml.NBR_RECORD nbr_products
625
624
  xml.ERROR_CODE ''
626
625
  xml.MESSAGE ''
627
626
  }
@@ -956,10 +955,8 @@ module Oddb2xml
956
955
  xml.doc.tag_suffix = @tag_suffix
957
956
  datetime = Time.new.strftime('%FT%T%z')
958
957
  xml.KOMPENDIUM(XML_OPTIONS) {
959
- length = 0
960
958
  %w[de fr].each do |lang|
961
959
  infos = @infos[lang].uniq {|i| i[:monid] }
962
- length += infos.length
963
960
  infos.each do |info|
964
961
  xml.KMP(
965
962
  'MONTYPE' => 'fi', # only
@@ -996,7 +993,6 @@ module Oddb2xml
996
993
  xml.doc.tag_suffix = @tag_suffix
997
994
  datetime = Time.new.strftime('%FT%T%z')
998
995
  xml.KOMPENDIUM_PRODUCT(XML_OPTIONS) {
999
- length = 0
1000
996
  info_index = {}
1001
997
  %w[de fr].each do |lang|
1002
998
  @infos[lang].each_with_index do |info, i|
@@ -1112,8 +1108,8 @@ module Oddb2xml
1112
1108
  bag_entry_via_ean = @items.values.select do |i|
1113
1109
  next unless i[:packages]
1114
1110
  i[:packages].values.select {|_pac| _pac[:ean].to_s == de_idx[:ean].to_s }.length != 0
1115
- end.length
1116
- if bag_entry_via_ean > 0
1111
+ end
1112
+ if bag_entry_via_ean.length > 0
1117
1113
  10
1118
1114
  else
1119
1115
  nil
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "2.3.6"
2
+ VERSION = "2.3.7"
3
3
  end
data/oddb2xml.xsd CHANGED
@@ -102,6 +102,7 @@
102
102
  <xs:attribute name="CREATION_DATETIME" use="required"/>
103
103
  <xs:attribute name="PROD_DATE" use="required"/>
104
104
  <xs:attribute name="VALID_DATE" use="required"/>
105
+ <xs:attribute name="GENERATED_BY" use="required"/>
105
106
  </xs:complexType>
106
107
  </xs:element>
107
108
  <xs:element name="ART">
@@ -451,6 +452,7 @@
451
452
  </xs:sequence>
452
453
  <xs:attribute name="CREATION_DATETIME" use="required"/>
453
454
  <xs:attribute name="VALID_DATE" use="required"/>
455
+ <xs:attribute name="GENERATED_BY" use="optional"/>
454
456
  </xs:complexType>
455
457
  </xs:element>
456
458
  <xs:element name="Betrieb">
@@ -507,6 +509,7 @@
507
509
  <xs:attribute name="CREATION_DATETIME" use="required"/>
508
510
  <xs:attribute name="PROD_DATE" use="required"/>
509
511
  <xs:attribute name="VALID_DATE" use="required"/>
512
+ <xs:attribute name="GENERATED_BY" use="optional"/>
510
513
  </xs:complexType>
511
514
  </xs:element>
512
515
  <xs:element name="CD">
@@ -530,6 +533,7 @@
530
533
  <xs:attribute name="CREATION_DATETIME" use="required"/>
531
534
  <xs:attribute name="PROD_DATE" use="required"/>
532
535
  <xs:attribute name="VALID_DATE" use="required"/>
536
+ <xs:attribute name="GENERATED_BY" use="optional"/>
533
537
  </xs:complexType>
534
538
  </xs:element>
535
539
  <xs:element name="CDMD">
@@ -554,6 +558,7 @@
554
558
  <xs:attribute name="CREATION_DATETIME" use="required"/>
555
559
  <xs:attribute name="PROD_DATE" use="required"/>
556
560
  <xs:attribute name="VALID_DATE" use="required"/>
561
+ <xs:attribute name="GENERATED_BY" use="optional"/>
557
562
  </xs:complexType>
558
563
  </xs:element>
559
564
  <xs:element name="IX">
@@ -614,6 +619,7 @@
614
619
  <xs:attribute name="CREATION_DATETIME" use="required"/>
615
620
  <xs:attribute name="PROD_DATE" use="required"/>
616
621
  <xs:attribute name="VALID_DATE" use="required"/>
622
+ <xs:attribute name="GENERATED_BY" use="optional"/>
617
623
  </xs:complexType>
618
624
  </xs:element>
619
625
  <xs:element name="IXMD">
@@ -674,6 +680,7 @@
674
680
  <xs:attribute name="CREATION_DATETIME" use="required"/>
675
681
  <xs:attribute name="PROD_DATE" use="required"/>
676
682
  <xs:attribute name="VALID_DATE" use="required"/>
683
+ <xs:attribute name="GENERATED_BY" use="optional"/>
677
684
  </xs:complexType>
678
685
  </xs:element>
679
686
  <xs:element name="LIM">
@@ -731,6 +738,7 @@
731
738
  <xs:attribute name="CREATION_DATETIME" use="required"/>
732
739
  <xs:attribute name="PROD_DATE" use="required"/>
733
740
  <xs:attribute name="VALID_DATE" use="required"/>
741
+ <xs:attribute name="GENERATED_BY" use="optional"/>
734
742
  </xs:complexType>
735
743
  </xs:element>
736
744
  <xs:element name="LIMMD">
@@ -802,6 +810,7 @@
802
810
  <xs:attribute name="CREATION_DATETIME" use="required"/>
803
811
  <xs:attribute name="PROD_DATE" use="required"/>
804
812
  <xs:attribute name="VALID_DATE" use="required"/>
813
+ <xs:attribute name="GENERATED_BY" use="optional"/>
805
814
  </xs:complexType>
806
815
  </xs:element>
807
816
  <xs:element name="PRD">
@@ -876,6 +885,7 @@
876
885
  <xs:attribute name="CREATION_DATETIME" use="required"/>
877
886
  <xs:attribute name="PROD_DATE" use="required"/>
878
887
  <xs:attribute name="VALID_DATE" use="required"/>
888
+ <xs:attribute name="GENERATED_BY" use="optional"/>
879
889
  </xs:complexType>
880
890
  </xs:element>
881
891
  <xs:element name="PRDMD">
@@ -938,6 +948,7 @@
938
948
  </xs:sequence>
939
949
  <xs:attribute name="CREATION_DATETIME" use="required"/>
940
950
  <xs:attribute name="VALID_DATE" use="required"/>
951
+ <xs:attribute name="GENERATED_BY" use="optional"/>
941
952
  </xs:complexType>
942
953
  </xs:element>
943
954
  <xs:element name="Person">
@@ -986,6 +997,7 @@
986
997
  <xs:attribute name="CREATION_DATETIME" use="required"/>
987
998
  <xs:attribute name="PROD_DATE" use="required"/>
988
999
  <xs:attribute name="VALID_DATE" use="required"/>
1000
+ <xs:attribute name="GENERATED_BY" use="optional"/>
989
1001
  </xs:complexType>
990
1002
  </xs:element>
991
1003
  <xs:element name="SB">
@@ -1008,6 +1020,7 @@
1008
1020
  <xs:attribute name="CREATION_DATETIME" use="required"/>
1009
1021
  <xs:attribute name="PROD_DATE" use="required"/>
1010
1022
  <xs:attribute name="VALID_DATE" use="required"/>
1023
+ <xs:attribute name="GENERATED_BY" use="optional"/>
1011
1024
  </xs:complexType>
1012
1025
  </xs:element>
1013
1026
  <xs:element name="SBMD">
@@ -1160,6 +1173,7 @@
1160
1173
  <xs:attribute name="CREATION_DATETIME" use="required"/>
1161
1174
  <xs:attribute name="PROD_DATE" use="required"/>
1162
1175
  <xs:attribute name="VALID_DATE" use="required"/>
1176
+ <xs:attribute name="GENERATED_BY" use="optional"/>
1163
1177
  </xs:complexType>
1164
1178
  </xs:element>
1165
1179
 
@@ -1186,6 +1200,7 @@
1186
1200
  <xs:attribute name="CREATION_DATETIME" use="required"/>
1187
1201
  <xs:attribute name="PROD_DATE" use="required"/>
1188
1202
  <xs:attribute name="VALID_DATE" use="required"/>
1203
+ <xs:attribute name="GENERATED_BY" use="optional"/>
1189
1204
  </xs:complexType>
1190
1205
  </xs:element>
1191
1206
  </xs:schema>
data/oddb_calc.xsd CHANGED
@@ -136,6 +136,7 @@
136
136
  <xs:attribute type="xs:string" name="CREATION_DATETIME" />
137
137
  <xs:attribute type="xs:string" name="PROD_DATE" />
138
138
  <xs:attribute type="xs:string" name="VALID_DATE" />
139
+ <xs:attribute name="GENERATED_BY" use="required"/>
139
140
  </xs:complexType>
140
141
  </xs:element>
141
142
  </xs:schema>
data/spec/builder_spec.rb CHANGED
@@ -413,8 +413,10 @@ def checkProductXml(nbr_record = -1)
413
413
  expect(File.exists?(product_filename)).to eq true
414
414
 
415
415
  # check products
416
- doc = REXML::Document.new IO.read(product_filename)
416
+ content = IO.read(product_filename)
417
+ doc = REXML::Document.new content
417
418
  check_result(doc, nbr_record)
419
+ expect(nbr_record).to eq content.scan(/<PRD/).size if nbr_record != -1
418
420
 
419
421
  desitin = checkAndGetProductWithGTIN(doc, Oddb2xml::LEVETIRACETAM_GTIN)
420
422
  expect(desitin.elements['ATC'].text).to eq('N03AX14')
@@ -592,7 +594,7 @@ if RUN_ALL
592
594
 
593
595
  it 'should generate a valid oddb_product.xml' do
594
596
  expect(@res).to match(/products/) if @res
595
- checkProductXml(NrProducts)
597
+ checkProductXml(NrPackages)
596
598
  end
597
599
 
598
600
  end
@@ -671,7 +673,7 @@ if RUN_ALL
671
673
 
672
674
  it 'should generate a valid oddb_product.xml' do
673
675
  expect(@res).to match(/products/) if @res != nil
674
- checkProductXml(NrProducts)
676
+ checkProductXml(NrPackages)
675
677
  end
676
678
 
677
679
  it 'should contain the correct (increased) prices' do
@@ -734,7 +736,7 @@ if RUN_ALL
734
736
  end
735
737
 
736
738
  it 'should produce a correct oddb_product.xml' do
737
- checkProductXml(NrProducts)
739
+ checkProductXml(NrPackages)
738
740
  end
739
741
 
740
742
  it 'should report correct output on stdout' do
@@ -870,7 +872,7 @@ if RUN_ALL
870
872
  it 'should add 80 percent to zur_rose pubbprice' do
871
873
  expect(File.exists?(oddb_article_xml)).to eq true
872
874
  FileUtils.cp(oddb_article_xml, File.join(Oddb2xml::WorkDir, 'tst-e80.xml'))
873
- checkProductXml(NrProducts)
875
+ checkProductXml(NrPackages)
874
876
  checkArticleXml
875
877
  checkPrices(true)
876
878
  end
@@ -883,7 +885,7 @@ if RUN_ALL
883
885
  end
884
886
 
885
887
  it 'should generate a correct oddb_product.xml' do
886
- checkProductXml(NrProducts)
888
+ checkProductXml(NrPackages)
887
889
  end
888
890
 
889
891
  it 'should generate an article with the COOL (fridge) attribute' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oddb2xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.6
4
+ version: 2.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhiro Asaka, Zeno R.R. Davatz, Niklaus Giger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip