cxml-ruby 0.3.0 → 0.6.1
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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -0
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +18 -0
- data/cxml-ruby.gemspec +1 -0
- data/lib/cxml-ruby.rb +1 -1
- data/lib/cxml/address.rb +4 -1
- data/lib/cxml/comment.rb +9 -0
- data/lib/cxml/contact.rb +4 -1
- data/lib/cxml/credential.rb +1 -1
- data/lib/cxml/deposit_amount.rb +9 -0
- data/lib/cxml/document.rb +11 -6
- data/lib/cxml/document_node.rb +14 -6
- data/lib/cxml/invoice_detail_item.rb +11 -11
- data/lib/cxml/invoice_detail_item_reference.rb +3 -1
- data/lib/cxml/invoice_detail_request_header.rb +5 -5
- data/lib/cxml/invoice_detail_summary.rb +6 -4
- data/lib/cxml/item_detail.rb +5 -1
- data/lib/cxml/order_request_header.rb +11 -10
- data/lib/cxml/parser.rb +30 -2
- data/lib/cxml/postal_address.rb +1 -1
- data/lib/cxml/version.rb +1 -1
- data/spec/document_spec.rb +33 -1
- data/spec/fixtures/1.2.014-cXML.dtd +4184 -0
- data/spec/fixtures/1.2.020-InvoiceDetail.dtd +4590 -0
- data/spec/fixtures/1.2.020-cXML.dtd +4917 -0
- data/spec/fixtures/1.2.037-InvoiceDetail.dtd +7287 -0
- data/spec/fixtures/invoice_taxes_at_line_multiple_taxes.xml +1 -3
- data/spec/fixtures/item_in.xml +2 -1
- data/spec/fixtures/{order_request.cxml → order_request.xml} +0 -0
- data/spec/fixtures/punch_out_order_message_doc.xml +1 -1
- data/spec/fixtures/response_status_200.xml +1 -1
- data/spec/fixtures/response_status_400.xml +2 -2
- data/spec/invoice_detail_request_spec.rb +21 -1
- data/spec/item_in_spec.rb +5 -0
- data/spec/money_spec.rb +8 -0
- data/spec/output/.gitkeep +0 -0
- data/spec/punch_out_order_message_spec.rb +5 -0
- data/spec/punch_out_setup_request_spec.rb +1 -0
- data/spec/purchase_order_request_spec.rb +6 -1
- data/spec/sender_spec.rb +6 -0
- data/spec/spec_helper.rb +27 -0
- metadata +21 -9
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
|
3
|
-
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2
|
3
|
+
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.037/InvoiceDetail.dtd">
|
4
4
|
|
5
5
|
<cXML version="1.0" payloadID="1240598937@SUBDOMAIN.coupahost.com" timestamp="2018-05-04T01:24:51-07:00">
|
6
6
|
|
@@ -176,11 +176,9 @@
|
|
176
176
|
|
177
177
|
<DiscountPercent percent="1" />
|
178
178
|
|
179
|
-
<DiscountDueDays>1</DiscountDueDays>
|
180
179
|
|
181
180
|
</Discount>
|
182
181
|
|
183
|
-
<NetDueDays>1</NetDueDays>
|
184
182
|
|
185
183
|
</PaymentTerm>
|
186
184
|
|
data/spec/fixtures/item_in.xml
CHANGED
@@ -4,8 +4,9 @@
|
|
4
4
|
<SupplierPartAuxiliaryID>lkajsdflsdf</SupplierPartAuxiliaryID>
|
5
5
|
</ItemID>
|
6
6
|
<ItemDetail>
|
7
|
-
<Description xml:lang="en"
|
7
|
+
<Description xml:lang="en"><![CDATA[AGENDA MAGAZINE RACK A4 CHARCOAL 25990]]></Description>
|
8
8
|
<UnitOfMeasure>EA</UnitOfMeasure>
|
9
9
|
<UnitPrice> <Money currency="GBP">5.35</Money> </UnitPrice>
|
10
|
+
<Classification domain="UNSPSC">44000000</Classification>
|
10
11
|
</ItemDetail>
|
11
12
|
</ItemIn>
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<?xml version="1.0"?>
|
2
|
-
<cxml version="1.2.
|
2
|
+
<cxml version="1.2.020" payloadID="1346769469000.process.162998590@officedepot.com" timestamp="2012-09-04T02:37:49-05:00">
|
3
3
|
<Header>
|
4
4
|
<From>
|
5
5
|
<Credential domain="NetworkID">
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<cXML version="1.2.
|
2
|
+
<cXML version="1.2.020" payloadID="1346769469000.process.162998590@officedepot.com" timestamp="2012-09-04T02:37:49-05:00">
|
3
3
|
<Response>
|
4
4
|
<Status code="200" text="OK"/>
|
5
5
|
<PunchOutSetupResponse>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<cXML version="1.2.
|
1
|
+
<cXML version="1.2.020" payloadID="1352382581000.process.454701738@domain.com" timestamp="2012-11-08T01:49:41-05:00">
|
2
2
|
<Response>
|
3
3
|
<Status code="400" text="java.lang.Exception: missing required parameter 'document'"/>
|
4
4
|
</Response>
|
5
|
-
</cXML>
|
5
|
+
</cXML>
|
@@ -50,34 +50,54 @@ describe CXML::InvoiceDetailRequest do
|
|
50
50
|
data = CXML::Parser.new(data: fixture('invoice_taxes_at_line.xml')).parse
|
51
51
|
doc = CXML::Document.new(data)
|
52
52
|
CXML::Parser.new(data: doc.to_xml).parse.should eq(data)
|
53
|
+
next unless test_for_xmllint
|
54
|
+
|
55
|
+
lint_doc_with_dtd(doc).should be true
|
53
56
|
end
|
54
57
|
it 'serializes the same output' do
|
55
58
|
data = CXML::Parser.new(data: fixture('invoice_backed_and_unbacked_by_pos.xml')).parse
|
56
59
|
doc = CXML::Document.new(data)
|
57
60
|
CXML::Parser.new(data: doc.to_xml).parse.should eq(data)
|
61
|
+
next unless test_for_xmllint
|
62
|
+
|
63
|
+
lint_doc_with_dtd(doc).should be true
|
58
64
|
end
|
59
65
|
it 'serializes the same output' do
|
60
66
|
data = CXML::Parser.new(data: fixture('invoice_backed_by_multiple_pos.xml')).parse
|
61
67
|
doc = CXML::Document.new(data)
|
62
68
|
CXML::Parser.new(data: doc.to_xml).parse.should eq(data)
|
69
|
+
next unless test_for_xmllint
|
70
|
+
|
71
|
+
lint_doc_with_dtd(doc).should be true
|
63
72
|
end
|
64
73
|
it 'serializes the same output' do
|
65
74
|
data = CXML::Parser.new(data: fixture('invoice_taxes_at_line_multiple_taxes.xml')).parse
|
66
75
|
doc = CXML::Document.new(data)
|
67
76
|
CXML::Parser.new(data: doc.to_xml).parse.should eq(data)
|
77
|
+
next unless test_for_xmllint
|
78
|
+
|
79
|
+
lint_doc_with_dtd(doc).should be true
|
68
80
|
end
|
69
81
|
it 'serializes the same output' do
|
70
82
|
fixture_xml = fixture('invoice_taxes_at_total.xml')
|
71
83
|
data = CXML::Parser.new(data: fixture_xml).parse
|
72
84
|
doc = CXML::Document.new(data)
|
73
85
|
CXML::Parser.new(data: doc.to_xml).parse.should eq(data)
|
86
|
+
next unless test_for_xmllint
|
87
|
+
|
88
|
+
lint_doc_with_dtd(doc).should be true
|
74
89
|
end
|
75
90
|
it 'serializes from an instance' do
|
76
91
|
money = CXML::Money.new(amount: '5', currency: 'USD')
|
77
92
|
summary = CXML::InvoiceDetailSummary.new(gross_amount: CXML::GrossAmount.new(money: money))
|
78
93
|
instance = described_class.new(invoice_detail_summary: summary)
|
79
94
|
data = CXML::Request.new(invoice_detail_request: instance)
|
80
|
-
doc = CXML::Document.new(
|
95
|
+
doc = CXML::Document.new(
|
96
|
+
request: data,
|
97
|
+
header: CXML::Header.new,
|
98
|
+
dtd: 'InvoiceDetail',
|
99
|
+
payload_id: 'foo'
|
100
|
+
)
|
81
101
|
parsed = CXML::Parser.new(data: doc.to_xml).parse
|
82
102
|
parsed[:request][:invoice_detail_request]
|
83
103
|
.should eq(instance.serializable_hash)
|
data/spec/item_in_spec.rb
CHANGED
@@ -35,5 +35,10 @@ describe CXML::ItemIn do
|
|
35
35
|
item_in_output_data[:item_id].should_not be_empty
|
36
36
|
item_in_output_data[:item_detail].should_not be_empty
|
37
37
|
end
|
38
|
+
it 'validates against the DTD' do
|
39
|
+
next unless test_for_xmllint
|
40
|
+
|
41
|
+
lint_doc_with_dtd(CXML::Document.new.from_xml(output_xml)).should be true
|
42
|
+
end
|
38
43
|
end
|
39
44
|
end
|
data/spec/money_spec.rb
CHANGED
@@ -38,5 +38,13 @@ describe CXML::Money do
|
|
38
38
|
it 'contains the required nodes' do
|
39
39
|
money_output_data[:currency].should_not be_empty
|
40
40
|
end
|
41
|
+
|
42
|
+
it 'can render non-string values' do
|
43
|
+
CXML::Document.new(message: { punch_out_order_message: {
|
44
|
+
punch_out_order_message_header: {
|
45
|
+
total: { money: { content: 12.3 } },
|
46
|
+
},
|
47
|
+
} }).to_xml
|
48
|
+
end
|
41
49
|
end
|
42
50
|
end
|
File without changes
|
@@ -36,5 +36,10 @@ describe CXML::PunchOutOrderMessage do
|
|
36
36
|
punch_out_order_message_output_data[:buyer_cookie].should_not be_empty
|
37
37
|
punch_out_order_message_output_data.should include(:item_in)
|
38
38
|
end
|
39
|
+
it 'validates against the DTD' do
|
40
|
+
next unless test_for_xmllint
|
41
|
+
|
42
|
+
lint_doc_with_dtd(CXML::Document.new.from_xml(output_xml)).should be true
|
43
|
+
end
|
39
44
|
end
|
40
45
|
end
|
@@ -31,6 +31,7 @@ describe CXML::PunchOutSetupRequest do
|
|
31
31
|
punch_out_setup_request_coupa.extrinsics.should be_a Array
|
32
32
|
punch_out_setup_request_coupa.extrinsics.first.should be_a CXML::Extrinsic
|
33
33
|
punch_out_setup_request_coupa.extrinsics.first.name.should_not be_nil
|
34
|
+
doc_coupa.header.sender.credential.shared_secret.should eq('test')
|
34
35
|
end
|
35
36
|
it 'sets the shipping attributes when present' do
|
36
37
|
data = CXML::Parser.new(data: fixture('punch_out_setup_request_doc_with_ship_to.xml')).parse
|
@@ -19,6 +19,11 @@ describe CXML::OrderRequest do
|
|
19
19
|
order_request_output_data[:item_out].should be_a Array
|
20
20
|
order_request_output_data[:item_out].length.should eq 2
|
21
21
|
end
|
22
|
+
it 'validates against the DTD' do
|
23
|
+
next unless test_for_xmllint
|
24
|
+
|
25
|
+
lint_doc_with_dtd(doc).should be true
|
26
|
+
end
|
22
27
|
end
|
23
28
|
describe '#initialize' do
|
24
29
|
it 'sets the required nodes' do
|
@@ -27,7 +32,7 @@ describe CXML::OrderRequest do
|
|
27
32
|
order_request.items_out.first.should_not be_nil
|
28
33
|
end
|
29
34
|
it 'sets the required nodes via another order request' do
|
30
|
-
request = CXML::Document.new.from_xml(fixture('order_request.
|
35
|
+
request = CXML::Document.new.from_xml(fixture('order_request.xml')).request
|
31
36
|
request.order_request.order_request_header.should_not be_nil
|
32
37
|
request.order_request.order_request_header.order_id.should_not be_nil
|
33
38
|
request.order_request.items_out.first.should_not be_nil
|
data/spec/sender_spec.rb
CHANGED
@@ -26,5 +26,11 @@ describe CXML::Sender do
|
|
26
26
|
sender_output_data[:user_agent].should_not be_empty
|
27
27
|
sender_output_data[:credential].should_not be_empty
|
28
28
|
end
|
29
|
+
|
30
|
+
it 'validates against the DTD' do
|
31
|
+
next unless test_for_xmllint
|
32
|
+
|
33
|
+
lint_doc_with_dtd(CXML::Document.new.from_xml(output_xml)).should be true
|
34
|
+
end
|
29
35
|
end
|
30
36
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,6 +9,7 @@ Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
|
|
9
9
|
|
10
10
|
RSpec.configure do |config|
|
11
11
|
config.expect_with(:rspec) { |c| c.syntax = :should }
|
12
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
12
13
|
end
|
13
14
|
|
14
15
|
def fixture_path(filename = nil)
|
@@ -19,3 +20,29 @@ end
|
|
19
20
|
def fixture(file)
|
20
21
|
File.read(File.join(fixture_path, file))
|
21
22
|
end
|
23
|
+
|
24
|
+
def dtd_path_from_url(url)
|
25
|
+
return 'spec/fixtures/1.2.037-cXML.dtd' unless url
|
26
|
+
|
27
|
+
match = url.match(%r{/(\d+\.\d+\.\d+)/(\w+\.dtd)}).to_a
|
28
|
+
file = "spec/fixtures/#{match.last(2).join('-')}"
|
29
|
+
return file if File.exist?(file)
|
30
|
+
|
31
|
+
system("curl #{url} -O && mv #{match.last} #{file}")
|
32
|
+
file
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_for_xmllint
|
36
|
+
return true if system('type xmllint > /dev/null 2>&1')
|
37
|
+
|
38
|
+
puts 'skipping DTD validation without xmllint'
|
39
|
+
false
|
40
|
+
end
|
41
|
+
|
42
|
+
def lint_doc_with_dtd(doc)
|
43
|
+
file = "spec/output/#{rand}.xml"
|
44
|
+
File.open(file, 'w') { |f| f.puts doc.to_xml }
|
45
|
+
linted = system("xmllint --noout --dtdvalid #{dtd_path_from_url(doc.dtd_url)} #{file}")
|
46
|
+
File.delete(file) if File.exist?(file)
|
47
|
+
linted
|
48
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cxml-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Beckman
|
8
8
|
- Eleni Chappen
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-04
|
12
|
+
date: 2020-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ox
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/cxml/browser_form_post.rb
|
109
109
|
- lib/cxml/charge.rb
|
110
110
|
- lib/cxml/classification.rb
|
111
|
+
- lib/cxml/comment.rb
|
111
112
|
- lib/cxml/confirmation_header.rb
|
112
113
|
- lib/cxml/confirmation_item.rb
|
113
114
|
- lib/cxml/confirmation_request.rb
|
@@ -118,6 +119,7 @@ files:
|
|
118
119
|
- lib/cxml/credential_mac.rb
|
119
120
|
- lib/cxml/deducted_price.rb
|
120
121
|
- lib/cxml/deduction_amount.rb
|
122
|
+
- lib/cxml/deposit_amount.rb
|
121
123
|
- lib/cxml/description.rb
|
122
124
|
- lib/cxml/discount.rb
|
123
125
|
- lib/cxml/discount_percent.rb
|
@@ -204,6 +206,10 @@ files:
|
|
204
206
|
- spec/cxml_spec.rb
|
205
207
|
- spec/document_spec.rb
|
206
208
|
- spec/fixtures/.gitkeep
|
209
|
+
- spec/fixtures/1.2.014-cXML.dtd
|
210
|
+
- spec/fixtures/1.2.020-InvoiceDetail.dtd
|
211
|
+
- spec/fixtures/1.2.020-cXML.dtd
|
212
|
+
- spec/fixtures/1.2.037-InvoiceDetail.dtd
|
207
213
|
- spec/fixtures/envelope.xml
|
208
214
|
- spec/fixtures/envelope2.xml
|
209
215
|
- spec/fixtures/invoice_backed_and_unbacked_by_pos.xml
|
@@ -212,7 +218,7 @@ files:
|
|
212
218
|
- spec/fixtures/invoice_taxes_at_line_multiple_taxes.xml
|
213
219
|
- spec/fixtures/invoice_taxes_at_total.xml
|
214
220
|
- spec/fixtures/item_in.xml
|
215
|
-
- spec/fixtures/order_request.
|
221
|
+
- spec/fixtures/order_request.xml
|
216
222
|
- spec/fixtures/punch_out_order_message_doc.xml
|
217
223
|
- spec/fixtures/punch_out_setup_request_doc.xml
|
218
224
|
- spec/fixtures/punch_out_setup_request_doc_coupa.xml
|
@@ -227,6 +233,7 @@ files:
|
|
227
233
|
- spec/item_id_spec.rb
|
228
234
|
- spec/item_in_spec.rb
|
229
235
|
- spec/money_spec.rb
|
236
|
+
- spec/output/.gitkeep
|
230
237
|
- spec/parser_spec.rb
|
231
238
|
- spec/protocol_spec.rb
|
232
239
|
- spec/punch_out_order_message_header_spec.rb
|
@@ -243,7 +250,7 @@ homepage: https://github.com/officeluv/cxml-ruby
|
|
243
250
|
licenses:
|
244
251
|
- MIT
|
245
252
|
metadata: {}
|
246
|
-
post_install_message:
|
253
|
+
post_install_message:
|
247
254
|
rdoc_options: []
|
248
255
|
require_paths:
|
249
256
|
- lib
|
@@ -251,15 +258,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
258
|
requirements:
|
252
259
|
- - ">="
|
253
260
|
- !ruby/object:Gem::Version
|
254
|
-
version: '
|
261
|
+
version: '2.4'
|
255
262
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
263
|
requirements:
|
257
264
|
- - ">="
|
258
265
|
- !ruby/object:Gem::Version
|
259
266
|
version: '0'
|
260
267
|
requirements: []
|
261
|
-
rubygems_version: 3.
|
262
|
-
signing_key:
|
268
|
+
rubygems_version: 3.1.2
|
269
|
+
signing_key:
|
263
270
|
specification_version: 4
|
264
271
|
summary: Parse/generate documents with the cXML protocol
|
265
272
|
test_files:
|
@@ -267,6 +274,10 @@ test_files:
|
|
267
274
|
- spec/cxml_spec.rb
|
268
275
|
- spec/document_spec.rb
|
269
276
|
- spec/fixtures/.gitkeep
|
277
|
+
- spec/fixtures/1.2.014-cXML.dtd
|
278
|
+
- spec/fixtures/1.2.020-InvoiceDetail.dtd
|
279
|
+
- spec/fixtures/1.2.020-cXML.dtd
|
280
|
+
- spec/fixtures/1.2.037-InvoiceDetail.dtd
|
270
281
|
- spec/fixtures/envelope.xml
|
271
282
|
- spec/fixtures/envelope2.xml
|
272
283
|
- spec/fixtures/invoice_backed_and_unbacked_by_pos.xml
|
@@ -275,7 +286,7 @@ test_files:
|
|
275
286
|
- spec/fixtures/invoice_taxes_at_line_multiple_taxes.xml
|
276
287
|
- spec/fixtures/invoice_taxes_at_total.xml
|
277
288
|
- spec/fixtures/item_in.xml
|
278
|
-
- spec/fixtures/order_request.
|
289
|
+
- spec/fixtures/order_request.xml
|
279
290
|
- spec/fixtures/punch_out_order_message_doc.xml
|
280
291
|
- spec/fixtures/punch_out_setup_request_doc.xml
|
281
292
|
- spec/fixtures/punch_out_setup_request_doc_coupa.xml
|
@@ -290,6 +301,7 @@ test_files:
|
|
290
301
|
- spec/item_id_spec.rb
|
291
302
|
- spec/item_in_spec.rb
|
292
303
|
- spec/money_spec.rb
|
304
|
+
- spec/output/.gitkeep
|
293
305
|
- spec/parser_spec.rb
|
294
306
|
- spec/protocol_spec.rb
|
295
307
|
- spec/punch_out_order_message_header_spec.rb
|