cxml-ruby 0.6.1 → 0.8.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87772dd26f3194f54c29efa9a993202f79e8102f9bda767bbab87fb43579b9be
4
- data.tar.gz: 227e6acd1a26406c8eaeabdec57326e5ac85ff5a965ff11c0d24650d786c3f51
3
+ metadata.gz: 25b2ba1b0156e96916f3f5aa7788d4b4c0d175452fa91e09b1cb8ad0c96f3c06
4
+ data.tar.gz: 73806c22df23149ca45e46250ecb5fc907ede4826dd7919d3ec922bdd93872cd
5
5
  SHA512:
6
- metadata.gz: 812724e750bb2f67a33fa0cd2acef0d03996d394574ea265f40b90c842f1b5244de9ab7ca74a7acedc38a6dbd0d96030933be52a6ef0cf7d2713328117d660bb
7
- data.tar.gz: 93d10408aaaafaa739ffa6841a83b0ecabe253247cff418684887ac8bfb3fed328e29a649e09d9e1ed043f8aa3d7adfcfbff4104156fb5e80993463d9ed147b6
6
+ metadata.gz: dbaed7a1c8af7c579c0f516422f085e802c3a7e582739dd99a476fc8eb45bea542cefc3b34920cadca1d72e74752d2a38cfc9981601d948167c8dbc050c7bbbb
7
+ data.tar.gz: f14c6e2f0c74c493cf2430daa9a90b948fc967c3268f72f0fd180f0eec0de7499baddaabc95ee417ef72552e33d3c4d75d3956437d7b2c797ad5e394310715d6
@@ -6,13 +6,16 @@ jobs:
6
6
  build:
7
7
 
8
8
  runs-on: ubuntu-latest
9
+ strategy:
10
+ matrix:
11
+ ruby: [ '2.6.x', '2.7.x', '3.0.x' ]
9
12
 
10
13
  steps:
11
14
  - uses: actions/checkout@v2
12
- - name: Set up Ruby 2.6
15
+ - name: Set up Ruby ${{ matrix.ruby }}
13
16
  uses: actions/setup-ruby@v1
14
17
  with:
15
- ruby-version: 2.6.x
18
+ ruby-version: ${{ matrix.ruby }}
16
19
  - name: Test with Rake
17
20
  run: |
18
21
  sudo apt-get install libxml2-utils
data/CHANGELOG.md CHANGED
@@ -14,6 +14,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
 
15
15
  ---
16
16
 
17
+ ## [0.8.2] - 2021-12-21
18
+ ### Fixed
19
+ - Add support for Ruby 3.x.x.
20
+
21
+ ## [0.8.1] - 2021-05-24
22
+ ### Fixed
23
+ - Reorder the attributes output for `PunchoutSetupRequest`.
24
+
25
+ ## [0.8.0] - 2021-04-25
26
+ ### Changed
27
+ - Support continued parsing of child nodes if unknown attribute is encountered with `raise_unknown_elements` set to `false`.
28
+
29
+ ## [0.7.0] - 2021-01-12
30
+ ### Added
31
+ - Support parsing Phone tags.
32
+
17
33
  ## [0.6.1] - 2020-09-04
18
34
  ### Fixed
19
35
  - Handle parsing CDATA tags in cXML content (Thanks @CRiva!).
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class CountryCode < DocumentNode
5
+ accessible_attributes %i[
6
+ iso_country_code
7
+ ]
8
+ end
9
+ end
@@ -35,7 +35,7 @@ module CXML
35
35
  data = data.serializable_hash if data.is_a?(self.class)
36
36
  return unless data.is_a?(Hash)
37
37
 
38
- data.each(&method(:initialize_attribute))
38
+ data.each { |arr| initialize_attribute(*arr) }
39
39
  end
40
40
 
41
41
  def serializable_hash
@@ -121,9 +121,7 @@ module CXML
121
121
  klass = "CXML::#{camelize(key)}"
122
122
  send("#{key}=", Object.const_get(klass).new(val))
123
123
  rescue NoMethodError => e
124
- raise(UnknownAttributeError, e) if CXML.raise_unknown_elements
125
-
126
- CXML.logger.warn(e)
124
+ handle_unknown_elements_error(e)
127
125
  rescue NameError => e
128
126
  raise(e) unless e.to_s.match?(klass)
129
127
 
@@ -136,6 +134,8 @@ module CXML
136
134
  else
137
135
  send("#{key}=", val)
138
136
  end
