metaschema 0.2.1 → 0.2.2

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.
@@ -365,17 +365,23 @@ module Metaschema
365
365
  # Content mapping
366
366
  content = xml_map.instance_variable_get(:@content_mapping)
367
367
  if content
368
- lines << " map_content to: :#{content.to}"
368
+ opts = ["to: :#{content.to}"]
369
+ opts << "delegate: :#{content.delegate}" if content.delegate
370
+ lines << " map_content #{opts.join(', ')}"
369
371
  end
370
372
 
371
373
  # Attribute mappings
372
374
  xml_map.instance_variable_get(:@attributes)&.each do |xml_name, rule|
373
- lines << " map_attribute \"#{xml_name}\", to: :#{rule.to}"
375
+ opts = ["\"#{xml_name}\"", "to: :#{rule.to}"]
376
+ opts << "delegate: :#{rule.delegate}" if rule.delegate
377
+ lines << " map_attribute #{opts.join(', ')}"
374
378
  end
375
379
 
376
380
  # Element mappings
377
381
  xml_map.instance_variable_get(:@elements)&.each do |xml_name, rule|
378
- lines << " map_element \"#{xml_name}\", to: :#{rule.to}"
382
+ opts = ["\"#{xml_name}\"", "to: :#{rule.to}"]
383
+ opts << "delegate: :#{rule.delegate}" if rule.delegate
384
+ lines << " map_element #{opts.join(', ')}"
379
385
  end
380
386
 
381
387
  lines << " end"
@@ -21,21 +21,34 @@ module Metaschema
21
21
  "dateTime" => :date_time,
22
22
  "date-with-timezone" => :date,
23
23
  "date-time-with-timezone" => :date_time,
24
+ "day-time-duration" => :string,
24
25
 
25
26
  # String subtypes
26
27
  "uuid" => :string,
27
28
  "uri" => :string,
29
+ "uri-reference" => :string,
28
30
  "email" => :string,
31
+ "email-address" => :string,
29
32
  "hostname" => :string,
30
33
  "ip-address" => :string,
34
+ "ip-v4-address" => :string,
35
+ "ip-v6-address" => :string,
36
+ "base64" => :string,
31
37
 
32
38
  # Markup types — use Metaschema's own types
33
39
  "markup-line" => Metaschema::MarkupLineDatatype,
34
- "markup-multiline" => Metaschema::MarkupLineDatatype,
40
+ "markup-multiline" => Metaschema::MarkupMultilineDatatype,
35
41
  }.freeze
36
42
 
37
43
  MARKUP_TYPES = %w[markup-line markup-multiline].freeze
38
44
 
45
+ # Default JSON value key by data type. Determines the JSON property
46
+ # name that holds a field's content value when serialized.
47
+ JSON_VALUE_KEY = {
48
+ "markup-line" => "RICHTEXT",
49
+ "markup-multiline" => "prose",
50
+ }.freeze
51
+
39
52
  class << self
40
53
  def map(as_type)
41
54
  TYPE_MAP[as_type.to_s] || :string
@@ -49,6 +62,13 @@ module Metaschema
49
62
  as_type.to_s == "markup-multiline"
50
63
  end
51
64
 
65
+ # Returns the default JSON value key for the given data type.
66
+ # E.g. "markup-line" -> "RICHTEXT", "markup-multiline" -> "prose",
67
+ # everything else -> "STRVALUE".
68
+ def json_value_key(as_type)
69
+ JSON_VALUE_KEY[as_type.to_s] || "STRVALUE"
70
+ end
71
+
52
72
  # Register format-specific serializers for types that lutaml-model
53
73
  # doesn't handle correctly out of the box.
54
74
  def register_serializers!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Metaschema
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
data/lib/metaschema.rb CHANGED
@@ -63,6 +63,7 @@ module Metaschema
63
63
  autoload :ListItemType, "metaschema/list_item_type"
64
64
  autoload :ListType, "metaschema/list_type"
65
65
  autoload :MarkupLineDatatype, "metaschema/markup_line_datatype"
66
+ autoload :MarkupMultilineDatatype, "metaschema/markup_multiline_datatype"
66
67
  autoload :MatchesConstraintType, "metaschema/matches_constraint_type"
67
68
  autoload :MetaschemaImportType, "metaschema/metaschema_import_type"
68
69
  autoload :MetaschemaConstraints, "metaschema/metaschema_constraints"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metaschema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
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-04-23 00:00:00.000000000 Z
11
+ date: 2026-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -117,11 +117,18 @@ files:
117
117
  - lib/metaschema/list_type.rb
118
118
  - lib/metaschema/markdown_doc_generator.rb
119
119
  - lib/metaschema/markup_line_datatype.rb
120
+ - lib/metaschema/markup_multiline_datatype.rb
120
121
  - lib/metaschema/matches_constraint_type.rb
121
122
  - lib/metaschema/metapath_evaluator.rb
122
123
  - lib/metaschema/metaschema_constraints.rb
123
124
  - lib/metaschema/metaschema_import_type.rb
124
125
  - lib/metaschema/model_generator.rb
126
+ - lib/metaschema/model_generator/assembly_factory.rb
127
+ - lib/metaschema/model_generator/field_factory.rb
128
+ - lib/metaschema/model_generator/services/collapsibles_collapser.rb
129
+ - lib/metaschema/model_generator/services/field_deserializer.rb
130
+ - lib/metaschema/model_generator/services/field_serializer.rb
131
+ - lib/metaschema/model_generator/utils.rb
125
132
  - lib/metaschema/namespace.rb
126
133
  - lib/metaschema/namespace_binding_type.rb
127
134
  - lib/metaschema/namespace_value.rb