lutaml-lml 0.1.6 → 0.1.8
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/lib/lutaml/lml/data_processor/instance_processing.rb +5 -0
- data/lib/lutaml/lml/document_builder.rb +80 -9
- data/lib/lutaml/lml/grammar/lml.artifact.json +2914 -1888
- data/lib/lutaml/lml/grammar/lml.parg +20 -4
- data/lib/lutaml/lml/grammar.rb +6 -3
- data/lib/lutaml/lml/model_compiler.rb +224 -36
- data/lib/lutaml/lml/models/data_type.rb +2 -0
- data/lib/lutaml/lml/models/derived_field.rb +14 -0
- data/lib/lutaml/lml/models/enum.rb +1 -0
- data/lib/lutaml/lml/models/instance.rb +1 -0
- data/lib/lutaml/lml/models/mapping.rb +15 -0
- data/lib/lutaml/lml/models/member_field.rb +12 -0
- data/lib/lutaml/lml/models/package.rb +1 -0
- data/lib/lutaml/lml/models/string_format.rb +16 -0
- data/lib/lutaml/lml/models/uml_class.rb +3 -0
- data/lib/lutaml/lml/version.rb +1 -1
- data/lib/lutaml/lml.rb +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d249342f8fa771fc6acc926a4a4fa75eb2f2532ccd4461ea0452c7930d6a0372
|
|
4
|
+
data.tar.gz: 7a852a63a20c02124a7c34c66501f749801711968239ef8e7fd7d92df4b96abb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2acbed3dc1c0da892d6344ec7ff87147d13d24de03b44ae8c8ff3ba136a3941a20ac6b95e4d1e4445c52b91ca0997e1d7c9a7425fd92713b954874ce2dd0abf3
|
|
7
|
+
data.tar.gz: a9f5844e875eba16ef0f3bdcb2f10ff62fe377935cce06f35c7e92571a8e7cfa9a43782919b2661f161cb4be6fffe73b67fc10bbcb9c56a73ab7ec36b2daec48
|
|
@@ -13,6 +13,7 @@ module Lutaml
|
|
|
13
13
|
|
|
14
14
|
INSTANCE_FIELD_HANDLERS = {
|
|
15
15
|
instance_type: :handle_instance_type,
|
|
16
|
+
isa: :handle_instance_isa,
|
|
16
17
|
instance: :handle_instance_nested,
|
|
17
18
|
attributes: :handle_instance_attributes,
|
|
18
19
|
template: :handle_instance_template
|
|
@@ -45,6 +46,10 @@ module Lutaml
|
|
|
45
46
|
result[:type] = process_value(value).last
|
|
46
47
|
end
|
|
47
48
|
|
|
49
|
+
def handle_instance_isa(value, result)
|
|
50
|
+
result[:isa] = process_value(value).last
|
|
51
|
+
end
|
|
52
|
+
|
|
48
53
|
def handle_instance_nested(value, result)
|
|
49
54
|
result[:instance] = process_instance(value)
|
|
50
55
|
end
|
|
@@ -20,7 +20,11 @@ module Lutaml
|
|
|
20
20
|
constraint: ::Lutaml::Lml::Constraint,
|
|
21
21
|
value: ::Lutaml::Lml::Value,
|
|
22
22
|
view_import: ::Lutaml::Lml::ViewImport,
|
|
23
|
-
view_filter: ::Lutaml::Lml::ViewFilter
|
|
23
|
+
view_filter: ::Lutaml::Lml::ViewFilter,
|
|
24
|
+
mapping: ::Lutaml::Lml::Mapping,
|
|
25
|
+
string_format: ::Lutaml::Lml::StringFormat,
|
|
26
|
+
derived_field: ::Lutaml::Lml::DerivedField,
|
|
27
|
+
member_field: ::Lutaml::Lml::MemberField
|
|
24
28
|
}.freeze
|
|
25
29
|
|
|
26
30
|
attr_reader :registry
|
|
@@ -31,7 +35,8 @@ module Lutaml
|
|
|
31
35
|
|
|
32
36
|
FACTORY_KEYS = %i[
|
|
33
37
|
document package class enum data_type diagram view_import view_filter
|
|
34
|
-
attribute association operation constraint value cardinality
|
|
38
|
+
attribute association operation constraint value cardinality mapping
|
|
39
|
+
string_format derived_field
|
|
35
40
|
].freeze
|
|
36
41
|
|
|
37
42
|
MEMBER_KEY_MAP = {
|
|
@@ -45,7 +50,9 @@ module Lutaml
|
|
|
45
50
|
associations: :association,
|
|
46
51
|
operations: :operation,
|
|
47
52
|
constraints: :constraint,
|
|
48
|
-
values: :value
|
|
53
|
+
values: :value,
|
|
54
|
+
mappings: :mapping,
|
|
55
|
+
member_fields: :member_field
|
|
49
56
|
}.freeze
|
|
50
57
|
|
|
51
58
|
FACTORY_KEYS.each do |key|
|
|
@@ -95,6 +102,9 @@ module Lutaml
|
|
|
95
102
|
end
|
|
96
103
|
|
|
97
104
|
def add_members(model, hash)
|
|
105
|
+
expand_mapping_section(model, hash)
|
|
106
|
+
expand_class_declarations(model, hash)
|
|
107
|
+
expand_enum_member_fields(model, hash)
|
|
98
108
|
MEMBER_KEY_MAP.each do |plural_key, singular_key|
|
|
99
109
|
data = hash.delete(plural_key)
|
|
100
110
|
next if data.nil?
|
|
@@ -106,6 +116,69 @@ module Lutaml
|
|
|
106
116
|
remap_filter_keys(hash, model)
|
|
107
117
|
end
|
|
108
118
|
|
|
119
|
+
# A mapping section arrives as a bare member hash
|
|
120
|
+
# { format:, maps: [{ wire:, to: }] }; expand to one Mapping entry
|
|
121
|
+
# per map line, each carrying the format, and strip the section keys
|
|
122
|
+
def expand_mapping_section(model, hash)
|
|
123
|
+
section = mapping_section_from(hash)
|
|
124
|
+
return unless section
|
|
125
|
+
|
|
126
|
+
section[:maps].to_a.each do |line|
|
|
127
|
+
model.wire_mappings << build(:mapping,
|
|
128
|
+
format: section[:format],
|
|
129
|
+
wire: unquote(line[:wire]),
|
|
130
|
+
to: unquote(line[:to]))
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def mapping_section_from(hash)
|
|
135
|
+
return { format: unquote(hash[:format]), maps: hash.delete(:maps) } if hash.key?(:maps)
|
|
136
|
+
|
|
137
|
+
hash.delete(:mappings)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# quoted_string captures nest their value under :string
|
|
141
|
+
def unquote(value)
|
|
142
|
+
value.is_a?(Hash) && value.key?(:string) ? value[:string] : value
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# L5/L7 declaration members: string_format sections (class- or
|
|
146
|
+
# models-level), derive lines, and enum member_fields blocks
|
|
147
|
+
def expand_class_declarations(model, hash)
|
|
148
|
+
if (section = hash.delete(:string_format))
|
|
149
|
+
model.string_formats << build_string_format(section)
|
|
150
|
+
end
|
|
151
|
+
if (section = hash.delete(:default_string_formats))
|
|
152
|
+
model.default_string_formats << build_string_format(section)
|
|
153
|
+
end
|
|
154
|
+
return unless (derived = hash.delete(:derived_field))
|
|
155
|
+
|
|
156
|
+
model.derived_fields << build(:derived_field,
|
|
157
|
+
name: derived[:name],
|
|
158
|
+
type: unquote(derived[:type]))
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def expand_enum_member_fields(model, hash)
|
|
162
|
+
decl = hash.delete(:member_fields_decl)
|
|
163
|
+
return unless decl && model.is_a?(Enum)
|
|
164
|
+
|
|
165
|
+
decl[:member_fields].to_a.each do |field|
|
|
166
|
+
model.member_fields << build(:member_field,
|
|
167
|
+
name: field[:name],
|
|
168
|
+
type: unquote(field[:member_field_type]))
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def build_string_format(section)
|
|
173
|
+
items = section[:items].to_a.each_with_object({}) do |item, acc|
|
|
174
|
+
acc[item[:key].to_sym] = unquote(item[:value])
|
|
175
|
+
end
|
|
176
|
+
build(:string_format,
|
|
177
|
+
format: unquote(section[:format]),
|
|
178
|
+
artifact: items[:artifact],
|
|
179
|
+
root: items[:root])
|
|
180
|
+
end
|
|
181
|
+
|
|
109
182
|
def ensure_collection(model, key)
|
|
110
183
|
model.public_send(key) || begin
|
|
111
184
|
model.public_send("#{key}=", [])
|
|
@@ -116,12 +189,10 @@ module Lutaml
|
|
|
116
189
|
def remap_filter_keys(hash, model)
|
|
117
190
|
return unless model.is_a?(Document)
|
|
118
191
|
|
|
119
|
-
if hash.key?(:show_list)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
hash[:hide_filter] = build_view_filter(hash.delete(:hide_list))
|
|
124
|
-
end
|
|
192
|
+
hash[:show_filter] = build_view_filter(hash.delete(:show_list)) if hash.key?(:show_list)
|
|
193
|
+
return unless hash.key?(:hide_list)
|
|
194
|
+
|
|
195
|
+
hash[:hide_filter] = build_view_filter(hash.delete(:hide_list))
|
|
125
196
|
end
|
|
126
197
|
|
|
127
198
|
def build_view_filter(entity_names)
|