137
+ rescue NoMethodError => e
138
+ handle_unknown_elements_error(e)
139
139
  end
140
140
 
141
141
  def camelize(string, uppercase_first_letter: true)
@@ -150,5 +150,11 @@ module CXML
150
150
  "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}"
151
151
  end.gsub('/', '::')
152
152
  end
153
+
154
+ def handle_unknown_elements_error(error)
155
+ raise(UnknownAttributeError, error) if CXML.raise_unknown_elements
156
+
157
+ CXML.logger.warn(error)
158
+ end
153
159
  end
154
160
  end
data/lib/cxml/phone.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class Phone < DocumentNode
5
+ accessible_attributes %i[
6
+ name
7
+ ]
8
+
9
+ accessible_nodes %i[
10
+ telephone_number
11
+ ]
12
+ end
13
+ end
@@ -5,12 +5,13 @@ module CXML
5
5
  accessible_attributes %i[
6
6
  operation
7
7
  ]
8
+
8
9
  accessible_nodes %i[
10
+ buyer_cookie
11
+ extrinsics
9
12
  browser_form_post
10
13
  supplier_setup
11
- buyer_cookie
12
14
  ship_to
13
- extrinsics
14
15
  contact
15
16
  ]
16
17
 
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class TelephoneNumber < DocumentNode
5
+ accessible_nodes %i[
6
+ country_code
7
+ area_or_city_code
8
+ number
9
+ ]
10
+ end
11
+ end
data/lib/cxml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CXML
4
- VERSION = '0.6.1'
4
+ VERSION = '0.8.2'
5
5
  end
@@ -82,6 +82,26 @@ describe CXML::Document do
82
82
  end
83
83
  end
84
84
 
85
+ context 'when unknown attribute is present' do
86
+ let(:data) { CXML::Parser.new(data: fixture('document_node_with_unknown_attribute.xml')).parse }
87
+ let(:doc) { CXML::Document.new(data) }
88
+
89
+ it 'does not raise and parses child nodes if CXML.raise_unknown_elements is false' do
90
+ CXML.raise_unknown_elements = false
91
+ -> { doc }.should_not raise_error
92
+
93
+ doc.response.status.code.should eq(200)
94
+ doc.response.status.content.should eq('123456')
95
+
96
+ # Reset `raise_unknown_elements` for future tests
97
+ CXML.raise_unknown_elements = true
98
+ end
99
+
100
+ it 'raises UnknownAttributeError' do
101
+ -> { doc }.should raise_error(CXML::UnknownAttributeError)
102
+ end
103
+ end
104
+
85
105
  context 'when a response document is passed' do
86
106
  let(:data) { CXML::Parser.new(data: fixture('response_status_200.xml')).parse }
87
107
  include_examples :document_has_mandatory_values
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.020/cXML.dtd">
3
+ <cXML xml:lang="en-US" payloadID="test-id" timestamp="2020-09-10T20:32:26+00:00">
4
+ <Response invalid="invalid">
5
+ <Status code="200" text="Ok">123456</Status>
6
+ </Response>
7
+ </cXML>
@@ -39,6 +39,13 @@
39
39
  <Country isoCountryCode="US">United States</Country>
40
40
  </PostalAddress>
41
41
  <Email name="default">jmadden@coupa1.com</Email>
42
+ <Phone name="work">
43
+ <TelephoneNumber>
44
+ <CountryCode isoCountryCode="US">1</CountryCode>
45
+ <AreaOrCityCode>855</AreaOrCityCode>
46
+ <Number>8671234</Number>
47
+ </TelephoneNumber>
48
+ </Phone>
42
49
  </Address>
43
50
  </ShipTo>
44
51
  </PunchOutSetupRequest>
@@ -38,6 +38,8 @@ describe CXML::PunchOutSetupRequest do
38
38
  doc = CXML::Document.new(data)
39
39
  doc.request.punch_out_setup_request.ship_to.should_not be_nil
40
40
  doc.request.punch_out_setup_request.ship_to.address.name.should_not be_nil
41
+ doc.request.punch_out_setup_request.ship_to.address.phone.should_not be_nil
42
+ doc.request.punch_out_setup_request.ship_to.address.phone.telephone_number.should_not be_nil
41
43
  end
42
44
  end
43
45
 
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.6.1
4
+ version: 0.8.2
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-09-04 00:00:00.000000000 Z
12
+ date: 2021-12-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ox
@@ -115,6 +115,7 @@ files:
115
115
  - lib/cxml/confirmation_status.rb
