oddb2xml 1.5.5 → 1.5.6

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.
@@ -1,3 +1,9 @@
1
+ === 1.5.6 / 09.07.2013
2
+
3
+ * Fix bug zurrose price format
4
+ * Update time format for zurrose import
5
+ * Update to add ZURROSE Price as optional value
6
+
1
7
  === 1.5.5 / 08.07.2013
2
8
 
3
9
  * Add local PATH option support for zurrose
@@ -653,13 +653,7 @@ module Oddb2xml
653
653
  #xml.LINENO
654
654
  #xml.NOUNITS
655
655
  #}
656
- if price # zurrose
657
- xml.ARTPRI {
658
- xml.VDAT datetime
659
- xml.PTYP "ZURROSE"
660
- xml.PRICE price[:price]
661
- }
662
- elsif pac
656
+ if pac
663
657
  pac[:prices].each_pair do |key, price|
664
658
  xml.ARTPRI {
665
659
  xml.VDAT price[:valid_date] unless price[:valid_date].empty?
@@ -668,6 +662,13 @@ module Oddb2xml
668
662
  }
669
663
  end
670
664
  end
665
+ if price
666
+ xml.ARTPRI {
667
+ xml.VDAT Time.parse(datetime).strftime("%d.%m.%Y")
668
+ xml.PTYP "ZURROSE"
669
+ xml.PRICE price[:price]
670
+ }
671
+ end
671
672
  #xml.ARTMIG {
672
673
  #xml.VDAT
673
674
  #xml.MIGCD
@@ -409,7 +409,7 @@ module Oddb2xml
409
409
  end
410
410
  class ZurroseExtractor < Extractor
411
411
  def initialize(dat)
412
- @io = StringIO.new(dat)
412
+ @io = StringIO.new(dat) if dat
413
413
  end
414
414
  def to_hash
415
415
  data = {}
@@ -417,9 +417,9 @@ module Oddb2xml
417
417
  next unless line =~ /(7680\d{9})(\d{1})\r\n$/
418
418
  data[$1.to_s] = {
419
419
  :vat => $2.to_s,
420
- :price => sprintf("%.2f", line[60,6].gsub(/(\d{2})$/, "." + $1.to_s).to_f)
420
+ :price => sprintf("%.2f", line[60,6].gsub(/(\d{2})$/, '.\1').to_f)
421
421
  }
422
- end
422
+ end if @io
423
423
  data
424
424
  end
425
425
  end
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "1.5.5"
2
+ VERSION = "1.5.6"
3
3
  end
@@ -5,3 +5,46 @@ require 'spec_helper'
5
5
  describe Oddb2xml::Extractor do
6
6
  it "pending"
7
7
  end
8
+
9
+ describe Oddb2xml::ZurroseExtractor do
10
+ context 'when transfer.dat is empty' do
11
+ subject { Oddb2xml::ZurroseExtractor.new("") }
12
+ it { expect(subject.to_hash).to be_empty }
13
+ end
14
+ context 'when transfer.dat is nil' do
15
+ subject { Oddb2xml::ZurroseExtractor.new(nil) }
16
+ it { expect(subject.to_hash).to be_empty }
17
+ end
18
+ context 'when as line break mark \n is given' do
19
+ subject do
20
+ dat = <<-DAT
21
+ 1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152
22
+ DAT
23
+ Oddb2xml::ZurroseExtractor.new(dat)
24
+ end
25
+ it { expect(subject.to_hash).to be_empty }
26
+ end
27
+ context 'when only 1 record have a valid EAN code' do
28
+ subject do
29
+ dat = <<-DAT
30
+ 1120020209ERYTRHOCIN I.V. Trockensub Fl 1g 001518002010300B080160000000000000002\r\n
31
+ 1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152\r\n
32
+ DAT
33
+ Oddb2xml::ZurroseExtractor.new(dat)
34
+ end
35
+ it { expect(subject.to_hash.keys.length).to eq(1) }
36
+ it { expect(subject.to_hash.keys.first).to eq("7680316440115") }
37
+ end
38
+ context 'when expected line is given' do
39
+ subject do
40
+ dat = <<-DAT
41
+ 1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152\r\n
42
+ DAT
43
+ Oddb2xml::ZurroseExtractor.new(dat)
44
+ end
45
+ it { expect(subject.to_hash.keys.length).to eq(1) }
46
+ it { expect(subject.to_hash.keys.first).to eq("7680316440115") }
47
+ it { expect(subject.to_hash.values.first[:vat]).to eq("2") }
48
+ it { expect(subject.to_hash.values.first[:price]).to eq("8.95") }
49
+ end
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oddb2xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
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-07-08 00:00:00.000000000 Z
12
+ date: 2013-07-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyzip