lutaml-model 0.3.22 → 0.3.24

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
  SHA256:
3
- metadata.gz: 3d740eaaa52ff7479fc3e0f23aa3fb308bd8b61f820ac22f036b31f24d696989
4
- data.tar.gz: '0294c66616f39e84e931b626f776ee555450ac962018bf3189200467761e2707'
3
+ metadata.gz: 18b88c11cf49c7a08199273885c202ea29ebc3aa9f470d1bffc177282b1d588b
4
+ data.tar.gz: 75b4d90ea27a62c55ca6643a80358ab80a0d7636b4c6511ecafa526e0855f294
5
5
  SHA512:
6
- metadata.gz: 56675b27dfbf1fa77986f5793f48dd8f5b53b69d5fa989209f79c1f2827ee0ed46eeeeecaed72904be2053a12c4653dab5d06dd0b1401754a06e9a0a9db8fc0f
7
- data.tar.gz: cedbee96c00a6d43065df43acc8ee7d5262bd03265fda81fc85698c1abb7c00f0989c7cc9d1afe1f5038b4323e886adadd0609250dd9f952e2e1b33fcc9b7fee
6
+ metadata.gz: 16d82eb3101b2e22f5d2e9197d3fdea94c787675d489a4a3792e7548f4275c6c926a87cf6a6242ee4672526ba1f0d3eb26c8fd629341240d4a93ab6d614d522f
7
+ data.tar.gz: 1369a5abd8dd616e28b4a8c5b7db3369634bf37c701c0cca76b20182df922e18e120c754bb486745f7d47df0bff983bdf6cb2e3651713e08aebe5c1eeb87297f
data/.rubocop_todo.yml CHANGED
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-11-03 22:29:56 UTC using RuboCop version 1.66.1.
3
+ # on 2024-11-08 07:37:57 UTC using RuboCop version 1.66.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 124
9
+ # Offense count: 127
10
10
  # This cop supports safe autocorrection (--autocorrect).
11
11
  # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
12
12
  # URISchemes: http, https
@@ -30,7 +30,7 @@ Lint/DuplicateMethods:
30
30
  Exclude:
31
31
  - 'lib/lutaml/model/attribute.rb'
32
32
 
33
- # Offense count: 37
33
+ # Offense count: 38
34
34
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
35
35
  Metrics/AbcSize:
36
36
  Exclude:
@@ -64,7 +64,7 @@ Metrics/CyclomaticComplexity:
64
64
  - 'lib/lutaml/model/xml_adapter/ox_adapter.rb'
65
65
  - 'lib/lutaml/model/xml_adapter/xml_document.rb'
66
66
 
67
- # Offense count: 51
67
+ # Offense count: 50
68
68
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
69
69
  Metrics/MethodLength:
70
70
  Max: 46
@@ -124,7 +124,7 @@ RSpec/MultipleDescribes:
124
124
  - 'spec/lutaml/model/xml_adapter/xml_namespace_spec.rb'
125
125
  - 'spec/lutaml/model/xml_adapter_spec.rb'
126
126
 
127
- # Offense count: 125
127
+ # Offense count: 123
128
128
  RSpec/MultipleExpectations:
129
129
  Max: 14
130
130
 
@@ -200,11 +200,10 @@ module Lutaml
200
200
 
201
201
  def cast(value, format, options = {})
202
202
  value ||= [] if collection?
203
- instance = options[:instance]
204
203
 
205
204
  if value.is_a?(Array)
206
205
  value.map do |v|
207
- cast(v, format, instance: instance)
206
+ cast(v, format, options)
208
207
  end
209
208
  elsif type <= Serialize && value.is_a?(Hash)
210
209
  type.apply_mappings(value, format, options)
@@ -310,6 +310,7 @@ module Lutaml
310
310
  def apply_xml_mapping(doc, instance, options = {})
311
311
  return instance unless doc
312
312
 
313
+ options[:default_namespace] = mappings_for(:xml)&.namespace_uri if options[:default_namespace].nil?
313
314
  mappings = mappings_for(:xml).mappings
314
315
 
315
316
  if doc.is_a?(Array)
@@ -340,14 +341,14 @@ module Lutaml
340
341
  doc.node.inner_xml
341
342
  elsif rule.content_mapping?
342
343
  doc["text"]
343
- elsif doc.key_exist?(rule.namespaced_name)
344
- doc.fetch(rule.namespaced_name)
344
+ elsif doc.key_exist?(rule.namespaced_name(options[:default_namespace]))
345
+ doc.fetch(rule.namespaced_name(options[:default_namespace]))
345
346
  else
346
347
  defaults_used << rule.to
347
348
  rule.to_value_for(instance)
348
349
  end
349
350
 
350
- value = normalize_xml_value(value, rule)
351
+ value = normalize_xml_value(value, rule, options)
351
352
  rule.deserialize(instance, value, attributes, self)
352
353
  end
353
354
 
@@ -388,7 +389,7 @@ module Lutaml
388
389
  instance
389
390
  end
390
391
 
391
- def normalize_xml_value(value, rule)
392
+ def normalize_xml_value(value, rule, options = {})
392
393
  attr = attribute_for_rule(rule)
393
394
 
394
395
  value = [value].compact if attr&.collection? && !value.is_a?(Array)
@@ -405,11 +406,11 @@ module Lutaml
405
406
 
406
407
  return value unless cast_value?(attr, rule)
407
408
 
409
+ options.merge(caller_class: self, mixed_content: rule.mixed_content)
408
410
  attr.cast(
409
411
  value,
410
412
  :xml,
411
- caller_class: self,
412
- mixed_content: rule.mixed_content,
413
+ options,
413
414
  )
414
415
  end
415
416
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.3.22"
5
+ VERSION = "0.3.24"
6
6
  end
7
7
  end
@@ -73,7 +73,7 @@ module Lutaml
73
73
  end
74
74
  end
75
75
 
76
- def namespaced_name
76
+ def namespaced_name(parent_namespace = nil)
77
77
  if name == "lang"
78
78
  "#{prefix}:#{name}"
79
79
  elsif namespace_set? || @attribute
@@ -81,7 +81,7 @@ module Lutaml
81
81
  elsif default_namespace
82
82
  "#{default_namespace}:#{name}"
83
83
  else
84
- name
84
+ [parent_namespace, name].compact.join(":")
85
85
  end
86
86
  end
87
87
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.22
4
+ version: 0.3.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-05 00:00:00.000000000 Z
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor