lutaml-lml 0.3.6 → 0.3.7
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.rb +5 -0
- data/lib/lutaml_lml/version.rb +6 -0
- metadata +12 -164
- data/exe/lutaml-lml +0 -6
- data/exe/lutaml-lml-lsp +0 -11
- data/lib/lutaml/lml/association_label_resolver.rb +0 -52
- data/lib/lutaml/lml/cli.rb +0 -489
- data/lib/lutaml/lml/data_processor/attribute_processing.rb +0 -133
- data/lib/lutaml/lml/data_processor/collection_processing.rb +0 -37
- data/lib/lutaml/lml/data_processor/instance_processing.rb +0 -77
- data/lib/lutaml/lml/data_processor/value_declaration_processing.rb +0 -70
- data/lib/lutaml/lml/data_processor/value_processing.rb +0 -103
- data/lib/lutaml/lml/data_processor/view_processing.rb +0 -26
- data/lib/lutaml/lml/data_processor.rb +0 -59
- data/lib/lutaml/lml/diagnostic.rb +0 -149
- data/lib/lutaml/lml/document_builder.rb +0 -481
- data/lib/lutaml/lml/entity_types.rb +0 -30
- data/lib/lutaml/lml/executor/adapter_helpers.rb +0 -45
- data/lib/lutaml/lml/executor/condition_evaluator.rb +0 -169
- data/lib/lutaml/lml/executor/csv_adapter.rb +0 -88
- data/lib/lutaml/lml/executor/format_adapter.rb +0 -54
- data/lib/lutaml/lml/executor/xml_adapter.rb +0 -102
- data/lib/lutaml/lml/executor.rb +0 -96
- data/lib/lutaml/lml/format/adapter/document.rb +0 -11
- data/lib/lutaml/lml/format/adapter/mapping.rb +0 -31
- data/lib/lutaml/lml/format/adapter/standard_adapter.rb +0 -162
- data/lib/lutaml/lml/format/adapter/transform.rb +0 -11
- data/lib/lutaml/lml/format.rb +0 -29
- data/lib/lutaml/lml/formatter/base.rb +0 -79
- data/lib/lutaml/lml/formatter/canonical.rb +0 -736
- data/lib/lutaml/lml/formatter/elk.rb +0 -45
- data/lib/lutaml/lml/formatter/graphviz/document_formatter.rb +0 -89
- data/lib/lutaml/lml/formatter/graphviz/html_builder.rb +0 -72
- data/lib/lutaml/lml/formatter/graphviz/node_formatter.rb +0 -89
- data/lib/lutaml/lml/formatter/graphviz/relationship_formatter.rb +0 -130
- data/lib/lutaml/lml/formatter/graphviz.rb +0 -90
- data/lib/lutaml/lml/formatter/svg_pdf/path_parser.rb +0 -134
- data/lib/lutaml/lml/formatter/svg_pdf.rb +0 -285
- data/lib/lutaml/lml/formatter.rb +0 -12
- data/lib/lutaml/lml/grammar/lml.artifact.json +0 -14993
- data/lib/lutaml/lml/grammar/lml.parg +0 -389
- data/lib/lutaml/lml/grammar.rb +0 -60
- data/lib/lutaml/lml/has_attributes.rb +0 -14
- data/lib/lutaml/lml/import_resolver.rb +0 -96
- data/lib/lutaml/lml/layout/elk_engine.rb +0 -15
- data/lib/lutaml/lml/layout/elk_graph_builder.rb +0 -129
- data/lib/lutaml/lml/layout/elk_svg_markers.rb +0 -45
- data/lib/lutaml/lml/layout/elk_svg_renderer.rb +0 -119
- data/lib/lutaml/lml/layout/engine.rb +0 -17
- data/lib/lutaml/lml/layout/graph_viz_engine.rb +0 -19
- data/lib/lutaml/lml/layout.rb +0 -12
- data/lib/lutaml/lml/literal_value.rb +0 -32
- data/lib/lutaml/lml/lsp/conversions.rb +0 -78
- data/lib/lutaml/lml/lsp/keywords.rb +0 -43
- data/lib/lutaml/lml/lsp/server.rb +0 -378
- data/lib/lutaml/lml/lsp/store.rb +0 -68
- data/lib/lutaml/lml/lsp/transport.rb +0 -53
- data/lib/lutaml/lml/lsp.rb +0 -16
- data/lib/lutaml/lml/model_compiler/enums.rb +0 -172
- data/lib/lutaml/lml/model_compiler/hydration.rb +0 -123
- data/lib/lutaml/lml/model_compiler/serialization_mappings.rb +0 -188
- data/lib/lutaml/lml/model_compiler/string_formats.rb +0 -42
- data/lib/lutaml/lml/model_compiler/validation.rb +0 -65
- data/lib/lutaml/lml/model_compiler.rb +0 -323
- data/lib/lutaml/lml/models/action.rb +0 -10
- data/lib/lutaml/lml/models/association.rb +0 -29
- data/lib/lutaml/lml/models/cardinality.rb +0 -10
- data/lib/lutaml/lml/models/collection.rb +0 -11
- data/lib/lutaml/lml/models/constraint.rb +0 -23
- data/lib/lutaml/lml/models/data_type.rb +0 -41
- data/lib/lutaml/lml/models/derived_field.rb +0 -14
- data/lib/lutaml/lml/models/diagram.rb +0 -20
- data/lib/lutaml/lml/models/document.rb +0 -84
- data/lib/lutaml/lml/models/enum.rb +0 -38
- data/lib/lutaml/lml/models/fidelity.rb +0 -10
- data/lib/lutaml/lml/models/group.rb +0 -11
- data/lib/lutaml/lml/models/instance.rb +0 -26
- data/lib/lutaml/lml/models/instance_collection.rb +0 -16
- data/lib/lutaml/lml/models/instances_export.rb +0 -10
- data/lib/lutaml/lml/models/instances_import.rb +0 -11
- data/lib/lutaml/lml/models/mapping.rb +0 -15
- data/lib/lutaml/lml/models/mapping_rule.rb +0 -16
- data/lib/lutaml/lml/models/member_field.rb +0 -14
- data/lib/lutaml/lml/models/namespace.rb +0 -16
- data/lib/lutaml/lml/models/operation.rb +0 -26
- data/lib/lutaml/lml/models/operation_parameter.rb +0 -12
- data/lib/lutaml/lml/models/package.rb +0 -26
- data/lib/lutaml/lml/models/primitive_type.rb +0 -33
- data/lib/lutaml/lml/models/reference.rb +0 -23
- data/lib/lutaml/lml/models/serialization_mapping.rb +0 -19
- data/lib/lutaml/lml/models/string_format.rb +0 -16
- data/lib/lutaml/lml/models/top_element_attribute.rb +0 -116
- data/lib/lutaml/lml/models/uml_class.rb +0 -85
- data/lib/lutaml/lml/models/value.rb +0 -15
- data/lib/lutaml/lml/models/view_filter.rb +0 -11
- data/lib/lutaml/lml/models/view_import.rb +0 -11
- data/lib/lutaml/lml/parser.rb +0 -19
- data/lib/lutaml/lml/pipeline.rb +0 -73
- data/lib/lutaml/lml/positioned.rb +0 -13
- data/lib/lutaml/lml/preprocessor.rb +0 -130
- data/lib/lutaml/lml/quoting.rb +0 -60
- data/lib/lutaml/lml/source.rb +0 -49
- data/lib/lutaml/lml/source_position.rb +0 -20
- data/lib/lutaml/lml/symbol_index.rb +0 -200
- data/lib/lutaml/lml/transform.rb +0 -119
- data/lib/lutaml/lml/types/text_type.rb +0 -28
- data/lib/lutaml/lml/types.rb +0 -10
- data/lib/lutaml/lml/validator.rb +0 -458
- data/lib/lutaml/lml/version.rb +0 -7
- data/lib/lutaml/lml/view_resolution.rb +0 -32
- data/lib/lutaml/lml/view_resolver.rb +0 -48
- data/lib/lutaml/lml/yaml_parser.rb +0 -17
- data/lib/lutaml/lml.rb +0 -130
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
module Format
|
|
6
|
-
module Adapter
|
|
7
|
-
# Serializes instance data to and from LML instance syntax on
|
|
8
|
-
# behalf of the lutaml-model format registry (to_lml/from_lml on
|
|
9
|
-
# compiled classes).
|
|
10
|
-
class StandardAdapter < Document
|
|
11
|
-
TYPE_KEY = "__type__"
|
|
12
|
-
|
|
13
|
-
include Lutaml::Lml::Quoting
|
|
14
|
-
|
|
15
|
-
def self.parse(data, _options = {})
|
|
16
|
-
return data if data.is_a?(Hash)
|
|
17
|
-
|
|
18
|
-
input = data.is_a?(IO) ? data : StringIO.new(data.to_s)
|
|
19
|
-
doc = Lutaml::Lml.parse_document(input)
|
|
20
|
-
instance_to_hash(doc.instance)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def to_lml(_options = {})
|
|
24
|
-
attrs = @attributes.dup
|
|
25
|
-
type_name = attrs.delete(TYPE_KEY) || "Data"
|
|
26
|
-
body = hash_to_lml_body(attrs)
|
|
27
|
-
"instance #{type_name} {\n#{body}\n}"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def self.instance_to_hash(instance)
|
|
31
|
-
return nil unless instance
|
|
32
|
-
|
|
33
|
-
hash = {}
|
|
34
|
-
hash[TYPE_KEY] = instance.type if instance.type
|
|
35
|
-
|
|
36
|
-
instance.each_attribute do |name, value, nested|
|
|
37
|
-
if nested.any?
|
|
38
|
-
hashes = nested.map { |i| instance_to_hash(i) }
|
|
39
|
-
hash[name] = nested.one? ? hashes.first : hashes
|
|
40
|
-
elsif value.is_a?(Array)
|
|
41
|
-
hash[name] = value.map { |v| primitive_value(v) }
|
|
42
|
-
elsif !value.nil?
|
|
43
|
-
hash[name] = primitive_value(value)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
hash.merge!(instance_to_hash(instance.instance)) if instance.instance
|
|
48
|
-
|
|
49
|
-
hash
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def self.primitive_value(val)
|
|
53
|
-
case val
|
|
54
|
-
when TrueClass, FalseClass, Integer, Float then val
|
|
55
|
-
else val.to_s
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
private_class_method :primitive_value
|
|
59
|
-
|
|
60
|
-
def hash_to_lml_body(hash, indent = 1)
|
|
61
|
-
lines = []
|
|
62
|
-
prefix = " " * indent
|
|
63
|
-
|
|
64
|
-
hash.each do |key, value|
|
|
65
|
-
next if key == TYPE_KEY
|
|
66
|
-
|
|
67
|
-
lines << format_value(prefix, key, value, indent)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
lines.join("\n")
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def format_key(key)
|
|
74
|
-
quote_scalar(key)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def format_value(prefix, key, value, indent)
|
|
78
|
-
key = format_key(key)
|
|
79
|
-
return "#{prefix}#{key} = ref:(#{value[:reference]})" if reference_value?(value)
|
|
80
|
-
|
|
81
|
-
case value
|
|
82
|
-
when Array
|
|
83
|
-
format_array(prefix, key, value, indent)
|
|
84
|
-
when Hash
|
|
85
|
-
format_nested(prefix, key, value, indent)
|
|
86
|
-
when Float
|
|
87
|
-
"#{prefix}#{key} = #{number_scalar(value)}"
|
|
88
|
-
when TrueClass, FalseClass, Integer
|
|
89
|
-
"#{prefix}#{key} = #{value}"
|
|
90
|
-
else
|
|
91
|
-
"#{prefix}#{key} = #{quote_value(value)}"
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def format_array(prefix, key, items, indent)
|
|
96
|
-
elements = items.map do |item|
|
|
97
|
-
if reference_value?(item)
|
|
98
|
-
" ref:(#{item[:reference]})"
|
|
99
|
-
else
|
|
100
|
-
case item
|
|
101
|
-
when Hash
|
|
102
|
-
format_nested_instance(item, indent + 1)
|
|
103
|
-
else
|
|
104
|
-
" #{quote_value(item)}"
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
inner = elements.join(",\n")
|
|
110
|
-
"#{prefix}#{key} = [\n#{inner}\n#{prefix}]"
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def format_nested(prefix, key, hash, indent)
|
|
114
|
-
type_name = hash.fetch(TYPE_KEY, "")
|
|
115
|
-
inner = hash_to_lml_body(hash, indent + 1)
|
|
116
|
-
type_clause = type_name.empty? ? "" : " #{type_name}"
|
|
117
|
-
"#{prefix}#{key} = instance#{type_clause} {\n#{inner}\n#{prefix}}"
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def format_nested_instance(hash, indent)
|
|
121
|
-
prefix = " " * indent
|
|
122
|
-
type_name = hash.fetch(TYPE_KEY, "")
|
|
123
|
-
inner = hash_to_lml_body(hash, indent + 1)
|
|
124
|
-
type_clause = type_name.empty? ? "" : " #{type_name}"
|
|
125
|
-
"#{prefix}instance#{type_clause} {\n#{inner}\n#{prefix}}"
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
# RS 3001 par. Value type: a `reference` map is the wire form of a
|
|
129
|
-
# reference literal; it emits as `ref:(path)`, never as a nested
|
|
130
|
-
# instance.
|
|
131
|
-
def reference_value?(value)
|
|
132
|
-
value.is_a?(Hash) && value.keys == [:reference]
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def quote_value(val)
|
|
136
|
-
return number_scalar(val) if val.is_a?(Float)
|
|
137
|
-
return val.to_s if val.is_a?(Numeric) || val.is_a?(TrueClass) || val.is_a?(FalseClass)
|
|
138
|
-
|
|
139
|
-
# RS 3001 §String values: escape backslash and double quote;
|
|
140
|
-
# every value is representable in double quotes. A bare word
|
|
141
|
-
# is only safe when the parser reads it back as the same
|
|
142
|
-
# string — `null`, booleans, and digit-leading tokens are
|
|
143
|
-
# data literals (and digit-led words do not re-parse).
|
|
144
|
-
str = val.to_s
|
|
145
|
-
return str if safe_bare_string?(str)
|
|
146
|
-
|
|
147
|
-
quote_always(str)
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
private
|
|
151
|
-
|
|
152
|
-
def safe_bare_string?(str)
|
|
153
|
-
return false unless str.match?(Lutaml::Lml::Quoting::BARE_WORD)
|
|
154
|
-
return false if str.match?(/\A(?:true|false|null)\z/)
|
|
155
|
-
|
|
156
|
-
!str.match?(/\A\d/)
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
data/lib/lutaml/lml/format.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
module Format
|
|
6
|
-
module Adapter
|
|
7
|
-
autoload :Document, "lutaml/lml/format/adapter/document"
|
|
8
|
-
autoload :Mapping, "lutaml/lml/format/adapter/mapping"
|
|
9
|
-
autoload :Transform, "lutaml/lml/format/adapter/transform"
|
|
10
|
-
autoload :StandardAdapter, "lutaml/lml/format/adapter/standard_adapter"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# ExportTransformer is defined at Lutaml::Model::ExportTransformer but
|
|
17
|
-
# referenced as bare ExportTransformer from KeyValue::Transform. Bridge the gap
|
|
18
|
-
# so constant resolution succeeds for the :lml format's to_lml path.
|
|
19
|
-
unless Lutaml::KeyValue.const_defined?(:ExportTransformer)
|
|
20
|
-
Lutaml::KeyValue::ExportTransformer = Lutaml::Model::ExportTransformer
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
Lutaml::Model::FormatRegistry.register(
|
|
24
|
-
:lml,
|
|
25
|
-
mapping_class: Lutaml::Lml::Format::Adapter::Mapping,
|
|
26
|
-
adapter_class: Lutaml::Lml::Format::Adapter::StandardAdapter,
|
|
27
|
-
transformer: Lutaml::Lml::Format::Adapter::Transform,
|
|
28
|
-
key_value: true,
|
|
29
|
-
)
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Formatter
|
|
5
|
-
class << self
|
|
6
|
-
def all
|
|
7
|
-
@all ||= []
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def find_by_name(name)
|
|
11
|
-
name = name.to_sym
|
|
12
|
-
all.detect { |formatter_class| formatter_class.formatter_name == name }
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
class Base
|
|
17
|
-
FORMAT_HANDLERS = {
|
|
18
|
-
Lml::TopElementAttribute => :format_attribute,
|
|
19
|
-
Lml::Operation => :format_operation,
|
|
20
|
-
Lml::Association => :format_relationship,
|
|
21
|
-
Lml::Document => :format_document,
|
|
22
|
-
Lml::DataType => :format_class,
|
|
23
|
-
Lml::UmlClass => :format_class,
|
|
24
|
-
Lml::Enum => :format_class
|
|
25
|
-
}.freeze
|
|
26
|
-
|
|
27
|
-
class << self
|
|
28
|
-
def inherited(subclass)
|
|
29
|
-
super
|
|
30
|
-
Formatter.all << subclass
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def format(node, attributes = {})
|
|
34
|
-
new(attributes).format(node)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Registry key for Formatter.find_by_name. Deliberately not
|
|
38
|
-
# `name` — shadowing Class#name breaks Ruby internals and any
|
|
39
|
-
# library that legitimately calls .name on these classes.
|
|
40
|
-
def formatter_name
|
|
41
|
-
to_s.split('::').last.downcase.to_sym
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
include Lml::HasAttributes
|
|
46
|
-
|
|
47
|
-
def initialize(attributes = {})
|
|
48
|
-
update_attributes(attributes)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def name
|
|
52
|
-
self.class.formatter_name
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
attr_reader :type
|
|
56
|
-
|
|
57
|
-
def type=(value)
|
|
58
|
-
@type = value.to_s.strip.downcase.to_sym
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def format(node)
|
|
62
|
-
dispatch_format(node)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def dispatch_format(node)
|
|
66
|
-
handler = FORMAT_HANDLERS.find { |type, _| node.is_a?(type) }&.last
|
|
67
|
-
raise Lml::Error, "no format handler for #{node.class}" unless handler
|
|
68
|
-
|
|
69
|
-
public_send(handler, node)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def format_attribute(_node) = raise(NotImplementedError)
|
|
73
|
-
def format_operation(_node) = raise(NotImplementedError)
|
|
74
|
-
def format_relationship(_node) = raise(NotImplementedError)
|
|
75
|
-
def format_class(_node) = raise(NotImplementedError)
|
|
76
|
-
def format_document(_node) = raise(NotImplementedError)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|