lutaml 0.9.33 → 0.9.34

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -0
  3. data/bin/plantuml2lutaml +1 -1
  4. data/bin/yaml2lutaml +6 -4
  5. data/exe/lutaml-wsd2uml +1 -1
  6. data/exe/lutaml-yaml2uml +6 -4
  7. data/lib/lutaml/command_line.rb +3 -3
  8. data/lib/lutaml/formatter/base.rb +3 -3
  9. data/lib/lutaml/formatter/graphviz.rb +10 -10
  10. data/lib/lutaml/sysml/block.rb +1 -1
  11. data/lib/lutaml/sysml/constraint_block.rb +1 -1
  12. data/lib/lutaml/sysml/nested_connector_end.rb +1 -1
  13. data/lib/lutaml/sysml/requirement.rb +41 -33
  14. data/lib/lutaml/sysml/xmi_file.rb +382 -355
  15. data/lib/lutaml/uml/actor.rb +1 -1
  16. data/lib/lutaml/uml/association.rb +5 -5
  17. data/lib/lutaml/uml/connector.rb +1 -1
  18. data/lib/lutaml/uml/constructor_end.rb +1 -1
  19. data/lib/lutaml/uml/dependency.rb +1 -1
  20. data/lib/lutaml/uml/document.rb +0 -1
  21. data/lib/lutaml/uml/formatter/base.rb +2 -2
  22. data/lib/lutaml/uml/formatter/graphviz.rb +10 -10
  23. data/lib/lutaml/uml/has_members.rb +4 -4
  24. data/lib/lutaml/uml/instance.rb +1 -1
  25. data/lib/lutaml/uml/model.rb +1 -1
  26. data/lib/lutaml/uml/node/class_node.rb +1 -1
  27. data/lib/lutaml/uml/operation.rb +2 -2
  28. data/lib/lutaml/uml/package.rb +2 -2
  29. data/lib/lutaml/uml/parsers/dsl.rb +7 -4
  30. data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +6 -3
  31. data/lib/lutaml/uml/property.rb +4 -4
  32. data/lib/lutaml/uml/top_element.rb +2 -2
  33. data/lib/lutaml/uml/top_element_attribute.rb +1 -1
  34. data/lib/lutaml/uml/value.rb +2 -2
  35. data/lib/lutaml/version.rb +1 -1
  36. data/lib/lutaml/xmi/liquid_drops/association_drop.rb +11 -2
  37. data/lib/lutaml/xmi/liquid_drops/attribute_drop.rb +1 -1
  38. data/lib/lutaml/xmi/liquid_drops/connector_drop.rb +40 -0
  39. data/lib/lutaml/xmi/liquid_drops/data_type_drop.rb +2 -1
  40. data/lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb +1 -1
  41. data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +2 -1
  42. data/lib/lutaml/xmi/liquid_drops/source_target_drop.rb +36 -0
  43. data/lib/lutaml/xmi/parsers/xmi_base.rb +28 -11
  44. data/lib/lutaml/xmi.rb +0 -1
  45. data/lutaml.gemspec +2 -10
  46. metadata +6 -103
  47. data/lib/lutaml/xmi/version.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a3e7ce554e5b58c9d922d7588087550e9fed056f5492e822b15531d91ddcb14
4
- data.tar.gz: 18ee2a6d41c7056f56cbb8f869ca234e3fcff6688024f8aeff55797047069270
3
+ metadata.gz: d209094b579492db86b7f110e3cca4a8c5e14b21107b55d901beb42ed5bf6cf8
4
+ data.tar.gz: 5e01c3afabf5acfd93274763419c42a4bf90055d48b4e9eb6a66c462a768bdad
5
5
  SHA512:
