xmlconv 1.1.6 → 1.1.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: b944e983c5846919a052589ef034b9f3213f87a7
4
- data.tar.gz: 886ccc0284adc4c66a48efd6f0a5f9f59ce5866f
3
+ metadata.gz: af623000ac8163705c7fff8b81e9c7a5016f0ceb
4
+ data.tar.gz: 2ec74af40347dd5681fae3e28863d8b2dfbff777
5
5
  SHA512:
6
- metadata.gz: 34d6f9ca0710e0c360f36e4167626c6afea002881ee15eacc31b786300f5f41d8aee21a649e392e4c4f865457cbe7a10cec27f778d7b882ebf94b53e14d88979
7
- data.tar.gz: b9a1eee2de8c25e0507da64e8621850126bae94b86a54a38c580b25703ac205b3c9859a50677fe7b9250335d7003f7224d9dc2411ec7b2f25ffe33e90338368c
6
+ metadata.gz: cdc78b73d3bc35b0219aa4ba25b493a979be9ff8ee25412fcdc58ed527a02f7068de7a7742fe8a849b48a9ffd92e3da4d8e9d2824c7eed304d60b32408f73221
7
+ data.tar.gz: e788fe936a974a20f9813bb4d109d66e8689eafbf8c3033988fcfc9794cf9a6bd52ae5cf300b69d5b9d238c8ffc17849ff53fe6fa7dffa557823828d79fef468
@@ -1,3 +1,7 @@
1
+ === 1.1.7 / 21.06.2017
2
+
3
+ * Added unittest and fix for handling ISO-8859 files
4
+
1
5
  === 1.1.6 / 20.06.2017
2
6
 
3
7
  * Trace transaction handling via SBSM.debug
@@ -14,7 +14,7 @@ module XmlConv
14
14
  if session.request_method.eql?('POST')
15
15
  xml_src = session.post_content
16
16
  SBSM.debug "XmlConv::State::Login POST params were #{session.request_params}"
17
- SBSM.debug " xml_src now #{xml_src}"
17
+ SBSM.debug " xml_src #{xml_src.encoding} now #{xml_src}"
18
18
  unless xml_src.length == 0
19
19
  transaction = XmlConv::Util::Transaction.new
20
20
  transaction.domain = session.server_name
@@ -5,6 +5,7 @@
5
5
  require 'odba'
6
6
  require 'xmlconv/util/destination'
7
7
  require 'xmlconv/util/mail'
8
+ require 'sbsm/logger'
8
9
 
9
10
  module XmlConv
10
11
  module Util
@@ -26,11 +27,8 @@ module XmlConv
26
27
  reader_instance = Conversion.const_get(@reader)
27
28
  writer_instance = Conversion.const_get(@writer)
28
29
  @start_time = Time.now
29
- if !@input.valid_encoding?
30
- @input = @input.encode("UTF-8", :invalid=>:replace, :replace=>"?")
31
- else
32
- @input = @input.encode("UTF-8")
33
- end
30
+ @input = @input.force_encoding("UTF-8")
31
+ @input = @input.encode("UTF-8", :invalid=>:replace, :replace=>"?") if !@input.valid_encoding?
34
32
  @input.gsub!(/\t+|\s+/, ' ')
35
33
  input_model = reader_instance.parse(@input)
36
34
  @arguments ||= []
@@ -45,23 +43,6 @@ module XmlConv
45
43
  @destination.forget_credentials!
46
44
  end
47
45
 
48
- # Assumes its encoding once as ISO-8859-1 (latin1) at here,
49
- # Because input_body is passed from ruby 1.8.6
50
- def encode(input_body)
51
- src = input_body.to_s
52
- begin
53
- # ISO-8859-1 (latin1) and WINDOWS-1252
54
- src.encode('ISO-8859-1').force_encoding('UTF-8')
55
- rescue Encoding::InvalidByteSequenceError,
56
- Encoding::UndefinedConversionError
57
- begin
58
- src.force_encoding('ISO-8859-1').encode('UTF-8')
59
- rescue
60
- src
61
- end
62
- end
63
- end
64
-
65
46
  def invoice_ids
66
47
  @model.invoices.collect do |inv|
67
48
  inv.invoice_id.last.to_s.gsub /^0+/, ''
@@ -1,3 +1,3 @@
1
1
  module XmlConv
2
- VERSION = '1.1.6'
2
+ VERSION = '1.1.7'
3
3
  end
