lutaml-lml 0.1.4 → 0.1.6

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: f72188a69457d2cf82445867f2b726dd621d63e82d79c7e56b01241e0d15ec84
4
- data.tar.gz: 402135ddb2bf31953c21f6166c859c6b5f67d24d1a9e18e8369eb3646a413381
3
+ metadata.gz: 9afdbd5bcb80896ee130f477fd40e21b475826cbe9ffcdac89b927e44ce77d5d
4
+ data.tar.gz: 194b68623da1d25a723af09a565948fdc6c567e340ebe7ac1efea5f8f925a6a1
5
5
  SHA512:
6
- metadata.gz: d07e5279b6c0d983d1ba1384ef3579aa3d493fba0520aedadfd97ac11a42bfca1fd2e96e621e6551e8dd22bef52e30136779cdf88e8bbe81e611b762e1efa3cd
7
- data.tar.gz: 20e402c37d1506fd86c4ded5fac0bb010dc58d3cdda8efcf3e92cd287ec8025331375310b7e40093741af136aaaf4f61d78a44456fe59b2d75dffe5e1d57568b
6
+ metadata.gz: 7f992466d0f04295e0808c199d37b31bc5ca16f8acc6e0a21ce519d932766437d7e87e604a7d5ea28b19ab89fe8ed3fa4f1b557882de7b36d41ec649be8f5a37
7
+ data.tar.gz: 57999ac9cba35e2ca2b515e40de8e99acf6d2ec00e4dc529c78a0344546f1e0c87ad66d42d116d55f53ccc38b137758a7c51c3a8a6500fa75431c3b579e06070
@@ -24,7 +24,7 @@ module Lutaml
24
24
  }.freeze
25
25
 
26
26
  PARSE_HANDLERS = {
27
- 'lutaml' => ->(path) { Lutaml::Lml.parse(File.new(path)) },
27
+ 'lutaml' => ->(path) { File.open(path) { |f| Lutaml::Lml.parse(f) } },
28
28
  'yaml' => ->(path) { Lutaml::Lml::YamlParser.parse(path.to_s) },
29
29
  'yml' => ->(path) { Lutaml::Lml::YamlParser.parse(path.to_s) },
30
30
  'exp' => lambda { |path|
@@ -94,8 +94,11 @@ module Lutaml
94
94
 
95
95
  lutaml lml validate model.lutaml project.lutaml
96
96
  DESC
97
+ method_option :input_format, type: :string, aliases: '-i',
98
+ desc: 'Input format (lutaml, yaml, exp)'
97
99
  def validate(*paths)
98
100
  assert_input_paths(paths)
101
+ @input_format = options[:input_format] || DEFAULT_INPUT_FORMAT
99
102
  errors = paths.map { |p| validate_single_file(p) }.compact
100
103
  report_validation(errors)
101
104
  end
@@ -4,7 +4,7 @@ module Lutaml
4
4
  module Lml
5
5
  class DataProcessor
6
6
  module AttributeProcessing
7
- EXCLUDED_PASS_THROUGH_KEYS = %i[key value comments add attributes properties].freeze
7
+ EXCLUDED_PASS_THROUGH_KEYS = %i[key value comments add attributes properties type_literal].freeze
8
8
 
9
9
  def process_attributes(obj)
10
10
  case obj
@@ -31,6 +31,7 @@ module Lutaml
31
31
  result = extract_name_and_value(obj)
32
32
  convert_instance_type(result)
33
33
  result[:extended] = !obj[:add].nil? if obj.key?(:add)
34
+ result[:literal] = true if obj.key?(:type_literal)
34
35
  apply_nested_attributes(result, obj)
35
36
  apply_remaining_keys(result, obj)
36
37
  result
@@ -14,8 +14,8 @@ module Lutaml
14
14
  symbol = ACCESS_SYMBOLS[node.visibility]
15
15
  result = "#{symbol}#{node.name}"
16
16
  if node.type
17
- keyword = node.keyword ? "«#{node.keyword}»" : ''
18
- result += " : #{keyword}#{node.type}"
17
+ stereotype = node.stereotype.empty? ? '' : node.stereotype.map { |s| "«#{s}»" }.join
18
+ result += " : #{stereotype}#{node.type}"
19
19
  end
20
20
  result += format_cardinality_bounds(node.cardinality) if node.cardinality
21
21
  result = escape_html_chars(result)
@@ -48,9 +48,23 @@ module Lutaml
48
48
  end.join(', ')
49
49
  end
50
50
 
51
+ # Kind labels rendered above the name: guillemet stereotypes first,
52
+ # then the entity-kind label (enums/data types/primitives carry no
53
+ # user stereotypes of their own in the grammar).
54
+ KIND_LABELS = {
55
+ enums: "enumeration",
56
+ data_types: "dataType",
57
+ primitives: "primitive"
58
+ }.freeze
59
+
51
60
  def format_class(node, hide_members = nil)
52
61
  name = ["<B>#{escape_html_chars(node.name)}</B>"]
53
- name.unshift("«#{escape_html_chars(node.keyword)}»") if node.keyword
62
+ node.stereotype.each do |stereotype|
63
+ name.unshift("«#{escape_html_chars(stereotype)}»")
64
+ end
65
+ if (kind = KIND_LABELS[node.class.entity_type])
66
+ name.unshift("«#{kind}»")
67
+ end
54
68
  name_html = build_name_table(name)
55
69
 
56
70
  member_formatter = node.is_a?(Lml::Enum) ? method(:format_enum_member) : nil