6
- metadata.gz: eb8d3699fc5cdda40ae70b388e520095874828d80d5759c32f754df0aff1ec31ae185f17296e26d09e23bb41c8326fb517626389227c277f549f6a107d303c17
7
- data.tar.gz: 745883a9eea0ef04d31f6941121d15dc9b0a687ae9c55634bd6790ab5d12fd1e72e6b9ce8b128a992463c405b057de53db76d0d0518a412f673986a4928288b0
6
+ metadata.gz: 81f816d09ac98a2c129b8864487ea0783ca4d794af29735c4ca71983f0235548d076d1e7bce046a7d30ae65257be195900ae299936e224704cb94d0f03950de8
7
+ data.tar.gz: bf7a607d36342a5f44c38722f049f7516eb40dc3374248623c2cf528ea24a4db36dddf6ee9c8e3fcc4c556ad3b942dae8e9fa7d02be0104a596ac24d8b11bbf9
data/Gemfile CHANGED
@@ -2,3 +2,11 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in lutaml.gemspec
4
4
  gemspec
5
+
6
+ gem "byebug"
7
+ gem "equivalent-xml", "~> 0.6.0"
8
+ gem "pry", "~> 0.12.2"
9
+ gem "rake", "~> 13.0"
10
+ gem "rspec", "~> 3.11"
11
+ gem "rubocop", "~> 1.58"
12
+ gem "rubocop-performance", "~> 1.19"
data/bin/plantuml2lutaml CHANGED
@@ -26,7 +26,7 @@ ASSOCIATION_MAPPINGS = {
26
26
 
27
27
  in_comment_block = false
28
28
 
29
- def transform_line(line)
29
+ def transform_line(line) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
30
30
  line = line.gsub(/^\s*'/, "** ").gsub(/\|[\sa-zA-Z]+$/, "")
31
31
  return sync_puts(line, 2) if ASSOCIATION_MAPPINGS.keys.none? do |key|
32
32
  line =~ key
data/bin/yaml2lutaml CHANGED
@@ -30,7 +30,7 @@ encountered_relations = Hash.new { |h, key| h[key] = [] }
30
30
  # cardinality:
31
31
  # min: 0
32
32
  # max: '*'
33
- def process_association(owner, values, encountered_relations)
33
+ def process_association(owner, values, encountered_relations) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
34
34
  target_name = values["target"]
35
35
  return if encountered_relations[owner].include?(target_name)
36
36
 
@@ -45,7 +45,8 @@ def process_association(owner, values, encountered_relations)
45
45
  if source["attribute"]
46
46
  source_attribute_name = source["attribute"].keys.first
47
47
  owner += "##{source_attribute_name}"
48
- if source["attribute"][source_attribute_name] && source["attribute"][source_attribute_name]["cardinality"]
48
+ if source["attribute"][source_attribute_name] &&
49
+ source["attribute"][source_attribute_name]["cardinality"]
49
50
  cardinality = source["attribute"][source_attribute_name]["cardinality"]
50
51
  owner += " [#{cardinality['min']}..#{cardinality['max']}]"
51
52
  end
@@ -61,7 +62,8 @@ def process_association(owner, values, encountered_relations)
61
62
  if target["attribute"]
62
63
  target_attribute_name = target["attribute"].keys.first
63
64
  member += "##{target_attribute_name}"
64
- if target["attribute"][target_attribute_name] && target["attribute"][target_attribute_name]["cardinality"]
65
+ if target["attribute"][target_attribute_name] &&
66
+ target["attribute"][target_attribute_name]["cardinality"]
65
67
  cardinality = target["attribute"][target_attribute_name]["cardinality"]
66
68
  member += " [#{cardinality['min']}..#{cardinality['max']}]"
67
69
  end
@@ -82,7 +84,7 @@ view_yaml["relations"]&.each do |values|
82
84
  process_association(values["source"], values, encountered_relations)
83
85
  end
84
86
 
85
- view_yaml["imports"].each_key do |entry|
87
+ view_yaml["imports"].each_key do |entry| # rubocop:disable Metrics/BlockLength
86
88
  import = YAML.safe_load(File.read(File.join(models_path, "#{entry}.yml")))
87
89
  import_name = import["name"] || File.basename(entry)
88
90
  # Class notation
data/exe/lutaml-wsd2uml CHANGED
@@ -26,7 +26,7 @@ ASSOCIATION_MAPPINGS = {
26
26
 
27
27
  in_comment_block = false
28
28
 
29
- def transform_line(line)
29
+ def transform_line(line) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
30
30
  line = line.gsub(/^\s*'/, "** ").gsub(/\|[\sa-zA-Z]+$/, "").delete("\r")
31
31
  return sync_puts(line, 2) if ASSOCIATION_MAPPINGS.keys.none? do |key|
32
32
  line =~ key
data/exe/lutaml-yaml2uml CHANGED
@@ -30,7 +30,7 @@ encountered_relations = Hash.new { |h, key| h[key] = [] }
30
30
  # cardinality:
31
31
  # min: 0
32
32
  # max: '*'
33
- def process_association(owner, values, encountered_relations)
33
+ def process_association(owner, values, encountered_relations) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
34
34
  target_name = values["target"]
35
35
  return if encountered_relations[owner].include?(target_name)
36
36
 
@@ -45,7 +45,8 @@ def process_association(owner, values, encountered_relations)
45
45
  if source["attribute"]
46
46
  source_attribute_name = source["attribute"].keys.first
47
47
  owner += "##{source_attribute_name}"
48
- if source["attribute"][source_attribute_name] && source["attribute"][source_attribute_name]["cardinality"]
48
+ if source["attribute"][source_attribute_name] &&
49
+ source["attribute"][source_attribute_name]["cardinality"]
49
50
  cardinality = source["attribute"][source_attribute_name]["cardinality"]
50
51
  owner += " [#{cardinality['min']}..#{cardinality['max']}]"
51
52
  end
@@ -61,7 +62,8 @@ def process_association(owner, values, encountered_relations)
61
62
  if target["attribute"]
62
63
  target_attribute_name = target["attribute"].keys.first
63
64
  member += "##{target_attribute_name}"
64
- if target["attribute"][target_attribute_name] && target["attribute"][target_attribute_name]["cardinality"]
65
+ if target["attribute"][target_attribute_name] &&
66
+ target["attribute"][target_attribute_name]["cardinality"]
65
67
  cardinality = target["attribute"][target_attribute_name]["cardinality"]
66
68
  member += " [#{cardinality['min']}..#{cardinality['max']}]"
67
69
  end
@@ -82,7 +84,7 @@ view_yaml["relations"]&.each do |values|
82
84
  process_association(values["source"], values, encountered_relations)
83
85
  end
84
86
 
85
- view_yaml["imports"].each_key do |entry|
87
+ view_yaml["imports"].each_key do |entry| # rubocop:disable Metrics/BlockLength
86
88
  import = YAML.safe_load(File.read(File.join(models_path, "#{entry}.yml")))
87
89
  import_name = import["name"] || File.basename(entry)
88
90
  # Class notation
@@ -68,7 +68,7 @@ module Lutaml
68
68
  raise(NotSupportedInputFormat, value) if @input_format.nil?
69
69
  end
70
70
 
71
- def run(original_args)
71
+ def run(original_args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
72
72
  args = original_args.dup
73
73
  if args.empty? || args.first.strip == "help"
74
74
  print_help
@@ -143,7 +143,7 @@ module Lutaml
143
143
  "\e[0m"
144
144
  end
145
145
 
146
- def setup_parser_options
146
+ def setup_parser_options # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
147
147
  @option_parser.banner = ""
148
148
  format_desc = "The output formatter (Default: '#{@formatter.name}')"
149
149
  @option_parser
@@ -196,7 +196,7 @@ module Lutaml
196
196
  end
197
197
  end
198
198
 
199
- def print_help
199
+ def print_help # rubocop:disable Metrics/AbcSize
200
200
  @out_object.puts <<~HELP
201
201
  #{text_bold('Usage:')} lutaml [options] PATHS
202
202
 
@@ -7,7 +7,7 @@ module Lutaml
7
7
  module Formatter
8
8
  class Base
9
9
  class << self
10
- def inherited(subclass)
10
+ def inherited(subclass) # rubocop:disable Lint/MissingSuper
11
11
  Formatter.all << subclass
12
12
  end
13
13
 
@@ -38,9 +38,9 @@ module Lutaml
38
38
  @type = value.to_s.strip.downcase.to_sym
39
39
  end
40
40
 
41
- def format(node)
41
+ def format(node) # rubocop:disable Metrics/CyclomaticComplexity
42
42
  case node
43
- when ::Lutaml::Uml::Node::Field then format_field(node)
43
+ when ::Lutaml::Uml::Node::Field then format_field(node)
44
44
  when ::Lutaml::Uml::Node::Method then format_method(node)
45
45
  when ::Lutaml::Uml::Node::Relationship then format_relationship(node)
46
46
  when ::Lutaml::Uml::Node::ClassRelationship
@@ -40,7 +40,7 @@ module Lutaml
40
40
  cmapx
41
41
  ].freeze
42
42
 
43
- def initialize(attributes = {})
43
+ def initialize(attributes = {}) # rubocop:disable Metrics/MethodLength
44
44
  super
45
45
 
46
46
  @graph = Attributes.new
@@ -87,7 +87,7 @@ module Lutaml
87
87
  .gsub("]", "&#93;")
88
88
  end
89
89
 
90
- def format_field(node)
90
+ def format_field(node) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
91
91
  symbol = ACCESS_SYMBOLS[node.visibility]
92
92
  result = "#{symbol}#{node.name}"
93
93
  if node.type
@@ -103,7 +103,7 @@ module Lutaml
103
103
  result
104
104
  end
105
105
 
106
- def format_method(node)
106
+ def format_method(node) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
107
107
  symbol = ACCESS_SYMBOLS[node.access]
108
108
  result = "#{symbol} #{node.name}"
109
109
  if node.arguments
@@ -129,7 +129,7 @@ module Lutaml
129
129
  %{#{graph_parent_name} -> #{graph_node_name}#{graph_attributes}}
130
130
  end
131
131
 
132
- def generate_graph_relationship_attributes(node)
132
+ def generate_graph_relationship_attributes(node) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
133
133
  attributes = Attributes.new
134
134
  if %w[dependency realizes].include?(node.member_end_type)
135
135
  attributes["style"] = "dashed"
@@ -196,7 +196,7 @@ module Lutaml
196
196
  "#{res} #{cardinality['min']}..#{cardinality['max']}"
197
197
  end
198
198
 
199
- def format_member_rows(members, hide_members)
199
+ def format_member_rows(members, hide_members) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
200
200
  unless !hide_members && members&.length&.positive?
201
201
  return <<~HEREDOC.chomp
202
202
  <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
@@ -217,7 +217,7 @@ module Lutaml
217
217
  field_table
218
218
  end
219
219
 
220
- def format_class(node, hide_members)
220
+ def format_class(node, hide_members) # rubocop:disable Metrics/AbcSize
221
221
  name = ["<B>#{node.name}</B>"]
222
222
  name.unshift("«#{node.keyword}»") if node.keyword
223
223
  name_html = <<~HEREDOC
@@ -245,7 +245,7 @@ module Lutaml
245
245
  HEREDOC
246
246
  end
247
247
 
248
- def format_document(node)
248
+ def format_document(node) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
249
249
  @fontname = node.fontname || DEFAULT_CLASS_FONT
250
250
  @node["fontname"] = "#{@fontname}-bold"
251
251
 
@@ -269,8 +269,8 @@ module Lutaml
269
269
  associations = node.classes.map(&:associations).compact.flatten +
270
270
  node.associations
271
271
  if node.groups
272
- associations = sort_by_document_groupping(node.groups,
273
- associations)
272
+ associations = sort_by_document_grouping(node.groups,
273
+ associations)
274
274
  end
275
275
  classes_names = node.classes.map(&:name)
276
276
  associations = associations.map do |assoc_node|
@@ -301,7 +301,7 @@ module Lutaml
301
301
 
302
302
  protected
303
303
 
304
- def sort_by_document_groupping(groups, associations)
304
+ def sort_by_document_grouping(groups, associations) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
305
305
  result = []
306
306
  groups.each do |batch|
307
307
  batch.each do |group_name|
@@ -3,7 +3,7 @@ module Lutaml
3
3
  class Block < Lutaml::Uml::Class
4
4
  attr_accessor :base_class
5
5
 
6
- def initialize
6
+ def initialize # rubocop:disable Lint/MissingSuper
7
7
  @xmi_id = nil
8
8
  @nested_classifier = []
9
9
  @stereotype = []
@@ -1,7 +1,7 @@
1
1
  module Lutaml
2
2
  module SysMl
3
3
  class ConstraintBlock < Block
4
- def initialize
4
+ def initialize # rubocop:disable Lint/MissingSuper
5
5
  @xmi_id = nil
6
6
  @nested_classifier = []
7
7
  @stereotype = []
@@ -3,7 +3,7 @@ module Lutaml
3
3
  class NestedConnectorEnd < Lutaml::Uml::ConnectorEnd
4
4
  attr_accessor :base_connectorend, :property_path
5
5
 
6
- def initialize
6
+ def initialize # rubocop:disable Lint/MissingSuper
7
7
  @property_path = []
8
8
  end
9
9
  end
@@ -1,34 +1,42 @@
1
- module Lutaml::Sysml
1
+ module Lutaml
2
+ module Sysml
3
+ class Requirement < Lutaml::Uml::Class
4
+ attr_accessor :id, :text, :base_class, :refined_by, :traced_to,
5
+ :derived_from, :satisfied_by
2
6
 
3
- class Requirement < Lutaml::Uml::Class
4
- attr_accessor :id, :text, :base_class, :refined_by, :traced_to, :derived_from, :satisfied_by
5
- def initialize
6
- @xmi_id = nil
7
- @id = nil
8
- @nested_classifier = []
9
- @stereotype = []
10
- @namespace = nil
11
- end
12
- def name
13
- if base_class != nil and base_class.name != nil
14
- return base_class.name
15
- end
16
- return nil
17
- end
18
- def full_name
19
- if base_class != nil and base_class.name != nil
20
- return base_class.full_name
21
- end
22
- return nil
23
- end
24
- ## def name
25
- ## if base_class != nil and base_class.name != nil
26
- ## base_class.name
27
- ## else
28
- ## nil
29
- ## end
30
- ## end
31
- ## def full_name
32
- ## get_base_class_full_name ( self )
33
- ## end
34
- end
7
+ def initialize # rubocop:disable Lint/MissingSuper
8
+ @xmi_id = nil
9
+ @id = nil
10
+ @nested_classifier = []
11
+ @stereotype = []
12
+ @namespace = nil
13
+ end
14
+
15
+ def name
16
+ if !base_class.nil? && !base_class.name.nil?
17
+ return base_class.name
18
+ end
19
+
20
+ nil
21
+ end
22
+
23
+ def full_name
24
+ if !base_class.nil? && !base_class.name.nil?
25
+ return base_class.full_name
26
+ end
27
+
28
+ nil
29
+ end
30
+ ## def name
31
+ ## if base_class != nil and base_class.name != nil
32
+ ## base_class.name
33
+ ## else
34
+ ## nil
35
+ ## end
36
+ ## end
37
+ ## def full_name
38
+ ## get_base_class_full_name ( self )
39
+ ## end
40
+ end
41
+ end
42
+ end