@@ -0,0 +1,28 @@
1
+ <?xml version "1.0" encoding="utf-8"?>
2
+ <customerOrder xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ compressionDesired="false" productDescriptionDesired="true"
5
+ backLogDesired="true" language="fr"
6
+ roundUpForCondition="true" version="1.0">
7
+ <client number="99" password="" />
8
+ <orderHeader deliveryDate="2017-06-06"
9
+ referenceNumber="060620172" mannerOfTransport="tour"
10
+ phoneCallDesired="false" urgent="false">
11
+ <deliveryAddress line1="136, Ch. De-La-Montagne"
12
+ line4="Pharmacie GOUDA" line5PostalCode="1224"
13
+ line5City="Ch�ne-Bougeries">
14
+ <addressLine2And3Text line2="Ch�ne-Bougeries" line3="GOUDA"
15
+ />
16
+ </deliveryAddress>
17
+ </orderHeader>
18
+ <orderLines>
19
+ <productOrderLine orderQuantity="10"
20
+ roundUpForCondition="true" backLogDesired="true">
21
+ <pharmaCode id="3463433" />
22
+ </productOrderLine>
23
+ <productOrderLine orderQuantity="2"
24
+ roundUpForCondition="true" backLogDesired="true">
25
+ <pharmaCode id="3029702" />
26
+ </productOrderLine>
27
+ </orderLines>
28
+ </customerOrder>
@@ -4,6 +4,10 @@
4
4
  $: << File.dirname(__FILE__)
5
5
  $: << File.expand_path('..', File.dirname(__FILE__))
6
6
  $: << File.expand_path('../../lib', File.dirname(__FILE__))
7
+ begin
8
+ require 'pry'
9
+ rescue LoadError
10
+ end
7
11
 
8
12
  require 'xmlconv/util/transaction'
9
13
  require 'mail'
@@ -100,6 +104,37 @@ module XmlConv
100
104
  assert_equal(2, ::Mail::TestMailer.deliveries.size)
101
105
  assert_equal([to_addr, 'bar'], ::Mail::TestMailer.deliveries.last.to)
102
106
  end
107
+ def test_execute_utf_8_problem
108
+ input = flexmock('input')
109
+ reader = flexmock('reader')
110
+ model = flexmock('model')
111
+ writer = flexmock('writer')
112
+ output = Array.new
113
+ destination = flexmock('destination')
114
+ destination.should_receive(:deliver).with(output).once.and_return(output.to_s)
115
+ destination.should_receive(:forget_credentials!).once
116
+ test_data_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data'))
117
+ content = File.open("#{test_data_dir}/umlaut_iso8859.xml", 'rb').read
118
+ @transaction.input = content
119
+ @transaction.reader = reader
120
+ @transaction.writer = writer
121
+ @transaction.destination = destination
122
+ reader.should_receive(:parse).and_return(input)
123
+ reader.should_receive(:convert).with(input).once.and_return(model)
124
+ writer.should_receive(:convert).with(model).once.and_return(output)
125
+ time1 = Time.now
126
+ result = @transaction.execute
127
+ time2 = Time.now
128
+ assert(/Ch\?ne-Bougeries/.match(@transaction.input))
129
+ assert_raises("ArgumentError: invalid byte sequence in UTF-8") { /Ch?ne-Bougeries/.match(content) }
130
+ assert_equal(reader, @transaction.reader)
131
+ assert_equal(model, @transaction.model)
132
+ assert_equal(writer, @transaction.writer)
133
+ assert_equal([], output)
134
+ assert_equal("", result)
135
+ assert_in_delta(time1, @transaction.start_time, 0.001)
136
+ assert_in_delta(time2, @transaction.commit_time, 0.001)
137
+ end
103
138
  end
104
139
  end
105
140
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmlconv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz, Niklaus Giger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-20 00:00:00.000000000 Z
11
+ date: 2017-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: odba
@@ -386,6 +386,7 @@ files:
386
386
  - test/data/polling.yaml
387
387
  - test/data/sandoz.xundart@bbmb.ch.20110524001038.928592
388
388
  - test/data/simple_email.txt
389
+ - test/data/umlaut_iso8859.xml
389
390
  - test/suite.rb
390
391
  - test/test_i2/address.rb
391
392
  - test/test_i2/date.rb
@@ -442,6 +443,7 @@ test_files:
442
443
  - test/data/polling.yaml
443
444
  - test/data/sandoz.xundart@bbmb.ch.20110524001038.928592
444
445
  - test/data/simple_email.txt
446
+ - test/data/umlaut_iso8859.xml
445
447
  - test/suite.rb
446
448
  - test/test_i2/address.rb
447
449
  - test/test_i2/date.rb