lutaml 0.10.11 → 0.10.13
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/.rubocop_todo.yml +24 -10
- data/lib/lutaml/cli/lml_commands.rb +17 -7
- data/lib/lutaml/express/parsers/exp.rb +11 -4
- data/lib/lutaml/model_transformations/parsers/xmi_parser.rb +2 -6
- data/lib/lutaml/qea/verification/document_verifier.rb +2 -2
- data/lib/lutaml/uml/parsers/yaml.rb +3 -0
- data/lib/lutaml/uml_repository/repository/loader.rb +3 -2
- data/lib/lutaml/uml_repository/repository.rb +3 -5
- data/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/data_type_drop.rb +4 -4
- data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +8 -8
- data/lib/lutaml/xmi/liquid_drops/package_drop.rb +6 -6
- data/lib/lutaml/xmi/liquid_drops/root_drop.rb +2 -2
- data/lib/lutaml/xmi/parsers/xml.rb +2 -2
- data/lib/lutaml/xml/parsers/xml.rb +0 -1
- data/lib/lutaml/xml/parsers/xsd.rb +35 -0
- data/lib/lutaml/xml.rb +1 -0
- data/lib/lutaml.rb +0 -2
- data/lutaml.gemspec +0 -1
- metadata +3 -17
- data/lib/lutaml/parser.rb +0 -53
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 66f287c7903f45ebce9fc0abdc3561ad6ef3df65fdb4b437a126685610756df7
|
|
4
|
+
data.tar.gz: 8459a2ad63cf3e4071c7d56ec4ae105410d3044aad2f05810419d4dd90adf861
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d395f7c78511a601edef5eab6e96f5f896e46a135675767dfd031df36caaa6cfb34a3e5c834d96feed728760a59bd1fe2321ff2ce25490274d9d2693345eb2aa
|
|
7
|
+
data.tar.gz: e0ab7f240736d995f948283a9668f578133a39443d95d1889178c7e8c97afb7872d581bc0d8b2d0b79db9c3587087448c82048bb2bce00ee28179b011c422597
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2026-05-
|
|
3
|
+
# on 2026-05-12 08:24:03 UTC using RuboCop version 1.86.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:
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
11
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
12
|
+
# SupportedStyles: with_first_argument, with_fixed_indentation
|
|
13
|
+
Layout/ArgumentAlignment:
|
|
14
|
+
Exclude:
|
|
15
|
+
- 'spec/lutaml/xml/parsers/xsd_spec.rb'
|
|
16
|
+
|
|
17
|
+
# Offense count: 156
|
|
10
18
|
# This cop supports safe autocorrection (--autocorrect).
|
|
11
19
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
12
20
|
# URISchemes: http, https
|
|
13
21
|
Layout/LineLength:
|
|
14
22
|
Enabled: false
|
|
15
23
|
|
|
24
|
+
# Offense count: 1
|
|
25
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
26
|
+
# Configuration parameters: AllowInHeredoc.
|
|
27
|
+
Layout/TrailingWhitespace:
|
|
28
|
+
Exclude:
|
|
29
|
+
- 'spec/lutaml/xml/parsers/xsd_spec.rb'
|
|
30
|
+
|
|
16
31
|
# Offense count: 1
|
|
17
32
|
Lint/BinaryOperatorWithIdenticalOperands:
|
|
18
33
|
Exclude:
|
|
@@ -93,7 +108,7 @@ Metrics/BlockLength:
|
|
|
93
108
|
Metrics/CyclomaticComplexity:
|
|
94
109
|
Enabled: false
|
|
95
110
|
|
|
96
|
-
# Offense count:
|
|
111
|
+
# Offense count: 75
|
|
97
112
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
98
113
|
Metrics/MethodLength:
|
|
99
114
|
Max: 62
|
|
@@ -112,13 +127,14 @@ Naming/MethodParameterName:
|
|
|
112
127
|
- 'lib/lutaml/uml_repository/static_site/generator.rb'
|
|
113
128
|
- 'spec/lutaml/parsers/serialize_xmi_to_liquid_spec.rb'
|
|
114
129
|
|
|
115
|
-
# Offense count:
|
|
130
|
+
# Offense count: 3
|
|
116
131
|
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
|
|
117
132
|
# AllowedMethods: call
|
|
118
133
|
# WaywardPredicates: infinite?, nonzero?
|
|
119
134
|
Naming/PredicateMethod:
|
|
120
135
|
Exclude:
|
|
121
136
|
- 'lib/lutaml/qea/factory/document_builder.rb'
|
|
137
|
+
- 'spec/lutaml/xmi/liquid_drops/nil_safety_spec.rb'
|
|
122
138
|
|
|
123
139
|
# Offense count: 3
|
|
124
140
|
# Configuration parameters: MinSize.
|
|
@@ -144,7 +160,7 @@ RSpec/BeforeAfterAll:
|
|
|
144
160
|
Exclude:
|
|
145
161
|
- 'spec/lutaml/qea/verification/comprehensive_equivalence_spec.rb'
|
|
146
162
|
|
|
147
|
-
# Offense count:
|
|
163
|
+
# Offense count: 24
|
|
148
164
|
# Configuration parameters: Prefixes, AllowedPatterns.
|
|
149
165
|
# Prefixes: when, with, without
|
|
150
166
|
RSpec/ContextWording:
|
|
@@ -159,16 +175,15 @@ RSpec/ContextWording:
|
|
|
159
175
|
- 'spec/lutaml/cli/uml/search_command_spec.rb'
|
|
160
176
|
- 'spec/lutaml/cli/uml/tree_command_spec.rb'
|
|
161
177
|
- 'spec/lutaml/cli/uml/verify_command_spec.rb'
|
|
162
|
-
- 'spec/lutaml/parser_qea_spec.rb'
|
|
163
178
|
- 'spec/lutaml/qea/integration/full_parsing_spec.rb'
|
|
164
179
|
- 'spec/lutaml/xml/parsers/xml_spec.rb'
|
|
165
180
|
|
|
166
|
-
# Offense count:
|
|
181
|
+
# Offense count: 22
|
|
167
182
|
# Configuration parameters: IgnoredMetadata.
|
|
168
183
|
RSpec/DescribeClass:
|
|
169
184
|
Enabled: false
|
|
170
185
|
|
|
171
|
-
# Offense count:
|
|
186
|
+
# Offense count: 649
|
|
172
187
|
# Configuration parameters: CountAsOne.
|
|
173
188
|
RSpec/ExampleLength:
|
|
174
189
|
Max: 30
|
|
@@ -257,13 +272,12 @@ RSpec/RepeatedExampleGroupDescription:
|
|
|
257
272
|
Exclude:
|
|
258
273
|
- 'spec/lutaml/uml/parsers/dsl_spec.rb'
|
|
259
274
|
|
|
260
|
-
# Offense count:
|
|
275
|
+
# Offense count: 4
|
|
261
276
|
# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
|
|
262
277
|
# SupportedInflectors: default, active_support
|
|
263
278
|
RSpec/SpecFilePathFormat:
|
|
264
279
|
Exclude:
|
|
265
280
|
- 'spec/express/parsers/exp_spec.rb'
|
|
266
|
-
- 'spec/lutaml/parser_qea_spec.rb'
|
|
267
281
|
- 'spec/lutaml/parsers/parse_xmi_spec.rb'
|
|
268
282
|
- 'spec/lutaml/parsers/serialize_xmi_to_liquid_spec.rb'
|
|
269
283
|
- 'spec/lutaml/uml_repository/web_ui/app_spec.rb'
|
|
@@ -7,6 +7,7 @@ require_relative "../uml/has_attributes"
|
|
|
7
7
|
require_relative "../uml/parsers/attribute"
|
|
8
8
|
require_relative "../uml/parsers/dsl"
|
|
9
9
|
require_relative "../uml/parsers/yaml"
|
|
10
|
+
require_relative "../express/parsers/exp"
|
|
10
11
|
|
|
11
12
|
module Lutaml
|
|
12
13
|
module Cli
|
|
@@ -81,9 +82,7 @@ module Lutaml
|
|
|
81
82
|
raise Thor::Error, "File does not exist: #{input_path}"
|
|
82
83
|
end
|
|
83
84
|
|
|
84
|
-
document =
|
|
85
|
-
.parse_into_document(File.new(input_path), @input_format)
|
|
86
|
-
.first
|
|
85
|
+
document = parse_document(input_path)
|
|
87
86
|
result = @formatter.format(document)
|
|
88
87
|
|
|
89
88
|
if @output_path
|
|
@@ -131,10 +130,7 @@ module Lutaml
|
|
|
131
130
|
end
|
|
132
131
|
|
|
133
132
|
begin
|
|
134
|
-
|
|
135
|
-
File.new(input_path),
|
|
136
|
-
DEFAULT_INPUT_FORMAT,
|
|
137
|
-
)
|
|
133
|
+
parse_document(input_path)
|
|
138
134
|
say "✓ #{input_path}", :green
|
|
139
135
|
rescue StandardError => e
|
|
140
136
|
errors << "#{input_path}: #{e.message}"
|
|
@@ -151,6 +147,20 @@ module Lutaml
|
|
|
151
147
|
end
|
|
152
148
|
|
|
153
149
|
no_commands do # rubocop:disable Metrics/BlockLength
|
|
150
|
+
def parse_document(input_path)
|
|
151
|
+
case @input_format
|
|
152
|
+
when "lutaml"
|
|
153
|
+
Lutaml::Uml::Parsers::Dsl.parse(File.new(input_path))
|
|
154
|
+
when "yaml", "yml"
|
|
155
|
+
Lutaml::Uml::Parsers::Yaml.parse(input_path.to_s)
|
|
156
|
+
when "exp"
|
|
157
|
+
Lutaml::Express::Parsers::Exp.parse(File.new(input_path))
|
|
158
|
+
else
|
|
159
|
+
raise Thor::Error,
|
|
160
|
+
"Unsupported input format: #{@input_format}"
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
154
164
|
def setup_options # rubocop:disable Metrics/AbcSize
|
|
155
165
|
@formatter = options[:formatter] if options[:formatter]
|
|
156
166
|
@type = options[:type] if options[:type]
|
|
@@ -2,19 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
require "expressir"
|
|
4
4
|
require "expressir/express/parser"
|
|
5
|
+
require "expressir/express/cache"
|
|
5
6
|
|
|
6
7
|
module Lutaml
|
|
7
8
|
module Express
|
|
8
9
|
module Parsers
|
|
9
|
-
#
|
|
10
|
+
# Parses EXPRESS schema files (.exp) and cached repositories (.exp.cache).
|
|
10
11
|
class Exp
|
|
11
|
-
# @param [
|
|
12
|
-
#
|
|
13
|
-
#
|
|
12
|
+
# @param io [File, IO] file object with path to .exp file
|
|
13
|
+
# @param options [Hash] parsing options
|
|
14
14
|
# @return [Expressir::Model::Repository]
|
|
15
15
|
def self.parse(io, _options = {})
|
|
16
16
|
Expressir::Express::Parser.from_files([io.path])
|
|
17
17
|
end
|
|
18
|
+
|
|
19
|
+
# @param path [String] path to cached .exp.cache file
|
|
20
|
+
# @param options [Hash] parsing options
|
|
21
|
+
# @return [Expressir::Model::Cache]
|
|
22
|
+
def self.parse_cache(path, _options = {})
|
|
23
|
+
Expressir::Express::Cache.from_file(path)
|
|
24
|
+
end
|
|
18
25
|
end
|
|
19
26
|
end
|
|
20
27
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "base_parser"
|
|
4
|
-
require_relative "../../
|
|
4
|
+
require_relative "../../xmi/parsers/xml"
|
|
5
5
|
|
|
6
6
|
module Lutaml
|
|
7
7
|
module ModelTransformations
|
|
@@ -9,11 +9,7 @@ module Lutaml
|
|
|
9
9
|
# XMI Parser implements the BaseParser interface for XML Metadata
|
|
10
10
|
# Interchange files.
|
|
11
11
|
#
|
|
12
|
-
#
|
|
13
|
-
# it
|
|
14
|
-
# to the new unified transformation architecture. It follows the Adapter
|
|
15
|
-
# pattern
|
|
16
|
-
# to integrate legacy XMI parsing with the new system.
|
|
12
|
+
# Delegates to Lutaml::Xmi::Parsers::Xml for actual parsing.
|
|
17
13
|
class XmiParser < BaseParser
|
|
18
14
|
# Get parser format name
|
|
19
15
|
#
|
|
@@ -5,7 +5,7 @@ require_relative "structure_matcher"
|
|
|
5
5
|
require_relative "element_comparator"
|
|
6
6
|
require_relative "comparison_result"
|
|
7
7
|
require_relative "../../qea"
|
|
8
|
-
require_relative "../../
|
|
8
|
+
require_relative "../../xmi/parsers/xml"
|
|
9
9
|
|
|
10
10
|
module Lutaml
|
|
11
11
|
module Qea
|
|
@@ -163,7 +163,7 @@ module Lutaml
|
|
|
163
163
|
|
|
164
164
|
# Parse XMI file
|
|
165
165
|
def parse_xmi(xmi_path)
|
|
166
|
-
Lutaml::
|
|
166
|
+
Lutaml::Xmi::Parsers::Xml.parse(File.new(xmi_path))
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
# Parse QEA file
|
|
@@ -7,6 +7,9 @@ module Lutaml
|
|
|
7
7
|
module Uml
|
|
8
8
|
module Parsers
|
|
9
9
|
class Yaml
|
|
10
|
+
# @param yaml_path [String] path to YAML file
|
|
11
|
+
# @param options [Hash] parsing options
|
|
12
|
+
# @return [Lutaml::Uml::Document]
|
|
10
13
|
def self.parse(yaml_path, options = {})
|
|
11
14
|
new.parse(yaml_path, options)
|
|
12
15
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "../../xmi/parsers/xml"
|
|
3
4
|
require_relative "../package_loader"
|
|
4
5
|
|
|
5
6
|
module Lutaml
|
|
@@ -25,7 +26,7 @@ module Lutaml
|
|
|
25
26
|
# @param options [Hash] Options for parsing
|
|
26
27
|
# @return [Repository]
|
|
27
28
|
def self.from_xmi(xmi_path, options = {})
|
|
28
|
-
document = Lutaml::
|
|
29
|
+
document = Lutaml::Xmi::Parsers::Xml.parse(File.new(xmi_path))
|
|
29
30
|
indexes = IndexBuilder.build_all(document)
|
|
30
31
|
new(document: document, indexes: indexes, options: options)
|
|
31
32
|
end
|
|
@@ -36,7 +37,7 @@ module Lutaml
|
|
|
36
37
|
# @param options [Hash] Options for parsing
|
|
37
38
|
# @return [LazyRepository]
|
|
38
39
|
def self.from_xmi_lazy(xmi_path, _options = {})
|
|
39
|
-
document = Lutaml::
|
|
40
|
+
document = Lutaml::Xmi::Parsers::Xml.parse(File.new(xmi_path))
|
|
40
41
|
LazyRepository.new(document: document, lazy: true)
|
|
41
42
|
end
|
|
42
43
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "../
|
|
3
|
+
require_relative "../xmi/parsers/xml"
|
|
4
4
|
require_relative "../uml/package_path"
|
|
5
5
|
require_relative "../uml/qualified_name"
|
|
6
6
|
require_relative "error_handler"
|
|
@@ -116,8 +116,7 @@ module Lutaml
|
|
|
116
116
|
# repo = Repository.from_xmi('model.xmi')
|
|
117
117
|
# repo = Repository.from_xmi('model.xmi', validate: true)
|
|
118
118
|
def self.from_xmi(xmi_path, options = {})
|
|
119
|
-
|
|
120
|
-
document = Lutaml::Parser.parse([File.new(xmi_path)]).first
|
|
119
|
+
document = Lutaml::Xmi::Parsers::Xml.parse(File.new(xmi_path))
|
|
121
120
|
|
|
122
121
|
# Build indexes
|
|
123
122
|
indexes = IndexBuilder.build_all(document)
|
|
@@ -143,8 +142,7 @@ module Lutaml
|
|
|
143
142
|
# repo = Repository.from_xmi_lazy('large-model.xmi')
|
|
144
143
|
# # Only document loaded, indexes built on first access
|
|
145
144
|
def self.from_xmi_lazy(xmi_path, _options = {})
|
|
146
|
-
|
|
147
|
-
document = Lutaml::Parser.parse([File.new(xmi_path)]).first
|
|
145
|
+
document = Lutaml::Xmi::Parsers::Xml.parse(File.new(xmi_path))
|
|
148
146
|
|
|
149
147
|
LazyRepository.new(document: document, lazy: true)
|
|
150
148
|
end
|
data/lib/lutaml/version.rb
CHANGED
|
@@ -20,7 +20,7 @@ module Lutaml
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def attributes
|
|
23
|
-
@model.attributes.filter_map do |owned_attr|
|
|
23
|
+
Array(@model.attributes).filter_map do |owned_attr|
|
|
24
24
|
if @options[:with_assoc] || owned_attr.association.nil?
|
|
25
25
|
::Lutaml::Xmi::LiquidDrops::AttributeDrop.new(owned_attr,
|
|
26
26
|
@options)
|
|
@@ -29,19 +29,19 @@ module Lutaml
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def operations
|
|
32
|
-
@model.operations.map do |operation|
|
|
32
|
+
Array(@model.operations).map do |operation|
|
|
33
33
|
::Lutaml::Xmi::LiquidDrops::OperationDrop.new(operation)
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def associations
|
|
38
|
-
@model.associations.filter_map do |assoc|
|
|
38
|
+
Array(@model.associations).filter_map do |assoc|
|
|
39
39
|
::Lutaml::Xmi::LiquidDrops::AssociationDrop.new(assoc, @options)
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def constraints
|
|
44
|
-
@model.constraints.map do |constraint|
|
|
44
|
+
Array(@model.constraints).map do |constraint|
|
|
45
45
|
::Lutaml::Xmi::LiquidDrops::ConstraintDrop.new(constraint)
|
|
46
46
|
end
|
|
47
47
|
end
|
|
@@ -81,7 +81,7 @@ module Lutaml
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
def attributes
|
|
84
|
-
@model.attributes.filter_map do |owned_attr|
|
|
84
|
+
Array(@model.attributes).filter_map do |owned_attr|
|
|
85
85
|
if @options[:with_assoc] || owned_attr.association.nil?
|
|
86
86
|
::Lutaml::Xmi::LiquidDrops::AttributeDrop.new(owned_attr,
|
|
87
87
|
@options)
|
|
@@ -90,44 +90,44 @@ module Lutaml
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def owned_attributes
|
|
93
|
-
@model.attributes.filter_map do |owned_attr|
|
|
93
|
+
Array(@model.attributes).filter_map do |owned_attr|
|
|
94
94
|
::Lutaml::Xmi::LiquidDrops::AttributeDrop.new(owned_attr, @options)
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def suppliers_dependencies
|
|
99
|
-
@suppliers_dependencies.filter_map do |dependency|
|
|
99
|
+
Array(@suppliers_dependencies).filter_map do |dependency|
|
|
100
100
|
::Lutaml::Xmi::LiquidDrops::DependencyDrop.new(dependency, @options)
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
def clients_dependencies
|
|
105
|
-
@clients_dependencies.filter_map do |dependency|
|
|
105
|
+
Array(@clients_dependencies).filter_map do |dependency|
|
|
106
106
|
::Lutaml::Xmi::LiquidDrops::DependencyDrop.new(dependency, @options)
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
def inheritances
|
|
111
|
-
@inheritance_ids.filter_map do |inheritance_id|
|
|
111
|
+
Array(@inheritance_ids).filter_map do |inheritance_id|
|
|
112
112
|
connector = @lookup.fetch_connector(inheritance_id)
|
|
113
113
|
::Lutaml::Xmi::LiquidDrops::ConnectorDrop.new(connector, @options)
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
def associations
|
|
118
|
-
@model.associations.filter_map do |assoc|
|
|
118
|
+
Array(@model.associations).filter_map do |assoc|
|
|
119
119
|
::Lutaml::Xmi::LiquidDrops::AssociationDrop.new(assoc, @options)
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
def operations
|
|
124
|
-
@model.operations.map do |operation|
|
|
124
|
+
Array(@model.operations).map do |operation|
|
|
125
125
|
::Lutaml::Xmi::LiquidDrops::OperationDrop.new(operation)
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
def constraints
|
|
130
|
-
@model.constraints.map do |constraint|
|
|
130
|
+
Array(@model.constraints).map do |constraint|
|
|
131
131
|
::Lutaml::Xmi::LiquidDrops::ConstraintDrop.new(constraint)
|
|
132
132
|
end
|
|
133
133
|
end
|
|
@@ -35,7 +35,7 @@ module Lutaml
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def klasses
|
|
38
|
-
@model.classes.map do |klass|
|
|
38
|
+
Array(@model.classes).map do |klass|
|
|
39
39
|
::Lutaml::Xmi::LiquidDrops::KlassDrop.new(
|
|
40
40
|
klass,
|
|
41
41
|
@guidance,
|
|
@@ -50,25 +50,25 @@ module Lutaml
|
|
|
50
50
|
alias classes klasses
|
|
51
51
|
|
|
52
52
|
def enums
|
|
53
|
-
@model.enums.map do |enum|
|
|
53
|
+
Array(@model.enums).map do |enum|
|
|
54
54
|
::Lutaml::Xmi::LiquidDrops::EnumDrop.new(enum, @options)
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def data_types
|
|
59
|
-
@model.data_types.map do |data_type|
|
|
59
|
+
Array(@model.data_types).map do |data_type|
|
|
60
60
|
::Lutaml::Xmi::LiquidDrops::DataTypeDrop.new(data_type, @options)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def diagrams
|
|
65
|
-
@model.diagrams.map do |diagram|
|
|
65
|
+
Array(@model.diagrams).map do |diagram|
|
|
66
66
|
::Lutaml::Xmi::LiquidDrops::DiagramDrop.new(diagram, @options)
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def packages
|
|
71
|
-
@model.packages.map do |package|
|
|
71
|
+
Array(@model.packages).map do |package|
|
|
72
72
|
::Lutaml::Xmi::LiquidDrops::PackageDrop.new(
|
|
73
73
|
package,
|
|
74
74
|
@guidance,
|
|
@@ -82,7 +82,7 @@ module Lutaml
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
def children_packages
|
|
85
|
-
@model.children_packages.map do |package|
|
|
85
|
+
Array(@model.children_packages).map do |package|
|
|
86
86
|
::Lutaml::Xmi::LiquidDrops::PackageDrop.new(
|
|
87
87
|
package,
|
|
88
88
|
@guidance,
|
|
@@ -19,14 +19,14 @@ module Lutaml
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def packages
|
|
22
|
-
@model.packages.map do |package|
|
|
22
|
+
Array(@model.packages).map do |package|
|
|
23
23
|
::Lutaml::Xmi::LiquidDrops::PackageDrop.new(package, @guidance,
|
|
24
24
|
@options)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def children_packages
|
|
29
|
-
@model.packages.flat_map(&:children_packages).uniq
|
|
29
|
+
Array(@model.packages).flat_map(&:children_packages).uniq
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -10,7 +10,7 @@ require "lutaml/converter/xmi_to_uml"
|
|
|
10
10
|
module Lutaml
|
|
11
11
|
module Xmi
|
|
12
12
|
module Parsers
|
|
13
|
-
#
|
|
13
|
+
# Parses XMI files into Lutaml::Uml::Document objects.
|
|
14
14
|
class Xml
|
|
15
15
|
include Lutaml::Converter::XmiToUml
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ module Lutaml
|
|
|
19
19
|
include XmiBase
|
|
20
20
|
|
|
21
21
|
class << self
|
|
22
|
-
# @param xml [String] path to
|
|
22
|
+
# @param xml [String, File] path to XMI file or file object
|
|
23
23
|
# @param options [Hash] options for parsing
|
|
24
24
|
# @return [Lutaml::Uml::Document]
|
|
25
25
|
def parse(xml, _options = {})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Xml
|
|
5
|
+
module Parsers
|
|
6
|
+
# Parses XSD schema files into Lutaml::Xml::Schema::Xsd::Schema objects.
|
|
7
|
+
#
|
|
8
|
+
# Delegates to lutaml-model's XSD parser with lazy loading to avoid
|
|
9
|
+
# eager-loading ~50 XSD model classes when not parsing XSD.
|
|
10
|
+
#
|
|
11
|
+
# @example Parse an XSD file
|
|
12
|
+
# schema = Lutaml::Xml::Parsers::Xsd.parse(File.new("schema.xsd"))
|
|
13
|
+
#
|
|
14
|
+
# @example With location for resolving imports
|
|
15
|
+
# schema = Lutaml::Xml::Parsers::Xsd.parse(
|
|
16
|
+
# File.new("schema.xsd"),
|
|
17
|
+
# location: "/path/to/schemas",
|
|
18
|
+
# )
|
|
19
|
+
class Xsd
|
|
20
|
+
# @param file [File, IO] file object with XSD content
|
|
21
|
+
# @param options [Hash] parsing options
|
|
22
|
+
# @option options [String] :location base path for resolving schema imports
|
|
23
|
+
# @return [Lutaml::Xml::Schema::Xsd::Schema]
|
|
24
|
+
def self.parse(file, options = {})
|
|
25
|
+
require "lutaml/xml/schema/xsd"
|
|
26
|
+
|
|
27
|
+
Lutaml::Xml::Schema::Xsd.parse(
|
|
28
|
+
file.read,
|
|
29
|
+
location: options[:location],
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/lutaml/xml.rb
CHANGED
data/lib/lutaml.rb
CHANGED
data/lutaml.gemspec
CHANGED
|
@@ -38,7 +38,6 @@ Gem::Specification.new do |spec|
|
|
|
38
38
|
spec.add_dependency "listen"
|
|
39
39
|
spec.add_dependency "lutaml-model", "~> 0.8.0"
|
|
40
40
|
spec.add_dependency "lutaml-path"
|
|
41
|
-
spec.add_dependency "lutaml-xsd"
|
|
42
41
|
spec.add_dependency "nokogiri", "~> 1.18"
|
|
43
42
|
spec.add_dependency "paint"
|
|
44
43
|
spec.add_dependency "parslet", "~> 2.0"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lutaml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.10.
|
|
4
|
+
version: 0.10.13
|
|
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-05-
|
|
11
|
+
date: 2026-05-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: expressir
|
|
@@ -108,20 +108,6 @@ dependencies:
|
|
|
108
108
|
- - ">="
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: lutaml-xsd
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - ">="
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: '0'
|
|
118
|
-
type: :runtime
|
|
119
|
-
prerelease: false
|
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
-
requirements:
|
|
122
|
-
- - ">="
|
|
123
|
-
- !ruby/object:Gem::Version
|
|
124
|
-
version: '0'
|
|
125
111
|
- !ruby/object:Gem::Dependency
|
|
126
112
|
name: nokogiri
|
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -699,7 +685,6 @@ files:
|
|
|
699
685
|
- lib/lutaml/model_transformations/parsers/qea_parser.rb
|
|
700
686
|
- lib/lutaml/model_transformations/parsers/xmi_parser.rb
|
|
701
687
|
- lib/lutaml/model_transformations/transformation_engine.rb
|
|
702
|
-
- lib/lutaml/parser.rb
|
|
703
688
|
- lib/lutaml/qea.rb
|
|
704
689
|
- lib/lutaml/qea/benchmark.rb
|
|
705
690
|
- lib/lutaml/qea/database.rb
|
|
@@ -966,6 +951,7 @@ files:
|
|
|
966
951
|
- lib/lutaml/xmi/xmi_lookup_service.rb
|
|
967
952
|
- lib/lutaml/xml.rb
|
|
968
953
|
- lib/lutaml/xml/parsers/xml.rb
|
|
954
|
+
- lib/lutaml/xml/parsers/xsd.rb
|
|
969
955
|
- lutaml.gemspec
|
|
970
956
|
- plateau_all_packages.lur
|
|
971
957
|
- templates/static_site/assets/images/lutaml-full.svg
|
data/lib/lutaml/parser.rb
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "expressir"
|
|
4
|
-
require "expressir/express/cache"
|
|
5
|
-
require_relative "xmi"
|
|
6
|
-
require_relative "xml"
|
|
7
|
-
require_relative "qea"
|
|
8
|
-
require_relative "uml"
|
|
9
|
-
|
|
10
|
-
module Lutaml
|
|
11
|
-
class Parser
|
|
12
|
-
EXPRESS_CACHE_PARSE_TYPE = "exp.cache"
|
|
13
|
-
|
|
14
|
-
attr_reader :parse_type, :file_list
|
|
15
|
-
|
|
16
|
-
class << self
|
|
17
|
-
def parse(file_list, input_type = nil)
|
|
18
|
-
file_list = [file_list] unless file_list.is_a?(Array)
|
|
19
|
-
new(Array(file_list), input_type).parse_into_document
|
|
20
|
-
end
|
|
21
|
-
alias_method :parse_into_document, :parse
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def initialize(file_list, input_type)
|
|
25
|
-
@parse_type = input_type || File.extname(file_list.first.path)[1..]
|
|
26
|
-
@file_list = file_list
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def parse_into_document # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
30
|
-
case parse_type
|
|
31
|
-
when "exp"
|
|
32
|
-
Expressir::Express::Parser.from_files(file_list.map(&:path))
|
|
33
|
-
when EXPRESS_CACHE_PARSE_TYPE
|
|
34
|
-
Expressir::Express::Cache.from_file(file_list.first.path)
|
|
35
|
-
when "qea"
|
|
36
|
-
# QEA files: Direct database parsing for Enterprise Architect
|
|
37
|
-
# Parse single QEA file and return as array for consistency with XMI
|
|
38
|
-
document = Lutaml::Qea.parse(file_list.first.path)
|
|
39
|
-
[document]
|
|
40
|
-
when "xmi"
|
|
41
|
-
file_list.map { |file| Lutaml::Xmi::Parsers::Xml.parse(file) }
|
|
42
|
-
when "xml"
|
|
43
|
-
file_list.map { |file| Lutaml::Xml::Parsers::Xml.parse(file) }
|
|
44
|
-
when "lutaml"
|
|
45
|
-
file_list.map { |file| Lutaml::Uml::Parsers::Dsl.parse(file) }
|
|
46
|
-
when "yml", "yaml"
|
|
47
|
-
file_list.map { |file| Lutaml::Uml::Parsers::Yaml.parse(file.path) }
|
|
48
|
-
else
|
|
49
|
-
raise ArgumentError, "Unsupported file format"
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|