lutaml-lml 0.3.6 → 0.3.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.rb +5 -0
- data/lib/lutaml_lml/version.rb +6 -0
- metadata +14 -166
- 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,11 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
class InstancesImport < Lutaml::Model::Serializable
|
|
6
|
-
attribute :format_type, :string
|
|
7
|
-
attribute :file, :string
|
|
8
|
-
attribute :attributes, "Lutaml::Lml::TopElementAttribute", collection: true, default: []
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# A lutaml-model wire-name mapping declared inside an LML class:
|
|
6
|
-
# mapping yaml { map "full-name", to: "name" }
|
|
7
|
-
# One entry per map line; `format` is the target serialization
|
|
8
|
-
# (yaml, xml, json, toml, csv).
|
|
9
|
-
class Mapping < Lutaml::Model::Serializable
|
|
10
|
-
attribute :format, :string
|
|
11
|
-
attribute :wire, :string
|
|
12
|
-
attribute :to, :string
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# One line of a serialization mapping: what kind of mapping (element,
|
|
6
|
-
# attribute, content, map, key, value), the serialization-side wire
|
|
7
|
-
# name, the model attribute it binds, and the qualifier mode for
|
|
8
|
-
# key/value collections (to_instance, as_attribute).
|
|
9
|
-
class MappingRule < Lutaml::Model::Serializable
|
|
10
|
-
attribute :kind, :string
|
|
11
|
-
attribute :wire, :string
|
|
12
|
-
attribute :field, :string
|
|
13
|
-
attribute :mode, :string
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# A typed payload field declared on an enum:
|
|
6
|
-
# member_fields { abbreviation String urn_segment String }
|
|
7
|
-
class MemberField < Lutaml::Model::Serializable
|
|
8
|
-
include Lutaml::Lml::Positioned
|
|
9
|
-
|
|
10
|
-
attribute :name, :string
|
|
11
|
-
attribute :type, :string
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# RS 3010 extension: a declared XML namespace (uri + optional prefix).
|
|
6
|
-
# The compiler generates the corresponding Lutaml::Model::XmlNamespace
|
|
7
|
-
# subclass for the compiled model namespace.
|
|
8
|
-
class Namespace < Lutaml::Model::Serializable
|
|
9
|
-
include Lutaml::Lml::Positioned
|
|
10
|
-
|
|
11
|
-
attribute :name, :string
|
|
12
|
-
attribute :uri, :string
|
|
13
|
-
attribute :prefix, :string
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# A class operation with parameters and a return type.
|
|
6
|
-
class Operation < Lutaml::Model::Serializable
|
|
7
|
-
include Lutaml::Lml::Positioned
|
|
8
|
-
|
|
9
|
-
# From TopElement
|
|
10
|
-
attribute :name, :string
|
|
11
|
-
attribute :definition, Lutaml::Lml::Types::TextType
|
|
12
|
-
attribute :keyword, :string
|
|
13
|
-
attribute :stereotype, :string, collection: true, default: -> { [] }
|
|
14
|
-
attribute :visibility, :string, default: "public"
|
|
15
|
-
|
|
16
|
-
# From Operation
|
|
17
|
-
attribute :id, :string
|
|
18
|
-
attribute :return_type, :string
|
|
19
|
-
attribute :parameter_type, :string
|
|
20
|
-
attribute :is_static, :boolean, default: false
|
|
21
|
-
attribute :is_abstract, :boolean, default: false
|
|
22
|
-
attribute :owned_parameter, "Lutaml::Lml::OperationParameter", collection: true,
|
|
23
|
-
default: -> { [] }
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
class OperationParameter < Lutaml::Model::Serializable
|
|
6
|
-
attribute :name, :string
|
|
7
|
-
attribute :type, :string
|
|
8
|
-
attribute :direction, :string, default: "in"
|
|
9
|
-
attribute :default, :string
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# A package grouping model definitions.
|
|
6
|
-
class Package < Lutaml::Model::Serializable
|
|
7
|
-
include Lutaml::Lml::Positioned
|
|
8
|
-
|
|
9
|
-
# From TopElement
|
|
10
|
-
attribute :name, :string
|
|
11
|
-
attribute :definition, Lutaml::Lml::Types::TextType
|
|
12
|
-
attribute :keyword, :string
|
|
13
|
-
attribute :stereotype, :string, collection: true, default: -> { [] }
|
|
14
|
-
attribute :visibility, :string, default: "public"
|
|
15
|
-
|
|
16
|
-
# From Package
|
|
17
|
-
attribute :contents, :string, collection: true, default: -> { [] }
|
|
18
|
-
attribute :classes, "Lutaml::Lml::UmlClass", collection: true, default: -> { [] }
|
|
19
|
-
attribute :enums, "Lutaml::Lml::Enum", collection: true, default: -> { [] }
|
|
20
|
-
attribute :data_types, "Lutaml::Lml::DataType", collection: true, default: -> { [] }
|
|
21
|
-
attribute :packages, "Lutaml::Lml::Package", collection: true, default: -> { [] }
|
|
22
|
-
attribute :diagrams, "Lutaml::Lml::Diagram", collection: true, default: -> { [] }
|
|
23
|
-
attribute :default_string_formats, "Lutaml::Lml::StringFormat", collection: true, default: -> { [] }
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# A primitive type declaration.
|
|
6
|
-
class PrimitiveType < Lutaml::Model::Serializable
|
|
7
|
-
include Lutaml::Lml::Positioned
|
|
8
|
-
|
|
9
|
-
# Primitives in LML are name-only entities, but the formatter
|
|
10
|
-
# accesses the same attributes as DataType via format_class.
|
|
11
|
-
attribute :name, :string
|
|
12
|
-
attribute :keyword, :string, default: "primitive"
|
|
13
|
-
attribute :definition, Lutaml::Lml::Types::TextType
|
|
14
|
-
attribute :stereotype, :string, collection: true, default: -> { [] }
|
|
15
|
-
attribute :visibility, :string, default: "public"
|
|
16
|
-
attribute :is_abstract, :boolean, default: false
|
|
17
|
-
attribute :attributes, "Lutaml::Lml::TopElementAttribute", collection: true,
|
|
18
|
-
default: -> { [] }
|
|
19
|
-
attribute :operations, "Lutaml::Lml::Operation", collection: true,
|
|
20
|
-
default: -> { [] }
|
|
21
|
-
attribute :associations, "Lutaml::Lml::Association", collection: true,
|
|
22
|
-
default: -> { [] }
|
|
23
|
-
|
|
24
|
-
def self.entity_type
|
|
25
|
-
:primitives
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def self.classifiable?
|
|
29
|
-
true
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# RS 3001 par. Value type: a reference to another instance
|
|
6
|
-
# (`reference:(path)` / `ref:(path)`). The attribute's value slot keeps
|
|
7
|
-
# its primitive wire shape (a `reference` hash); this is the typed
|
|
8
|
-
# domain view of it, built at one canonical point
|
|
9
|
-
# (TopElementAttribute#reference) so validation and serialization
|
|
10
|
-
# consume structured references instead of re-sniffing hashes.
|
|
11
|
-
class Reference < Lutaml::Model::Serializable
|
|
12
|
-
attribute :path, :string
|
|
13
|
-
|
|
14
|
-
def segments
|
|
15
|
-
@segments ||= path.to_s.split('.')
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def to_s
|
|
19
|
-
path.to_s
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# RS 3010 extension: a serialization mapping declared separately from
|
|
6
|
-
# its class and linked by target name —
|
|
7
|
-
# mapping xml Ceramic { element "ceramic" … }
|
|
8
|
-
class SerializationMapping < Lutaml::Model::Serializable
|
|
9
|
-
include Lutaml::Lml::Positioned
|
|
10
|
-
|
|
11
|
-
attribute :format, :string
|
|
12
|
-
attribute :target, :string
|
|
13
|
-
attribute :element_name, :string
|
|
14
|
-
attribute :namespace_ref, :string
|
|
15
|
-
attribute :mixed_content, :boolean, default: false
|
|
16
|
-
attribute :rules, 'Lutaml::Lml::MappingRule', collection: true, default: -> { [] }
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# A grammar-backed string format declared on a class (or as a
|
|
6
|
-
# models-block default): a thin reference — the artifact owns the
|
|
7
|
-
# capture maps and render specs; LML only names format, artifact,
|
|
8
|
-
# and entry root.
|
|
9
|
-
# string_format :pubid { artifact "pubid/iso" root "iso_identifier" }
|
|
10
|
-
class StringFormat < Lutaml::Model::Serializable
|
|
11
|
-
attribute :format, :string
|
|
12
|
-
attribute :artifact, :string
|
|
13
|
-
attribute :root, :string
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# An attribute declaration or instance assignment entry.
|
|
6
|
-
class TopElementAttribute < Lutaml::Model::Serializable
|
|
7
|
-
include Lutaml::Lml::Positioned
|
|
8
|
-
|
|
9
|
-
# Core attributes
|
|
10
|
-
attribute :name, :string
|
|
11
|
-
attribute :visibility, :string, default: "public"
|
|
12
|
-
attribute :type, :string
|
|
13
|
-
attribute :id, :string
|
|
14
|
-
attribute :contain, :string
|
|
15
|
-
attribute :static, :string
|
|
16
|
-
attribute :cardinality, "Lutaml::Lml::Cardinality"
|
|
17
|
-
attribute :literal, :boolean, default: false
|
|
18
|
-
attribute :is_derived, :boolean, default: false
|
|
19
|
-
attribute :is_static, :boolean, default: false
|
|
20
|
-
attribute :is_read_only, :boolean, default: false
|
|
21
|
-
attribute :stereotype, :string, collection: true, default: -> { [] }
|
|
22
|
-
attribute :definition, Lutaml::Lml::Types::TextType
|
|
23
|
-
attribute :association, :string
|
|
24
|
-
attribute :default, :string
|
|
25
|
-
attribute :value_set, :string, collection: true, default: -> { [] }
|
|
26
|
-
attribute :pattern, :string
|
|
27
|
-
# `as :element` / `as :attribute`: the XML node kind (issue #49)
|
|
28
|
-
attribute :xml_role, :string
|
|
29
|
-
|
|
30
|
-
# LML-specific attributes
|
|
31
|
-
attribute :properties, "Lutaml::Lml::TopElementAttribute", collection: true, default: -> { [] }
|
|
32
|
-
attribute :value, LiteralValue
|
|
33
|
-
attribute :attributes, "Lutaml::Lml::TopElementAttribute", collection: true, default: -> { [] }
|
|
34
|
-
attribute :extended, :boolean
|
|
35
|
-
attribute :instances, "Lutaml::Lml::Instance", collection: true, default: -> { [] }
|
|
36
|
-
|
|
37
|
-
# Declared in full because a mapping block replaces the defaults. The
|
|
38
|
-
# rules below are the defaults, 1:1, except for `value`.
|
|
39
|
-
#
|
|
40
|
-
# `value` needs custom methods because a list literal reaches the model
|
|
41
|
-
# as a bare Array, and lutaml-model refuses one on a non-collection
|
|
42
|
-
# attribute: Attribute#cast splits it, then valid_collection! raises
|
|
43
|
-
# CollectionTrueMissingError. A custom `from` returns before that check,
|
|
44
|
-
# so a non-empty list survives a round trip without changing the
|
|
45
|
-
# serialized form. An empty list still does not: the transform skips a
|
|
46
|
-
# blank value before reaching the custom method, so `[]` reloads as nil.
|
|
47
|
-
key_value do
|
|
48
|
-
map "name", to: :name
|
|
49
|
-
map "visibility", to: :visibility
|
|
50
|
-
map "type", to: :type
|
|
51
|
-
map "id", to: :id
|
|
52
|
-
map "contain", to: :contain
|
|
53
|
-
map "static", to: :static
|
|
54
|
-
map "cardinality", to: :cardinality
|
|
55
|
-
map "literal", to: :literal
|
|
56
|
-
map "is_derived", to: :is_derived
|
|
57
|
-
map "is_static", to: :is_static
|
|
58
|
-
map "is_read_only", to: :is_read_only
|
|
59
|
-
map "stereotype", to: :stereotype
|
|
60
|
-
map "definition", to: :definition
|
|
61
|
-
map "association", to: :association
|
|
62
|
-
map "default", to: :default
|
|
63
|
-
map "value_set", to: :value_set
|
|
64
|
-
map "pattern", to: :pattern
|
|
65
|
-
map "xml_role", to: :xml_role
|
|
66
|
-
map "properties", to: :properties
|
|
67
|
-
map "value", to: :value, with: { to: :value_to, from: :value_from }
|
|
68
|
-
map "attributes", to: :attributes
|
|
69
|
-
map "extended", to: :extended
|
|
70
|
-
map "instances", to: :instances
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# Public because lutaml-model invokes mapping methods via public_send.
|
|
74
|
-
#
|
|
75
|
-
# Skipping nil keeps the key out of the output, which is what the default
|
|
76
|
-
# mapping does. `false` is a real literal, so the guard tests for nil
|
|
77
|
-
# rather than truthiness.
|
|
78
|
-
def value_to(model, doc)
|
|
79
|
-
literal = model.value
|
|
80
|
-
return if literal.nil?
|
|
81
|
-
|
|
82
|
-
doc["value"] = unwrap_literal(literal)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# lutaml-model runs this on a throwaway mapper instance, so `self` is not
|
|
86
|
-
# the object being deserialized - `model` is. Writing to `self.value`
|
|
87
|
-
# here would update an object that is discarded a moment later.
|
|
88
|
-
def value_from(model, value)
|
|
89
|
-
model.value = value
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# RS 3001 par. Value type: the typed view of a reference value
|
|
93
|
-
# (`reference:(...)` / `ref:(...)`). Nil for every other value shape;
|
|
94
|
-
# for a list of references, the first reference.
|
|
95
|
-
def reference
|
|
96
|
-
literal = value.respond_to?(:value) ? value.value : value
|
|
97
|
-
cargo = literal.is_a?(::Array) ? literal.first : literal
|
|
98
|
-
cargo = cargo.value if cargo.is_a?(LiteralValue)
|
|
99
|
-
return nil unless cargo.is_a?(::Hash) && cargo[:reference]
|
|
100
|
-
|
|
101
|
-
Reference.new(path: cargo[:reference].to_s)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
private
|
|
105
|
-
|
|
106
|
-
# A LiteralValue sits at the top level for a map literal, and inside the
|
|
107
|
-
# array for a list of references. Writing one through unwrapped raises
|
|
108
|
-
# ArgumentError in the adapter.
|
|
109
|
-
def unwrap_literal(value)
|
|
110
|
-
return value.map { |item| unwrap_literal(item) } if value.is_a?(::Array)
|
|
111
|
-
|
|
112
|
-
value.is_a?(LiteralValue) ? value.value : value
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# A class declaration with its members.
|
|
6
|
-
class UmlClass < Lutaml::Model::Serializable
|
|
7
|
-
include Lutaml::Lml::Positioned
|
|
8
|
-
|
|
9
|
-
# From TopElement. TextType unescapes \{ \} and normalizes lines
|
|
10
|
-
# on every assignment (builder, yaml, direct).
|
|
11
|
-
attribute :name, :string
|
|
12
|
-
attribute :definition, Lutaml::Lml::Types::TextType
|
|
13
|
-
attribute :stereotype, :string, collection: true, default: -> { [] }
|
|
14
|
-
attribute :visibility, :string, default: "public"
|
|
15
|
-
attribute :comments, :string, collection: true
|
|
16
|
-
|
|
17
|
-
# From UmlClassifier
|
|
18
|
-
attribute :is_abstract, :boolean, default: false
|
|
19
|
-
|
|
20
|
-
# From UmlClass
|
|
21
|
-
attribute :nested_classifier, :string, collection: true, default: -> { [] }
|
|
22
|
-
attribute :type, :string
|
|
23
|
-
attribute :attributes, "Lutaml::Lml::TopElementAttribute", collection: true
|
|
24
|
-
attribute :modifier, :string
|
|
25
|
-
attribute :constraints, "Lutaml::Lml::Constraint", collection: true
|
|
26
|
-
attribute :operations, "Lutaml::Lml::Operation", collection: true, default: -> { [] }
|
|
27
|
-
attribute :data_types, "Lutaml::Lml::DataType", collection: true
|
|
28
|
-
attribute :associations, "Lutaml::Lml::Association", collection: true
|
|
29
|
-
attribute :wire_mappings, "Lutaml::Lml::Mapping", collection: true, default: -> { [] }
|
|
30
|
-
attribute :string_formats, "Lutaml::Lml::StringFormat", collection: true, default: -> { [] }
|
|
31
|
-
attribute :derived_fields, "Lutaml::Lml::DerivedField", collection: true, default: -> { [] }
|
|
32
|
-
attribute :serialization_mappings, "Lutaml::Lml::SerializationMapping", collection: true, default: -> { [] }
|
|
33
|
-
|
|
34
|
-
# LML-specific
|
|
35
|
-
# In-class `namespace "uri"` declaration (issue #49)
|
|
36
|
-
attribute :xml_namespace, "Lutaml::Lml::Namespace"
|
|
37
|
-
attribute :parent_class, :string
|
|
38
|
-
|
|
39
|
-
yaml do
|
|
40
|
-
map "name", to: :name
|
|
41
|
-
map "is_abstract", to: :is_abstract
|
|
42
|
-
map "definition", to: :definition
|
|
43
|
-
map "modifier", to: :modifier
|
|
44
|
-
map "stereotype", to: :stereotype
|
|
45
|
-
map "visibility", to: :visibility
|
|
46
|
-
map "type", to: :type
|
|
47
|
-
map "xml_namespace", to: :xml_namespace
|
|
48
|
-
map "attributes", to: :attributes
|
|
49
|
-
map "operations", to: :operations
|
|
50
|
-
map "constraints", to: :constraints
|
|
51
|
-
map "data_types", to: :data_types
|
|
52
|
-
# Owner-side defaulting is a parent-context rule ("an
|
|
53
|
-
# association nested under a class defaults its owner to that
|
|
54
|
-
# class"); only a mapping proc can see the containing model.
|
|
55
|
-
map "associations", to: :associations, with: {
|
|
56
|
-
to: :associations_to_yaml, from: :associations_from_yaml
|
|
57
|
-
}
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def associations_to_yaml(model, doc)
|
|
61
|
-
return unless model.associations
|
|
62
|
-
|
|
63
|
-
associations = model.associations.map(&:to_hash)
|
|
64
|
-
doc["associations"] = associations unless associations.empty?
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def associations_from_yaml(model, values)
|
|
68
|
-
associations = values.map do |value|
|
|
69
|
-
value["owner_end"] = model.name if value["owner_end"].nil?
|
|
70
|
-
Association.from_yaml(value.to_yaml)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
model.associations = associations
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def self.entity_type
|
|
77
|
-
:classes
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def self.classifiable?
|
|
81
|
-
true
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# A value construct member.
|
|
6
|
-
class Value < Lutaml::Model::Serializable
|
|
7
|
-
include Lutaml::Lml::Positioned
|
|
8
|
-
|
|
9
|
-
attribute :name, :string
|
|
10
|
-
attribute :id, :string
|
|
11
|
-
attribute :type, :string
|
|
12
|
-
attribute :definition, Lutaml::Lml::Types::TextType
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
data/lib/lutaml/lml/parser.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# The LML parser: raw LML text → parse tree. The grammar lives in
|
|
6
|
-
# grammar/lml.parg (PARG); this class is the Ruby-facing front door.
|
|
7
|
-
# Pipeline-level entry points live on the Lutaml::Lml module
|
|
8
|
-
# (parse / parse_document).
|
|
9
|
-
class Parser
|
|
10
|
-
def self.parse(input, **options)
|
|
11
|
-
new.parse(input, **options)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def parse(input, **_options)
|
|
15
|
-
Grammar.artifact.parse(Grammar::ENTRY, input.to_s)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
data/lib/lutaml/lml/pipeline.rb
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'parsanol'
|
|
4
|
-
|
|
5
|
-
module Lutaml
|
|
6
|
-
module Lml
|
|
7
|
-
# Parse pipeline only: preprocess → parse → transform → process →
|
|
8
|
-
# build. View resolution and label enrichment are a separate,
|
|
9
|
-
# explicit post-parse step (ViewResolution) — file I/O for imports
|
|
10
|
-
# does not belong inside parsing.
|
|
11
|
-
class Pipeline
|
|
12
|
-
def self.call(input)
|
|
13
|
-
new(input).call
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def initialize(input)
|
|
17
|
-
@input = Source.wrap(input)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def call
|
|
21
|
-
data = Preprocessor.call(@input)
|
|
22
|
-
hash = parse_raw(data)
|
|
23
|
-
hash = DataProcessor.process(hash)
|
|
24
|
-
build_document(hash)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
def parse_raw(data)
|
|
30
|
-
Transform.new.apply(Parser.new.parse(data))
|
|
31
|
-
rescue Parsanol::ParseFailed => e
|
|
32
|
-
raise ParsingError.new(failure_message(e), diagnostic: parse_diagnostic(e))
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def parse_diagnostic(error)
|
|
36
|
-
line, column = failure_location(error)
|
|
37
|
-
Diagnostic.build(
|
|
38
|
-
'parse/LML-001',
|
|
39
|
-
message: error.message.lines.first.to_s.strip,
|
|
40
|
-
file: @input.path,
|
|
41
|
-
line: line,
|
|
42
|
-
column: column,
|
|
43
|
-
)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Parsanol releases up to 1.3.57 annotate native failures with a
|
|
47
|
-
# byte offset marker but report cause.position as 0; fixed parsanol
|
|
48
|
-
# already carries the correct location in the message. Only
|
|
49
|
-
# rebuild the location when the marker is present.
|
|
50
|
-
def failure_message(error)
|
|
51
|
-
detail = error.message.lines.first.to_s.strip
|
|
52
|
-
line, column = failure_location(error)
|
|
53
|
-
location = (" at line #{line} char #{column}." if line && !detail.match?(/at line \d+ char \d+/))
|
|
54
|
-
"#{detail}#{location}\ncause: #{error.parse_failure_cause&.ascii_tree}"
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def failure_location(error)
|
|
58
|
-
cause = error.parse_failure_cause
|
|
59
|
-
offset = error.message[/@@parsanol_pos:(\d+)/, 1]&.to_i
|
|
60
|
-
return cause.source.line_and_column(offset) if offset && cause&.source
|
|
61
|
-
|
|
62
|
-
match = error.message.match(/at line (\d+) char (\d+)/)
|
|
63
|
-
match ? [match[1].to_i, match[2].to_i] : [nil, nil]
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def build_document(hash)
|
|
67
|
-
document = DocumentBuilder.new(DocumentBuilder::DEFAULT_REGISTRY).build(:document, hash)
|
|
68
|
-
document.source_path = @input.path
|
|
69
|
-
document
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lutaml
|
|
4
|
-
module Lml
|
|
5
|
-
# Non-serialized source metadata carried by parsed entities. These
|
|
6
|
-
# accessors are deliberately not lutaml-model attributes: positions
|
|
7
|
-
# and the source path are diagnostics metadata, not document data,
|
|
8
|
-
# and must not appear in to_hash/YAML/JSON output.
|
|
9
|
-
module Positioned
|
|
10
|
-
attr_accessor :source_position, :source_path
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|