lutaml-lml 0.3.0 → 0.3.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: c44e08a243084f376e006dfa845a878267d5867d1c07e9cb2f957cadfdf593af
4
- data.tar.gz: 56b169b4f31489f51713071e48002ec2b0babc8f6b510aa6660e7b02976b0f93
3
+ metadata.gz: c34192e0a5b3532ebb204def3335546bf9accac1852e603b2871290244d53825
4
+ data.tar.gz: ff0dbbc23ce3738f3e0e4e073923701bc214cdebfddcae308ae2dba18c20b345
5
5
  SHA512:
6
- metadata.gz: 12590d775d46b14bbefe7733610b6b60c08ddaa169e6aa3e4010b13979e565d36bde270adffc5e7ef6cdb37c9fbcadedb16d66b0bbc1e6404d74c46da5b2c1ec
7
- data.tar.gz: 1dcf78fc5244594d03992cdb8dd4b2e286c0069741b3985bad2667ea1752eab19534aa16878e9e2c80ac3ab4b0c5c2381756634590a99df1070e72a0e6b7bf83
6
+ metadata.gz: b9de9426a07f60623c905352fee21e78c12c8352a15c924cd3a1085fec39980bc691b1ad6cab840b5dbcf89f01741cd61b2eb48c6e3acdf232295474c70dd784
7
+ data.tar.gz: 1d24bf1caa90301837f55a6e0b3fa68d9b5527647d2634547c89281a9f090ec54ad2836a07d1dd83ee992036d0baa10ce55ae7cf2b33a29da428f3f1bd17854c
@@ -3,6 +3,9 @@
3
3
  module Lutaml
4
4
  module Lml
5
5
  class DataProcessor
6
+ # Normalizes attribute entries from the parse tree: merges
7
+ # comma-form groups, extracts names/types/values, and applies the
8
+ # nested attribute/property structure.
6
9
  module AttributeProcessing
7
10
  EXCLUDED_PASS_THROUGH_KEYS = %i[key value comments add attributes properties type_literal].freeze
8
11
 
@@ -57,7 +60,11 @@ module Lutaml
57
60
  end
58
61
 
59
62
  def merge_collection_value(existing, value)
60
- current = existing.is_a?(Array) ? existing : (existing ? [existing] : [])
63
+ current = if existing.is_a?(Array)
64
+ existing
65
+ else
66
+ (existing ? [existing] : [])
67
+ end
61
68
  current + (value.is_a?(Array) ? value : [value])
62
69
  end
63
70
 
@@ -115,6 +122,7 @@ module Lutaml
115
122
  # `default: "Clear"` uses the colon separator (RS 3001 §Attribute);
116
123
  # the colon lands in the captured name and must not.
117
124
  def strip_argument_colon(name)
125
+ name = name[:string] if name.is_a?(Hash) && name.key?(:string)
118
126
  name.to_s.sub(/:\z/, "")
119
127
  end
120
128
  end
@@ -38,7 +38,14 @@ module Lutaml
38
38
  if member.key?(:definition)
39
39
  (inner[:attributes] ||= []) << { name: 'description', type: unwrap_string(member[:definition]) }
40
40
  elsif member.key?(:instance)
41
- (inner[:instances] ||= []).concat(Array(member[:instance]))
41
+ # The bare `instance { ... }` capture is the instance-body
42
+ # hash; it must go through instance processing so its
43
+ # members become attribute entries, not raw pairs.
44
+ bodies = member[:instance].is_a?(Hash) ? [member[:instance]] : Array(member[:instance])
45
+ bodies.each do |body|
46
+ entry = body.is_a?(Hash) ? process_instance(body) : body
47
+ (inner[:instances] ||= []) << entry
48
+ end
42
49
  elsif member.key?(:attributes)
43
50
  (inner[:properties] ||= []) << member[:attributes]
44
51
  elsif member.key?(:key)
@@ -158,7 +158,19 @@ module Lutaml
158
158
  # the same member shape the bare-identifier shortcut produces.
159
159
  def expand_value_declaration(model, hash)
160
160
  decl = hash.delete(:value_decl) or return
161
- apply_attribute(model, :attributes, decl.fetch(:attributes))
161
+ inner = decl.fetch(:attributes)
162
+
163
+ # Route the value block's members onto the entry: descriptions
164
+ # and payload pairs ride the nested attributes, instance bodies
165
+ # become the entry's instances (RS 3001 §Enums values carrying
166
+ # instances).
167
+ entry = { name: inner[:name] }
168
+ entry[:attributes] = inner[:attributes] if inner[:attributes]
169
+ entry[:properties] = Array(inner[:properties]).flat_map do |pair|
170
+ pair.is_a?(Hash) ? [pair] : Array(pair)
171
+ end if inner[:properties]
172
+ entry[:instances] = inner[:instances] if inner[:instances]
173
+ apply_attribute(model, :attributes, entry)
162
174
  end
163
175
 
164
176
  # Namespace declaration bodies arrive as keyword-line members
@@ -77,7 +77,18 @@ module Lutaml
77
77
  lines.join("\n")
78
78
  end
79
79
 
80
+ def format_key(key)
81
+ key = key.to_s
82
+ return key if key.match?(BARE_WORD)
83
+
84
+ # Same escaping as quote_value: a key may contain any
85
+ # character, and the emitted form must re-parse (issue #78).
86
+ escaped = key.gsub('\\') { |bs| bs * 2 }.gsub('"') { |q| "\\#{q}" }
87
+ "\"#{escaped}\""
88
+ end
89
+
80
90
  def format_value(prefix, key, value, indent)
91
+ key = format_key(key)
81
92
  return "#{prefix}#{key} = ref:(#{value[:reference]})" if reference_value?(value)
82
93
 
83
94
  case value
@@ -142,7 +153,7 @@ module Lutaml
142
153
  # every value is representable in double quotes.
143
154
  # gsub replacement strings re-interpret backslash pairs, so
144
155
  # the backslash doubling uses the block form.
145
- escaped = str.gsub('\\') { |bs| bs + bs }.gsub('"') { |q| '\\' + q }
156
+ escaped = str.gsub('\\') { |bs| bs * 2 }.gsub('"') { |q| "\\#{q}" }
146
157
  "\"#{escaped}\""
147
158
  end
148
159
  end
@@ -65,6 +65,10 @@ module Lutaml
65
65
  # Depth-first walk applying cumulative translate(x,y).
66
66
  def walk(node, dx, dy)
67
67
  node.children.each do |child|
68
+ # Whitespace between elements arrives as text nodes under
69
+ # some moxml adapters; only elements carry geometry.
70
+ next unless child.element?
71
+
68
72
  cdx, cdy = translate_of(child)
69
73
  case child.name
70
74
  when 'g'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Lml
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-lml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-11 00:00:00.000000000 Z
11
+ date: 2026-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.0
19
+ version: 0.8.114
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.0
26
+ version: 0.8.114
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: parsanol
29
29
  requirement: !ruby/object:Gem::Requirement