lutaml 0.10.12 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6c2a2164de4ea6ec27e076a4724d35d573af91829fa0103fc3e129707597de8
4
- data.tar.gz: 811651ff02e1b7001d056f70b3f9e96bd52c227a67d9e943134816b3408dc321
3
+ metadata.gz: 66f287c7903f45ebce9fc0abdc3561ad6ef3df65fdb4b437a126685610756df7
4
+ data.tar.gz: 8459a2ad63cf3e4071c7d56ec4ae105410d3044aad2f05810419d4dd90adf861
5
5
  SHA512:
6
- metadata.gz: '086fe280c4b5555a9e03d3718c5976bfbaaa7dbc9a7d4722fd6557e7779b6a673e372c5ea5e26cf9272c768067a8663672e06a2b3914bc6bbba459568a85faa5'
7
- data.tar.gz: 49c1c37825b6e3390b696a30584998c29433dd182bb2dfbf733985fc960306913d7ed2706b38959ba9766ec2d6458f2e552180a904fef22d655c409acb276183
6
+ metadata.gz: d395f7c78511a601edef5eab6e96f5f896e46a135675767dfd031df36caaa6cfb34a3e5c834d96feed728760a59bd1fe2321ff2ce25490274d9d2693345eb2aa
7
+ data.tar.gz: e0ab7f240736d995f948283a9668f578133a39443d95d1889178c7e8c97afb7872d581bc0d8b2d0b79db9c3587087448c82048bb2bce00ee28179b011c422597
data/.rubocop_todo.yml CHANGED
@@ -1,32 +1,32 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-05-11 22:46:59 UTC using RuboCop version 1.86.1.
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: 5
9
+ # Offense count: 1
10
10
  # This cop supports safe autocorrection (--autocorrect).
11
11
  # Configuration parameters: EnforcedStyle, IndentationWidth.
12
12
  # SupportedStyles: with_first_argument, with_fixed_indentation
13
13
  Layout/ArgumentAlignment:
14
14
  Exclude:
15
- - 'spec/lutaml/xmi/liquid_drops/nil_safety_spec.rb'
15
+ - 'spec/lutaml/xml/parsers/xsd_spec.rb'
16
16
 
17
- # Offense count: 159
17
+ # Offense count: 156
18
18
  # This cop supports safe autocorrection (--autocorrect).
19
19
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
20
20
  # URISchemes: http, https
21
21
  Layout/LineLength:
22
22
  Enabled: false
23
23
 
24
- # Offense count: 5
24
+ # Offense count: 1
25
25
  # This cop supports safe autocorrection (--autocorrect).
26
26
  # Configuration parameters: AllowInHeredoc.
27
27
  Layout/TrailingWhitespace:
28
28
  Exclude:
29
- - 'spec/lutaml/xmi/liquid_drops/nil_safety_spec.rb'
29
+ - 'spec/lutaml/xml/parsers/xsd_spec.rb'
30
30
 
31
31
  # Offense count: 1
32
32
  Lint/BinaryOperatorWithIdenticalOperands:
@@ -108,7 +108,7 @@ Metrics/BlockLength:
108
108
  Metrics/CyclomaticComplexity:
109
109
  Enabled: false
110
110
 
111
- # Offense count: 74
111
+ # Offense count: 75
112
112
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
113
113
  Metrics/MethodLength:
114
114
  Max: 62
@@ -160,7 +160,7 @@ RSpec/BeforeAfterAll:
160
160
  Exclude:
161
161
  - 'spec/lutaml/qea/verification/comprehensive_equivalence_spec.rb'
162
162
 
163
- # Offense count: 25
163
+ # Offense count: 24
164
164
  # Configuration parameters: Prefixes, AllowedPatterns.
165
165
  # Prefixes: when, with, without
166
166
  RSpec/ContextWording:
@@ -175,7 +175,6 @@ RSpec/ContextWording:
175
175
  - 'spec/lutaml/cli/uml/search_command_spec.rb'
176
176
  - 'spec/lutaml/cli/uml/tree_command_spec.rb'
177
177
  - 'spec/lutaml/cli/uml/verify_command_spec.rb'
178
- - 'spec/lutaml/parser_qea_spec.rb'
179
178
  - 'spec/lutaml/qea/integration/full_parsing_spec.rb'
180
179
  - 'spec/lutaml/xml/parsers/xml_spec.rb'
181
180
 
@@ -184,7 +183,7 @@ RSpec/ContextWording:
184
183
  RSpec/DescribeClass:
185
184
  Enabled: false
186
185
 
187
- # Offense count: 652
186
+ # Offense count: 649
188
187
  # Configuration parameters: CountAsOne.
189
188
  RSpec/ExampleLength:
190
189
  Max: 30
@@ -273,13 +272,12 @@ RSpec/RepeatedExampleGroupDescription:
273
272
  Exclude:
274
273
  - 'spec/lutaml/uml/parsers/dsl_spec.rb'
275
274
 
276
- # Offense count: 5
275
+ # Offense count: 4
277
276
  # Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
278
277
  # SupportedInflectors: default, active_support
279
278
  RSpec/SpecFilePathFormat:
280
279
  Exclude:
281
280
  - 'spec/express/parsers/exp_spec.rb'
282
- - 'spec/lutaml/parser_qea_spec.rb'
283
281
  - 'spec/lutaml/parsers/parse_xmi_spec.rb'
284
282
  - 'spec/lutaml/parsers/serialize_xmi_to_liquid_spec.rb'
285
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 = Lutaml::Parser
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
- Lutaml::Parser.parse_into_document(
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
- # Class for parsing .exp schema files into Expressir::Model::Repository
10
+ # Parses EXPRESS schema files (.exp) and cached repositories (.exp.cache).
10
11
  class Exp
11
- # @param [String] io - file object with path to .exp file
12
- # [Hash] options - options for parsing
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 "../../parser"
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
- # This parser wraps the existing Lutaml::Parser functionality and adapts
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 "../../parser"
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::Parser.parse([File.new(xmi_path)]).first
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::Parser.parse([File.new(xmi_path)]).first
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::Parser.parse([File.new(xmi_path)]).first
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 "../parser"
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
- # Parse XMI using Lutaml::Parser
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
- # Parse XMI using Lutaml::Parser
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lutaml
4
- VERSION = "0.10.12"
4
+ VERSION = "0.10.13"
5
5
  end
@@ -10,7 +10,7 @@ require "lutaml/converter/xmi_to_uml"
10
10
  module Lutaml
11
11
  module Xmi
12
12
  module Parsers
13
- # Class for parsing .xmi schema files into ::Lutaml::Uml::Document
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 xml
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 = {})
@@ -4,7 +4,6 @@ require "nokogiri"
4
4
  require "htmlentities"
5
5
  require "lutaml/uml/has_attributes"
6
6
  require "lutaml/uml/document"
7
- require "lutaml/xsd"
8
7
  require "lutaml/model"
9
8
  require "lutaml/model/schema"
10
9
 
@@ -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
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "xml/parsers/xml"
4
+ require_relative "xml/parsers/xsd"
data/lib/lutaml.rb CHANGED
@@ -6,8 +6,6 @@ module Lutaml
6
6
  class Error < StandardError; end
7
7
  end
8
8
 
9
- require_relative "lutaml/parser"
10
-
11
9
  require_relative "lutaml/express"
12
10
  require_relative "lutaml/formatter"
13
11
  require_relative "lutaml/layout"
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.12
4
+ version: 0.10.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -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