metaschema 0.1.2 → 0.2.1
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.yml +19 -1
- data/.rubocop_todo.yml +558 -8
- data/CLAUDE.md +78 -0
- data/Rakefile +3 -3
- data/exe/metaschema +1 -2
- data/lib/metaschema/allowed_value_type.rb +18 -25
- data/lib/metaschema/allowed_values_type.rb +15 -22
- data/lib/metaschema/anchor_type.rb +15 -20
- data/lib/metaschema/any_type.rb +2 -4
- data/lib/metaschema/assembly.rb +18 -27
- data/lib/metaschema/assembly_model_type.rb +10 -19
- data/lib/metaschema/assembly_reference_type.rb +16 -24
- data/lib/metaschema/augment_type.rb +39 -0
- data/lib/metaschema/block_quote_type.rb +17 -25
- data/lib/metaschema/choice_type.rb +6 -13
- data/lib/metaschema/code_type.rb +17 -23
- data/lib/metaschema/constraint_let_type.rb +5 -9
- data/lib/metaschema/constraint_validator.rb +483 -0
- data/lib/metaschema/define_assembly_constraints_type.rb +17 -26
- data/lib/metaschema/define_field_constraints_type.rb +13 -19
- data/lib/metaschema/define_flag_constraints_type.rb +9 -17
- data/lib/metaschema/example_type.rb +6 -11
- data/lib/metaschema/expect_constraint_type.rb +12 -18
- data/lib/metaschema/field.rb +13 -20
- data/lib/metaschema/field_reference_type.rb +19 -27
- data/lib/metaschema/flag.rb +9 -18
- data/lib/metaschema/flag_reference_type.rb +14 -21
- data/lib/metaschema/formal_name.rb +9 -0
- data/lib/metaschema/global_assembly_definition_type.rb +21 -34
- data/lib/metaschema/global_field_definition_type.rb +26 -39
- data/lib/metaschema/global_flag_definition_type.rb +18 -27
- data/lib/metaschema/group_as_type.rb +7 -9
- data/lib/metaschema/grouped_assembly_reference_type.rb +11 -18
- data/lib/metaschema/grouped_choice_type.rb +16 -24
- data/lib/metaschema/grouped_field_reference_type.rb +11 -18
- data/lib/metaschema/grouped_inline_assembly_definition_type.rb +17 -29
- data/lib/metaschema/grouped_inline_field_definition_type.rb +26 -37
- data/lib/metaschema/image_type.rb +5 -7
- data/lib/metaschema/import.rb +3 -5
- data/lib/metaschema/index_has_key_constraint_type.rb +12 -19
- data/lib/metaschema/inline_assembly_definition_type.rb +25 -38
- data/lib/metaschema/inline_field_definition_type.rb +31 -43
- data/lib/metaschema/inline_flag_definition_type.rb +17 -25
- data/lib/metaschema/inline_markup_type.rb +17 -22
- data/lib/metaschema/insert_type.rb +4 -6
- data/lib/metaschema/json_base_uri.rb +9 -0
- data/lib/metaschema/json_key_type.rb +3 -5
- data/lib/metaschema/json_schema_generator.rb +456 -0
- data/lib/metaschema/json_value_key.rb +9 -0
- data/lib/metaschema/json_value_key_flag_type.rb +3 -5
- data/lib/metaschema/key_field.rb +5 -9
- data/lib/metaschema/list_item_type.rb +29 -39
- data/lib/metaschema/list_type.rb +3 -7
- data/lib/metaschema/markdown_doc_generator.rb +354 -0
- data/lib/metaschema/markup_line_datatype.rb +16 -23
- data/lib/metaschema/matches_constraint_type.rb +12 -18
- data/lib/metaschema/metapath_evaluator.rb +385 -0
- data/lib/metaschema/metaschema_constraints.rb +24 -0
- data/lib/metaschema/metaschema_import_type.rb +3 -5
- data/lib/metaschema/model_generator.rb +2175 -0
- data/lib/metaschema/namespace.rb +8 -0
- data/lib/metaschema/namespace_binding_type.rb +4 -6
- data/lib/metaschema/namespace_value.rb +9 -0
- data/lib/metaschema/ordered_list_type.rb +4 -8
- data/lib/metaschema/preformatted_type.rb +16 -23
- data/lib/metaschema/property_type.rb +6 -8
- data/lib/metaschema/remarks_type.rb +18 -27
- data/lib/metaschema/root.rb +23 -31
- data/lib/metaschema/root_name.rb +3 -5
- data/lib/metaschema/ruby_source_emitter.rb +869 -0
- data/lib/metaschema/schema_version.rb +9 -0
- data/lib/metaschema/scope.rb +7 -13
- data/lib/metaschema/short_name.rb +9 -0
- data/lib/metaschema/table_cell_type.rb +18 -25
- data/lib/metaschema/table_row_type.rb +4 -8
- data/lib/metaschema/table_type.rb +3 -7
- data/lib/metaschema/targeted_allowed_values_constraint_type.rb +16 -23
- data/lib/metaschema/targeted_expect_constraint_type.rb +13 -19
- data/lib/metaschema/targeted_has_cardinality_constraint_type.rb +13 -19
- data/lib/metaschema/targeted_index_constraint_type.rb +13 -20
- data/lib/metaschema/targeted_index_has_key_constraint_type.rb +13 -20
- data/lib/metaschema/targeted_key_constraint_type.rb +12 -19
- data/lib/metaschema/targeted_matches_constraint_type.rb +13 -19
- data/lib/metaschema/type_mapper.rb +82 -0
- data/lib/metaschema/use_name_type.rb +3 -5
- data/lib/metaschema/version.rb +1 -1
- data/lib/metaschema.rb +97 -9
- metadata +28 -95
- data/lib/metaschema/metaschemaconstraints.rb +0 -31
data/lib/metaschema/scope.rb
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'assembly'
|
|
6
|
-
require_relative 'field'
|
|
7
|
-
require_relative 'flag'
|
|
8
|
-
|
|
9
3
|
module Metaschema
|
|
10
4
|
class Scope < Lutaml::Model::Serializable
|
|
11
5
|
attribute :metaschema_namespace, :string
|
|
@@ -15,14 +9,14 @@ module Metaschema
|
|
|
15
9
|
attribute :flag, Flag, collection: true
|
|
16
10
|
|
|
17
11
|
xml do
|
|
18
|
-
|
|
19
|
-
namespace
|
|
12
|
+
element "scope"
|
|
13
|
+
namespace ::Metaschema::Namespace
|
|
20
14
|
|
|
21
|
-
map_attribute
|
|
22
|
-
map_attribute
|
|
23
|
-
map_element
|
|
24
|
-
map_element
|
|
25
|
-
map_element
|
|
15
|
+
map_attribute "metaschema-namespace", to: :metaschema_namespace
|
|
16
|
+
map_attribute "metaschema-short-name", to: :metaschema_short_name
|
|
17
|
+
map_element "field", to: :field
|
|
18
|
+
map_element "assembly", to: :assembly
|
|
19
|
+
map_element "flag", to: :flag
|
|
26
20
|
end
|
|
27
21
|
end
|
|
28
22
|
end
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'anchor_type'
|
|
6
|
-
require_relative 'code_type'
|
|
7
|
-
require_relative 'image_type'
|
|
8
|
-
require_relative 'inline_markup_type'
|
|
9
|
-
require_relative 'insert_type'
|
|
10
|
-
|
|
11
3
|
module Metaschema
|
|
12
4
|
class TableCellType < Lutaml::Model::Serializable
|
|
13
|
-
attribute :content, :string
|
|
14
|
-
attribute :align, :string, default: -> {
|
|
5
|
+
attribute :content, :string, collection: true
|
|
6
|
+
attribute :align, :string, default: -> { "left" }
|
|
15
7
|
attribute :a, AnchorType, collection: true
|
|
16
8
|
attribute :insert, InsertType, collection: true
|
|
17
9
|
attribute :br, :string, collection: true
|
|
@@ -26,23 +18,24 @@ module Metaschema
|
|
|
26
18
|
attribute :img, ImageType, collection: true
|
|
27
19
|
|
|
28
20
|
xml do
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
element "tableCellType"
|
|
22
|
+
mixed_content
|
|
23
|
+
namespace ::Metaschema::Namespace
|
|
31
24
|
|
|
32
25
|
map_content to: :content
|
|
33
|
-
map_attribute
|
|
34
|
-
map_element
|
|
35
|
-
map_element
|
|
36
|
-
map_element
|
|
37
|
-
map_element
|
|
38
|
-
map_element
|
|
39
|
-
map_element
|
|
40
|
-
map_element
|
|
41
|
-
map_element
|
|
42
|
-
map_element
|
|
43
|
-
map_element
|
|
44
|
-
map_element
|
|
45
|
-
map_element
|
|
26
|
+
map_attribute "align", to: :align
|
|
27
|
+
map_element "a", to: :a
|
|
28
|
+
map_element "insert", to: :insert
|
|
29
|
+
map_element "br", to: :br
|
|
30
|
+
map_element "code", to: :code
|
|
31
|
+
map_element "em", to: :em
|
|
32
|
+
map_element "i", to: :i
|
|
33
|
+
map_element "b", to: :b
|
|
34
|
+
map_element "strong", to: :strong
|
|
35
|
+
map_element "sub", to: :sub
|
|
36
|
+
map_element "sup", to: :sup
|
|
37
|
+
map_element "q", to: :q
|
|
38
|
+
map_element "img", to: :img
|
|
46
39
|
end
|
|
47
40
|
end
|
|
48
41
|
end
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'table_cell_type'
|
|
6
|
-
|
|
7
3
|
module Metaschema
|
|
8
4
|
class TableRowType < Lutaml::Model::Serializable
|
|
9
5
|
attribute :td, TableCellType, collection: true
|
|
10
6
|
attribute :th, TableCellType, collection: true
|
|
11
7
|
|
|
12
8
|
xml do
|
|
13
|
-
|
|
14
|
-
namespace
|
|
9
|
+
element "tableRowType"
|
|
10
|
+
namespace ::Metaschema::Namespace
|
|
15
11
|
|
|
16
|
-
map_element
|
|
17
|
-
map_element
|
|
12
|
+
map_element "td", to: :td
|
|
13
|
+
map_element "th", to: :th
|
|
18
14
|
end
|
|
19
15
|
end
|
|
20
16
|
end
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'table_row_type'
|
|
6
|
-
|
|
7
3
|
module Metaschema
|
|
8
4
|
class TableType < Lutaml::Model::Serializable
|
|
9
5
|
attribute :tr, TableRowType, collection: true
|
|
10
6
|
|
|
11
7
|
xml do
|
|
12
|
-
|
|
13
|
-
namespace
|
|
8
|
+
element "tableType"
|
|
9
|
+
namespace ::Metaschema::Namespace
|
|
14
10
|
|
|
15
|
-
map_element
|
|
11
|
+
map_element "tr", to: :tr
|
|
16
12
|
end
|
|
17
13
|
end
|
|
18
14
|
end
|
|
@@ -1,39 +1,32 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'allowed_value_type'
|
|
6
|
-
require_relative 'markup_line_datatype'
|
|
7
|
-
require_relative 'property_type'
|
|
8
|
-
require_relative 'remarks_type'
|
|
9
|
-
|
|
10
3
|
module Metaschema
|
|
11
4
|
class TargetedAllowedValuesConstraintType < Lutaml::Model::Serializable
|
|
12
5
|
attribute :id, :string
|
|
13
|
-
attribute :level, :string, default: -> {
|
|
14
|
-
attribute :allow_other, :string, default: -> {
|
|
15
|
-
attribute :extensible, :string, default: -> {
|
|
6
|
+
attribute :level, :string, default: -> { "ERROR" }
|
|
7
|
+
attribute :allow_other, :string, default: -> { "no" }
|
|
8
|
+
attribute :extensible, :string, default: -> { "external" }
|
|
16
9
|
attribute :target, :string
|
|
17
|
-
attribute :formal_name,
|
|
10
|
+
attribute :formal_name, FormalName
|
|
18
11
|
attribute :description, MarkupLineDatatype
|
|
19
12
|
attribute :prop, PropertyType, collection: true
|
|
20
13
|
attribute :enum, AllowedValueType, collection: true
|
|
21
14
|
attribute :remarks, RemarksType
|
|
22
15
|
|
|
23
16
|
xml do
|
|
24
|
-
|
|
25
|
-
namespace
|
|
17
|
+
element "TargetedAllowedValuesConstraintType"
|
|
18
|
+
namespace ::Metaschema::Namespace
|
|
26
19
|
|
|
27
|
-
map_attribute
|
|
28
|
-
map_attribute
|
|
29
|
-
map_attribute
|
|
30
|
-
map_attribute
|
|
31
|
-
map_attribute
|
|
32
|
-
map_element
|
|
33
|
-
map_element
|
|
34
|
-
map_element
|
|
35
|
-
map_element
|
|
36
|
-
map_element
|
|
20
|
+
map_attribute "id", to: :id
|
|
21
|
+
map_attribute "level", to: :level
|
|
22
|
+
map_attribute "allow-other", to: :allow_other
|
|
23
|
+
map_attribute "extensible", to: :extensible
|
|
24
|
+
map_attribute "target", to: :target
|
|
25
|
+
map_element "formal-name", to: :formal_name
|
|
26
|
+
map_element "description", to: :description
|
|
27
|
+
map_element "prop", to: :prop
|
|
28
|
+
map_element "enum", to: :enum
|
|
29
|
+
map_element "remarks", to: :remarks
|
|
37
30
|
end
|
|
38
31
|
end
|
|
39
32
|
end
|
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'markup_line_datatype'
|
|
6
|
-
require_relative 'property_type'
|
|
7
|
-
require_relative 'remarks_type'
|
|
8
|
-
|
|
9
3
|
module Metaschema
|
|
10
4
|
class TargetedExpectConstraintType < Lutaml::Model::Serializable
|
|
11
5
|
attribute :id, :string
|
|
12
|
-
attribute :level, :string, default: -> {
|
|
6
|
+
attribute :level, :string, default: -> { "ERROR" }
|
|
13
7
|
attribute :test, :string
|
|
14
8
|
attribute :target, :string
|
|
15
|
-
attribute :formal_name,
|
|
9
|
+
attribute :formal_name, FormalName
|
|
16
10
|
attribute :description, MarkupLineDatatype
|
|
17
11
|
attribute :prop, PropertyType, collection: true
|
|
18
12
|
attribute :message, :string
|
|
19
13
|
attribute :remarks, RemarksType
|
|
20
14
|
|
|
21
15
|
xml do
|
|
22
|
-
|
|
23
|
-
namespace
|
|
16
|
+
element "TargetedExpectConstraintType"
|
|
17
|
+
namespace ::Metaschema::Namespace
|
|
24
18
|
|
|
25
|
-
map_attribute
|
|
26
|
-
map_attribute
|
|
27
|
-
map_attribute
|
|
28
|
-
map_attribute
|
|
29
|
-
map_element
|
|
30
|
-
map_element
|
|
31
|
-
map_element
|
|
32
|
-
map_element
|
|
33
|
-
map_element
|
|
19
|
+
map_attribute "id", to: :id
|
|
20
|
+
map_attribute "level", to: :level
|
|
21
|
+
map_attribute "test", to: :test
|
|
22
|
+
map_attribute "target", to: :target
|
|
23
|
+
map_element "formal-name", to: :formal_name
|
|
24
|
+
map_element "description", to: :description
|
|
25
|
+
map_element "prop", to: :prop
|
|
26
|
+
map_element "message", to: :message
|
|
27
|
+
map_element "remarks", to: :remarks
|
|
34
28
|
end
|
|
35
29
|
end
|
|
36
30
|
end
|
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'markup_line_datatype'
|
|
6
|
-
require_relative 'property_type'
|
|
7
|
-
require_relative 'remarks_type'
|
|
8
|
-
|
|
9
3
|
module Metaschema
|
|
10
4
|
class TargetedHasCardinalityConstraintType < Lutaml::Model::Serializable
|
|
11
5
|
attribute :id, :string
|
|
12
|
-
attribute :level, :string, default: -> {
|
|
6
|
+
attribute :level, :string, default: -> { "ERROR" }
|
|
13
7
|
attribute :target, :string
|
|
14
8
|
attribute :min_occurs, :integer
|
|
15
9
|
attribute :max_occurs, :integer
|
|
16
|
-
attribute :formal_name,
|
|
10
|
+
attribute :formal_name, FormalName
|
|
17
11
|
attribute :description, MarkupLineDatatype
|
|
18
12
|
attribute :prop, PropertyType, collection: true
|
|
19
13
|
attribute :remarks, RemarksType
|
|
20
14
|
|
|
21
15
|
xml do
|
|
22
|
-
|
|
23
|
-
namespace
|
|
16
|
+
element "TargetedHasCardinalityConstraintType"
|
|
17
|
+
namespace ::Metaschema::Namespace
|
|
24
18
|
|
|
25
|
-
map_attribute
|
|
26
|
-
map_attribute
|
|
27
|
-
map_attribute
|
|
28
|
-
map_attribute
|
|
29
|
-
map_attribute
|
|
30
|
-
map_element
|
|
31
|
-
map_element
|
|
32
|
-
map_element
|
|
33
|
-
map_element
|
|
19
|
+
map_attribute "id", to: :id
|
|
20
|
+
map_attribute "level", to: :level
|
|
21
|
+
map_attribute "target", to: :target
|
|
22
|
+
map_attribute "min-occurs", to: :min_occurs
|
|
23
|
+
map_attribute "max-occurs", to: :max_occurs
|
|
24
|
+
map_element "formal-name", to: :formal_name
|
|
25
|
+
map_element "description", to: :description
|
|
26
|
+
map_element "prop", to: :prop
|
|
27
|
+
map_element "remarks", to: :remarks
|
|
34
28
|
end
|
|
35
29
|
end
|
|
36
30
|
end
|
|
@@ -1,37 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'key_field'
|
|
6
|
-
require_relative 'markup_line_datatype'
|
|
7
|
-
require_relative 'property_type'
|
|
8
|
-
require_relative 'remarks_type'
|
|
9
|
-
|
|
10
3
|
module Metaschema
|
|
11
4
|
class TargetedIndexConstraintType < Lutaml::Model::Serializable
|
|
12
5
|
attribute :id, :string
|
|
13
|
-
attribute :level, :string, default: -> {
|
|
6
|
+
attribute :level, :string, default: -> { "ERROR" }
|
|
14
7
|
attribute :target, :string
|
|
15
8
|
attribute :name, :string
|
|
16
|
-
attribute :formal_name,
|
|
9
|
+
attribute :formal_name, FormalName
|
|
17
10
|
attribute :description, MarkupLineDatatype
|
|
18
11
|
attribute :prop, PropertyType, collection: true
|
|
19
12
|
attribute :key_field, KeyField, collection: true
|
|
20
13
|
attribute :remarks, RemarksType
|
|
21
14
|
|
|
22
15
|
xml do
|
|
23
|
-
|
|
24
|
-
namespace
|
|
16
|
+
element "TargetedIndexConstraintType"
|
|
17
|
+
namespace ::Metaschema::Namespace
|
|
25
18
|
|
|
26
|
-
map_attribute
|
|
27
|
-
map_attribute
|
|
28
|
-
map_attribute
|
|
29
|
-
map_attribute
|
|
30
|
-
map_element
|
|
31
|
-
map_element
|
|
32
|
-
map_element
|
|
33
|
-
map_element
|
|
34
|
-
map_element
|
|
19
|
+
map_attribute "id", to: :id
|
|
20
|
+
map_attribute "level", to: :level
|
|
21
|
+
map_attribute "target", to: :target
|
|
22
|
+
map_attribute "name", to: :name
|
|
23
|
+
map_element "formal-name", to: :formal_name
|
|
24
|
+
map_element "description", to: :description
|
|
25
|
+
map_element "prop", to: :prop
|
|
26
|
+
map_element "key-field", to: :key_field
|
|
27
|
+
map_element "remarks", to: :remarks
|
|
35
28
|
end
|
|
36
29
|
end
|
|
37
30
|
end
|
|
@@ -1,37 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'key_field'
|
|
6
|
-
require_relative 'markup_line_datatype'
|
|
7
|
-
require_relative 'property_type'
|
|
8
|
-
require_relative 'remarks_type'
|
|
9
|
-
|
|
10
3
|
module Metaschema
|
|
11
4
|
class TargetedIndexHasKeyConstraintType < Lutaml::Model::Serializable
|
|
12
5
|
attribute :id, :string
|
|
13
|
-
attribute :level, :string, default: -> {
|
|
6
|
+
attribute :level, :string, default: -> { "ERROR" }
|
|
14
7
|
attribute :name, :string
|
|
15
8
|
attribute :target, :string
|
|
16
|
-
attribute :formal_name,
|
|
9
|
+
attribute :formal_name, FormalName
|
|
17
10
|
attribute :description, MarkupLineDatatype
|
|
18
11
|
attribute :prop, PropertyType, collection: true
|
|
19
12
|
attribute :key_field, KeyField, collection: true
|
|
20
13
|
attribute :remarks, RemarksType
|
|
21
14
|
|
|
22
15
|
xml do
|
|
23
|
-
|
|
24
|
-
namespace
|
|
16
|
+
element "TargetedIndexHasKeyConstraintType"
|
|
17
|
+
namespace ::Metaschema::Namespace
|
|
25
18
|
|
|
26
|
-
map_attribute
|
|
27
|
-
map_attribute
|
|
28
|
-
map_attribute
|
|
29
|
-
map_attribute
|
|
30
|
-
map_element
|
|
31
|
-
map_element
|
|
32
|
-
map_element
|
|
33
|
-
map_element
|
|
34
|
-
map_element
|
|
19
|
+
map_attribute "id", to: :id
|
|
20
|
+
map_attribute "level", to: :level
|
|
21
|
+
map_attribute "name", to: :name
|
|
22
|
+
map_attribute "target", to: :target
|
|
23
|
+
map_element "formal-name", to: :formal_name
|
|
24
|
+
map_element "description", to: :description
|
|
25
|
+
map_element "prop", to: :prop
|
|
26
|
+
map_element "key-field", to: :key_field
|
|
27
|
+
map_element "remarks", to: :remarks
|
|
35
28
|
end
|
|
36
29
|
end
|
|
37
30
|
end
|
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'key_field'
|
|
6
|
-
require_relative 'markup_line_datatype'
|
|
7
|
-
require_relative 'property_type'
|
|
8
|
-
require_relative 'remarks_type'
|
|
9
|
-
|
|
10
3
|
module Metaschema
|
|
11
4
|
class TargetedKeyConstraintType < Lutaml::Model::Serializable
|
|
12
5
|
attribute :id, :string
|
|
13
|
-
attribute :level, :string, default: -> {
|
|
6
|
+
attribute :level, :string, default: -> { "ERROR" }
|
|
14
7
|
attribute :target, :string
|
|
15
|
-
attribute :formal_name,
|
|
8
|
+
attribute :formal_name, FormalName
|
|
16
9
|
attribute :description, MarkupLineDatatype
|
|
17
10
|
attribute :prop, PropertyType, collection: true
|
|
18
11
|
attribute :key_field, KeyField, collection: true
|
|
19
12
|
attribute :remarks, RemarksType
|
|
20
13
|
|
|
21
14
|
xml do
|
|
22
|
-
|
|
23
|
-
namespace
|
|
15
|
+
element "TargetedKeyConstraintType"
|
|
16
|
+
namespace ::Metaschema::Namespace
|
|
24
17
|
|
|
25
|
-
map_attribute
|
|
26
|
-
map_attribute
|
|
27
|
-
map_attribute
|
|
28
|
-
map_element
|
|
29
|
-
map_element
|
|
30
|
-
map_element
|
|
31
|
-
map_element
|
|
32
|
-
map_element
|
|
18
|
+
map_attribute "id", to: :id
|
|
19
|
+
map_attribute "level", to: :level
|
|
20
|
+
map_attribute "target", to: :target
|
|
21
|
+
map_element "formal-name", to: :formal_name
|
|
22
|
+
map_element "description", to: :description
|
|
23
|
+
map_element "prop", to: :prop
|
|
24
|
+
map_element "key-field", to: :key_field
|
|
25
|
+
map_element "remarks", to: :remarks
|
|
33
26
|
end
|
|
34
27
|
end
|
|
35
28
|
end
|
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
|
-
require_relative 'markup_line_datatype'
|
|
6
|
-
require_relative 'property_type'
|
|
7
|
-
require_relative 'remarks_type'
|
|
8
|
-
|
|
9
3
|
module Metaschema
|
|
10
4
|
class TargetedMatchesConstraintType < Lutaml::Model::Serializable
|
|
11
5
|
attribute :id, :string
|
|
12
|
-
attribute :level, :string, default: -> {
|
|
6
|
+
attribute :level, :string, default: -> { "ERROR" }
|
|
13
7
|
attribute :regex, :string
|
|
14
8
|
attribute :datatype, :string
|
|
15
9
|
attribute :target, :string
|
|
16
|
-
attribute :formal_name,
|
|
10
|
+
attribute :formal_name, FormalName
|
|
17
11
|
attribute :description, MarkupLineDatatype
|
|
18
12
|
attribute :prop, PropertyType, collection: true
|
|
19
13
|
attribute :remarks, RemarksType
|
|
20
14
|
|
|
21
15
|
xml do
|
|
22
|
-
|
|
23
|
-
namespace
|
|
16
|
+
element "TargetedMatchesConstraintType"
|
|
17
|
+
namespace ::Metaschema::Namespace
|
|
24
18
|
|
|
25
|
-
map_attribute
|
|
26
|
-
map_attribute
|
|
27
|
-
map_attribute
|
|
28
|
-
map_attribute
|
|
29
|
-
map_attribute
|
|
30
|
-
map_element
|
|
31
|
-
map_element
|
|
32
|
-
map_element
|
|
33
|
-
map_element
|
|
19
|
+
map_attribute "id", to: :id
|
|
20
|
+
map_attribute "level", to: :level
|
|
21
|
+
map_attribute "regex", to: :regex
|
|
22
|
+
map_attribute "datatype", to: :datatype
|
|
23
|
+
map_attribute "target", to: :target
|
|
24
|
+
map_element "formal-name", to: :formal_name
|
|
25
|
+
map_element "description", to: :description
|
|
26
|
+
map_element "prop", to: :prop
|
|
27
|
+
map_element "remarks", to: :remarks
|
|
34
28
|
end
|
|
35
29
|
end
|
|
36
30
|
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Metaschema
|
|
4
|
+
class TypeMapper
|
|
5
|
+
TYPE_MAP = {
|
|
6
|
+
# Basic types
|
|
7
|
+
"string" => :string,
|
|
8
|
+
"token" => :string,
|
|
9
|
+
"boolean" => :boolean,
|
|
10
|
+
"integer" => :integer,
|
|
11
|
+
"decimal" => :decimal,
|
|
12
|
+
|
|
13
|
+
# Integer subtypes
|
|
14
|
+
"positive-integer" => :integer,
|
|
15
|
+
"negative-integer" => :integer,
|
|
16
|
+
"non-positive-integer" => :integer,
|
|
17
|
+
"non-negative-integer" => :integer,
|
|
18
|
+
|
|
19
|
+
# Date/time types
|
|
20
|
+
"date" => :date,
|
|
21
|
+
"dateTime" => :date_time,
|
|
22
|
+
"date-with-timezone" => :date,
|
|
23
|
+
"date-time-with-timezone" => :date_time,
|
|
24
|
+
|
|
25
|
+
# String subtypes
|
|
26
|
+
"uuid" => :string,
|
|
27
|
+
"uri" => :string,
|
|
28
|
+
"email" => :string,
|
|
29
|
+
"hostname" => :string,
|
|
30
|
+
"ip-address" => :string,
|
|
31
|
+
|
|
32
|
+
# Markup types — use Metaschema's own types
|
|
33
|
+
"markup-line" => Metaschema::MarkupLineDatatype,
|
|
34
|
+
"markup-multiline" => Metaschema::MarkupLineDatatype,
|
|
35
|
+
}.freeze
|
|
36
|
+
|
|
37
|
+
MARKUP_TYPES = %w[markup-line markup-multiline].freeze
|
|
38
|
+
|
|
39
|
+
class << self
|
|
40
|
+
def map(as_type)
|
|
41
|
+
TYPE_MAP[as_type.to_s] || :string
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def markup?(as_type)
|
|
45
|
+
MARKUP_TYPES.include?(as_type.to_s)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def multiline?(as_type)
|
|
49
|
+
as_type.to_s == "markup-multiline"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Register format-specific serializers for types that lutaml-model
|
|
53
|
+
# doesn't handle correctly out of the box.
|
|
54
|
+
def register_serializers!
|
|
55
|
+
# Decimal JSON — BigDecimal#to_s defaults to scientific
|
|
56
|
+
# notation ("0.11e1"); JSON needs plain notation (1.1)
|
|
57
|
+
Lutaml::Model::Type::Value.register_format_type_serializer(
|
|
58
|
+
:json, Lutaml::Model::Type::Decimal,
|
|
59
|
+
to: lambda { |inst|
|
|
60
|
+
return nil unless inst.value
|
|
61
|
+
|
|
62
|
+
v = inst.value
|
|
63
|
+
v = Lutaml::Model::Type::Decimal.cast(v) unless v.is_a?(BigDecimal)
|
|
64
|
+
v.to_f
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# Decimal XML — same scientific notation issue
|
|
69
|
+
Lutaml::Model::Type::Value.register_format_type_serializer(
|
|
70
|
+
:xml, Lutaml::Model::Type::Decimal,
|
|
71
|
+
to: lambda { |inst|
|
|
72
|
+
return nil unless inst.value
|
|
73
|
+
|
|
74
|
+
v = inst.value
|
|
75
|
+
v = Lutaml::Model::Type::Decimal.cast(v) unless v.is_a?(BigDecimal)
|
|
76
|
+
v.to_s("F")
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'lutaml/model'
|
|
4
|
-
|
|
5
3
|
module Metaschema
|
|
6
4
|
class UseNameType < Lutaml::Model::Serializable
|
|
7
5
|
attribute :content, :string
|
|
8
6
|
attribute :index, :integer
|
|
9
7
|
|
|
10
8
|
xml do
|
|
11
|
-
|
|
12
|
-
namespace
|
|
9
|
+
element "UseNameType"
|
|
10
|
+
namespace ::Metaschema::Namespace
|
|
13
11
|
|
|
14
12
|
map_content to: :content
|
|
15
|
-
map_attribute
|
|
13
|
+
map_attribute "index", to: :index
|
|
16
14
|
end
|
|
17
15
|
end
|
|
18
16
|
end
|
data/lib/metaschema/version.rb
CHANGED