116
116
  - lib/cxml/contact.rb
117
117
  - lib/cxml/country.rb
118
+ - lib/cxml/country_code.rb
118
119
  - lib/cxml/credential.rb
119
120
  - lib/cxml/credential_mac.rb
120
121
  - lib/cxml/deducted_price.rb
@@ -170,6 +171,7 @@ files:
170
171
  - lib/cxml/parser.rb
171
172
  - lib/cxml/payment_term.rb
172
173
  - lib/cxml/period.rb
174
+ - lib/cxml/phone.rb
173
175
  - lib/cxml/postal_address.rb
174
176
  - lib/cxml/protocol.rb
175
177
  - lib/cxml/punch_out_order_message.rb
@@ -195,6 +197,7 @@ files:
195
197
  - lib/cxml/tax_detail.rb
196
198
  - lib/cxml/tax_location.rb
197
199
  - lib/cxml/taxable_amount.rb
200
+ - lib/cxml/telephone_number.rb
198
201
  - lib/cxml/to.rb
199
202
  - lib/cxml/total.rb
200
203
  - lib/cxml/total_allowances.rb
@@ -210,6 +213,7 @@ files:
210
213
  - spec/fixtures/1.2.020-InvoiceDetail.dtd
211
214
  - spec/fixtures/1.2.020-cXML.dtd
212
215
  - spec/fixtures/1.2.037-InvoiceDetail.dtd
216
+ - spec/fixtures/document_node_with_unknown_attribute.xml
213
217
  - spec/fixtures/envelope.xml
214
218
  - spec/fixtures/envelope2.xml
215
219
  - spec/fixtures/invoice_backed_and_unbacked_by_pos.xml
@@ -250,7 +254,7 @@ homepage: https://github.com/officeluv/cxml-ruby
250
254
  licenses:
251
255
  - MIT
252
256
  metadata: {}
253
- post_install_message:
257
+ post_install_message:
254
258
  rdoc_options: []
255
259
  require_paths:
256
260
  - lib
@@ -265,52 +269,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
269
  - !ruby/object:Gem::Version
266
270
  version: '0'
267
271
  requirements: []
268
- rubygems_version: 3.1.2
269
- signing_key:
272
+ rubygems_version: 3.2.3
273
+ signing_key:
270
274
  specification_version: 4
271
275
  summary: Parse/generate documents with the cXML protocol
272
- test_files:
273
- - spec/credential_spec.rb
274
- - spec/cxml_spec.rb
275
- - spec/document_spec.rb
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
281
- - spec/fixtures/envelope.xml
282
- - spec/fixtures/envelope2.xml
283
- - spec/fixtures/invoice_backed_and_unbacked_by_pos.xml
284
- - spec/fixtures/invoice_backed_by_multiple_pos.xml
285
- - spec/fixtures/invoice_taxes_at_line.xml
286
- - spec/fixtures/invoice_taxes_at_line_multiple_taxes.xml
287
- - spec/fixtures/invoice_taxes_at_total.xml
288
- - spec/fixtures/item_in.xml
289
- - spec/fixtures/order_request.xml
290
- - spec/fixtures/punch_out_order_message_doc.xml
291
- - spec/fixtures/punch_out_setup_request_doc.xml
292
- - spec/fixtures/punch_out_setup_request_doc_coupa.xml
293
- - spec/fixtures/punch_out_setup_request_doc_with_ship_to.xml
294
- - spec/fixtures/purchase_order_request_200.xml
295
- - spec/fixtures/request_doc.xml
296
- - spec/fixtures/response_status_200.xml
297
- - spec/fixtures/response_status_400.xml
298
- - spec/header_spec.rb
299
- - spec/invoice_detail_request_spec.rb
300
- - spec/item_detail_spec.rb
301
- - spec/item_id_spec.rb
302
- - spec/item_in_spec.rb
303
- - spec/money_spec.rb
304
- - spec/output/.gitkeep
305
- - spec/parser_spec.rb
306
- - spec/protocol_spec.rb
307
- - spec/punch_out_order_message_header_spec.rb
308
- - spec/punch_out_order_message_spec.rb
309
- - spec/punch_out_setup_request_spec.rb
310
- - spec/purchase_order_request_spec.rb
311
- - spec/request_spec.rb
312
- - spec/response_spec.rb
313
- - spec/sender_spec.rb
314
- - spec/spec_helper.rb
315
- - spec/status_spec.rb
316
- - spec/support/helpers.rb
276
+ test_files: []