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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +19 -1
  3. data/.rubocop_todo.yml +558 -8
  4. data/CLAUDE.md +78 -0
  5. data/Rakefile +3 -3
  6. data/exe/metaschema +1 -2
  7. data/lib/metaschema/allowed_value_type.rb +18 -25
  8. data/lib/metaschema/allowed_values_type.rb +15 -22
  9. data/lib/metaschema/anchor_type.rb +15 -20
  10. data/lib/metaschema/any_type.rb +2 -4
  11. data/lib/metaschema/assembly.rb +18 -27
  12. data/lib/metaschema/assembly_model_type.rb +10 -19
  13. data/lib/metaschema/assembly_reference_type.rb +16 -24
  14. data/lib/metaschema/augment_type.rb +39 -0
  15. data/lib/metaschema/block_quote_type.rb +17 -25
  16. data/lib/metaschema/choice_type.rb +6 -13
  17. data/lib/metaschema/code_type.rb +17 -23
  18. data/lib/metaschema/constraint_let_type.rb +5 -9
  19. data/lib/metaschema/constraint_validator.rb +483 -0
  20. data/lib/metaschema/define_assembly_constraints_type.rb +17 -26
  21. data/lib/metaschema/define_field_constraints_type.rb +13 -19
  22. data/lib/metaschema/define_flag_constraints_type.rb +9 -17
  23. data/lib/metaschema/example_type.rb +6 -11
  24. data/lib/metaschema/expect_constraint_type.rb +12 -18
  25. data/lib/metaschema/field.rb +13 -20
  26. data/lib/metaschema/field_reference_type.rb +19 -27
  27. data/lib/metaschema/flag.rb +9 -18
  28. data/lib/metaschema/flag_reference_type.rb +14 -21
  29. data/lib/metaschema/formal_name.rb +9 -0
  30. data/lib/metaschema/global_assembly_definition_type.rb +21 -34
  31. data/lib/metaschema/global_field_definition_type.rb +26 -39
  32. data/lib/metaschema/global_flag_definition_type.rb +18 -27
  33. data/lib/metaschema/group_as_type.rb +7 -9
  34. data/lib/metaschema/grouped_assembly_reference_type.rb +11 -18
  35. data/lib/metaschema/grouped_choice_type.rb +16 -24
  36. data/lib/metaschema/grouped_field_reference_type.rb +11 -18
  37. data/lib/metaschema/grouped_inline_assembly_definition_type.rb +17 -29
  38. data/lib/metaschema/grouped_inline_field_definition_type.rb +26 -37
  39. data/lib/metaschema/image_type.rb +5 -7
  40. data/lib/metaschema/import.rb +3 -5
  41. data/lib/metaschema/index_has_key_constraint_type.rb +12 -19
  42. data/lib/metaschema/inline_assembly_definition_type.rb +25 -38
  43. data/lib/metaschema/inline_field_definition_type.rb +31 -43
  44. data/lib/metaschema/inline_flag_definition_type.rb +17 -25
  45. data/lib/metaschema/inline_markup_type.rb +17 -22
  46. data/lib/metaschema/insert_type.rb +4 -6
  47. data/lib/metaschema/json_base_uri.rb +9 -0
  48. data/lib/metaschema/json_key_type.rb +3 -5
  49. data/lib/metaschema/json_schema_generator.rb +456 -0
  50. data/lib/metaschema/json_value_key.rb +9 -0
  51. data/lib/metaschema/json_value_key_flag_type.rb +3 -5
  52. data/lib/metaschema/key_field.rb +5 -9
  53. data/lib/metaschema/list_item_type.rb +29 -39
  54. data/lib/metaschema/list_type.rb +3 -7
  55. data/lib/metaschema/markdown_doc_generator.rb +354 -0
  56. data/lib/metaschema/markup_line_datatype.rb +16 -23
  57. data/lib/metaschema/matches_constraint_type.rb +12 -18
  58. data/lib/metaschema/metapath_evaluator.rb +385 -0
  59. data/lib/metaschema/metaschema_constraints.rb +24 -0
  60. data/lib/metaschema/metaschema_import_type.rb +3 -5
  61. data/lib/metaschema/model_generator.rb +2175 -0
  62. data/lib/metaschema/namespace.rb +8 -0
  63. data/lib/metaschema/namespace_binding_type.rb +4 -6
  64. data/lib/metaschema/namespace_value.rb +9 -0
  65. data/lib/metaschema/ordered_list_type.rb +4 -8
  66. data/lib/metaschema/preformatted_type.rb +16 -23
  67. data/lib/metaschema/property_type.rb +6 -8
  68. data/lib/metaschema/remarks_type.rb +18 -27
  69. data/lib/metaschema/root.rb +23 -31
  70. data/lib/metaschema/root_name.rb +3 -5
  71. data/lib/metaschema/ruby_source_emitter.rb +869 -0
  72. data/lib/metaschema/schema_version.rb +9 -0
  73. data/lib/metaschema/scope.rb +7 -13
  74. data/lib/metaschema/short_name.rb +9 -0
  75. data/lib/metaschema/table_cell_type.rb +18 -25
  76. data/lib/metaschema/table_row_type.rb +4 -8
  77. data/lib/metaschema/table_type.rb +3 -7
  78. data/lib/metaschema/targeted_allowed_values_constraint_type.rb +16 -23
  79. data/lib/metaschema/targeted_expect_constraint_type.rb +13 -19
  80. data/lib/metaschema/targeted_has_cardinality_constraint_type.rb +13 -19
  81. data/lib/metaschema/targeted_index_constraint_type.rb +13 -20
  82. data/lib/metaschema/targeted_index_has_key_constraint_type.rb +13 -20
  83. data/lib/metaschema/targeted_key_constraint_type.rb +12 -19
  84. data/lib/metaschema/targeted_matches_constraint_type.rb +13 -19
  85. data/lib/metaschema/type_mapper.rb +82 -0
  86. data/lib/metaschema/use_name_type.rb +3 -5
  87. data/lib/metaschema/version.rb +1 -1
  88. data/lib/metaschema.rb +97 -9
  89. metadata +28 -95
  90. data/lib/metaschema/metaschemaconstraints.rb +0 -31
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metaschema
4
+ class Namespace < Lutaml::Xml::Namespace
5
+ uri "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
6
+ prefix_default "m"
7
+ end
8
+ 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 NamespaceBindingType < Lutaml::Model::Serializable
7
5
  attribute :prefix, :string
8
6
  attribute :uri, :string
9
7
 
10
8
  xml do
11
- root 'NamespaceBindingType'
12
- namespace 'http://csrc.nist.gov/ns/oscal/metaschema/1.0'
9
+ element "NamespaceBindingType"
10
+ namespace ::Metaschema::Namespace
13
11
 
14
- map_attribute 'prefix', to: :prefix
15
- map_attribute 'uri', to: :uri
12
+ map_attribute "prefix", to: :prefix
13
+ map_attribute "uri", to: :uri
16
14
  end
17
15
  end
18
16
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metaschema
4
+ class NamespaceValue < Lutaml::Model::Type::String
5
+ xml do
6
+ namespace ::Metaschema::Namespace
7
+ end
8
+ end
9
+ end
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lutaml/model'
4
-
5
- # require_relative "list_item_type"
6
-
7
3
  module Metaschema
8
4
  class ListItemType < Lutaml::Model::Serializable; end
9
5
 
@@ -12,11 +8,11 @@ module Metaschema
12
8
  attribute :li, ListItemType, collection: true
13
9
 
14
10
  xml do
15
- root 'orderedListType'
16
- namespace 'http://csrc.nist.gov/ns/oscal/metaschema/1.0'
11
+ element "orderedListType"
12
+ namespace ::Metaschema::Namespace
17
13
 
18
- map_attribute 'start', to: :start
19
- map_element 'li', to: :li
14
+ map_attribute "start", to: :start
15
+ map_element "li", to: :li
20
16
  end
21
17
  end
22
18
  end
@@ -1,16 +1,8 @@
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 PreformattedType < Lutaml::Model::Serializable
13
- attribute :content, :string
5
+ attribute :content, :string, collection: true
14
6
  attribute :a, AnchorType, collection: true
15
7
  attribute :insert, InsertType, collection: true
16
8
  attribute :br, :string, collection: true
@@ -25,22 +17,23 @@ module Metaschema
25
17
  attribute :img, ImageType, collection: true
26
18
 
27
19
  xml do
28
- root 'preformattedType', mixed: true
29
- namespace 'http://csrc.nist.gov/ns/oscal/metaschema/1.0'
20
+ element "preformattedType"
21
+ mixed_content
22
+ namespace ::Metaschema::Namespace
30
23
 
31
24
  map_content to: :content
32
- map_element 'a', to: :a
33
- map_element 'insert', to: :insert
34
- map_element 'br', to: :br
35
- map_element 'code', to: :code
36
- map_element 'em', to: :em
37
- map_element 'i', to: :i
38
- map_element 'b', to: :b
39
- map_element 'strong', to: :strong
40
- map_element 'sub', to: :sub
41
- map_element 'sup', to: :sup
42
- map_element 'q', to: :q
43
- map_element 'img', to: :img
25
+ map_element "a", to: :a
26
+ map_element "insert", to: :insert
27
+ map_element "br", to: :br
28
+ map_element "code", to: :code
29
+ map_element "em", to: :em
30
+ map_element "i", to: :i
31
+ map_element "b", to: :b
32
+ map_element "strong", to: :strong
33
+ map_element "sub", to: :sub
34
+ map_element "sup", to: :sup
35
+ map_element "q", to: :q
36
+ map_element "img", to: :img
44
37
  end
45
38
  end
46
39
  end
@@ -1,20 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lutaml/model'
4
-
5
3
  module Metaschema
6
4
  class PropertyType < Lutaml::Model::Serializable
7
- attribute :namespace, :string, default: -> { 'http://csrc.nist.gov/ns/oscal/metaschema/1.0' }
5
+ attribute :namespace, :string, default: -> { "http://csrc.nist.gov/ns/oscal/metaschema/1.0" }
8
6
  attribute :name, :string
9
7
  attribute :value, :string
10
8
 
11
9
  xml do
12
- root 'PropertyType'
13
- namespace 'http://csrc.nist.gov/ns/oscal/metaschema/1.0'
10
+ element "PropertyType"
11
+ namespace ::Metaschema::Namespace
14
12
 
15
- map_attribute 'namespace', to: :namespace
16
- map_attribute 'name', to: :name
17
- map_attribute 'value', to: :value
13
+ map_attribute "namespace", to: :namespace
14
+ map_attribute "name", to: :name
15
+ map_attribute "value", to: :value
18
16
  end
19
17
  end
20
18
  end
@@ -1,15 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lutaml/model'
4
-
5
- require_relative 'block_quote_type'
6
- require_relative 'image_type'
7
- require_relative 'inline_markup_type'
8
- require_relative 'list_type'
9
- require_relative 'ordered_list_type'
10
- require_relative 'preformatted_type'
11
- require_relative 'table_type'
12
-
13
3
  module Metaschema
14
4
  class RemarksType < Lutaml::Model::Serializable
15
5
  attribute :klass, :string
@@ -29,24 +19,25 @@ module Metaschema
29
19
  attribute :img, ImageType, collection: true
30
20
 
31
21
  xml do
32
- root 'RemarksType', mixed: true
33
- namespace 'http://csrc.nist.gov/ns/oscal/metaschema/1.0'
22
+ element "RemarksType"
23
+ mixed_content
24
+ namespace ::Metaschema::Namespace
34
25
 
35
- map_attribute 'class', to: :klass
36
- map_element 'h1', to: :h1
37
- map_element 'h2', to: :h2
38
- map_element 'h3', to: :h3
39
- map_element 'h4', to: :h4
40
- map_element 'h5', to: :h5
41
- map_element 'h6', to: :h6
42
- map_element 'ul', to: :ul
43
- map_element 'ol', to: :ol
44
- map_element 'pre', to: :pre
45
- map_element 'hr', to: :hr
46
- map_element 'blockquote', to: :blockquote
47
- map_element 'p', to: :p
48
- map_element 'table', to: :table
49
- map_element 'img', to: :img
26
+ map_attribute "class", to: :klass
27
+ map_element "h1", to: :h1
28
+ map_element "h2", to: :h2
29
+ map_element "h3", to: :h3
30
+ map_element "h4", to: :h4
31
+ map_element "h5", to: :h5
32
+ map_element "h6", to: :h6
33
+ map_element "ul", to: :ul
34
+ map_element "ol", to: :ol
35
+ map_element "pre", to: :pre
36
+ map_element "hr", to: :hr
37
+ map_element "blockquote", to: :blockquote
38
+ map_element "p", to: :p
39
+ map_element "table", to: :table
40
+ map_element "img", to: :img
50
41
  end
51
42
  end
52
43
  end
@@ -1,24 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lutaml/model'
4
-
5
- require_relative 'global_assembly_definition_type'
6
- require_relative 'global_field_definition_type'
7
- require_relative 'global_flag_definition_type'
8
- require_relative 'markup_line_datatype'
9
- require_relative 'metaschema_import_type'
10
- require_relative 'namespace_binding_type'
11
- require_relative 'property_type'
12
- require_relative 'remarks_type'
13
-
14
3
  module Metaschema
15
4
  class Root < Lutaml::Model::Serializable
16
- attribute :abstract, :string, default: -> { 'no' }
5
+ attribute :abstract, :string, default: -> { "no" }
17
6
  attribute :schema_name, MarkupLineDatatype
18
- attribute :schema_version, :string
19
- attribute :short_name, :string
20
- attribute :namespace, :string
21
- attribute :json_base_uri, :string
7
+ attribute :schema_version, SchemaVersion
8
+ attribute :short_name, ShortName
9
+ attribute :namespace, NamespaceValue
10
+ attribute :json_base_uri, JsonBaseUri
22
11
  attribute :prop, PropertyType, collection: true
23
12
  attribute :remarks, RemarksType
24
13
  attribute :import, MetaschemaImportType, collection: true
@@ -26,24 +15,27 @@ module Metaschema
26
15
  attribute :define_assembly, GlobalAssemblyDefinitionType, collection: true
27
16
  attribute :define_field, GlobalFieldDefinitionType, collection: true
28
17
  attribute :define_flag, GlobalFlagDefinitionType, collection: true
18
+ attribute :augment, AugmentType, collection: true
29
19
 
30
20
  xml do
31
- root 'METASCHEMA', ordered: true
32
- namespace 'http://csrc.nist.gov/ns/oscal/metaschema/1.0'
21
+ element "METASCHEMA"
22
+ ordered
23
+ namespace ::Metaschema::Namespace
33
24
 
34
- map_attribute 'abstract', to: :abstract
35
- map_element 'schema-name', to: :schema_name
36
- map_element 'schema-version', to: :schema_version
37
- map_element 'short-name', to: :short_name
38
- map_element 'namespace', to: :namespace
39
- map_element 'json-base-uri', to: :json_base_uri
40
- map_element 'prop', to: :prop
41
- map_element 'remarks', to: :remarks
42
- map_element 'import', to: :import
43
- map_element 'namespace-binding', to: :namespace_binding
44
- map_element 'define-assembly', to: :define_assembly
45
- map_element 'define-field', to: :define_field
46
- map_element 'define-flag', to: :define_flag
25
+ map_attribute "abstract", to: :abstract
26
+ map_element "schema-name", to: :schema_name
27
+ map_element "schema-version", to: :schema_version
28
+ map_element "short-name", to: :short_name
29
+ map_element "namespace", to: :namespace
30
+ map_element "json-base-uri", to: :json_base_uri
31
+ map_element "prop", to: :prop
32
+ map_element "remarks", to: :remarks
33
+ map_element "import", to: :import
34
+ map_element "namespace-binding", to: :namespace_binding
35
+ map_element "define-assembly", to: :define_assembly
36
+ map_element "define-field", to: :define_field
37
+ map_element "define-flag", to: :define_flag
38
+ map_element "augment", to: :augment
47
39
  end
48
40
  end
49
41
  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 RootName < Lutaml::Model::Serializable
7
5
  attribute :content, :string
8
6
  attribute :index, :integer
9
7
 
10
8
  xml do
11
- root 'root-name'
12
- namespace 'http://csrc.nist.gov/ns/oscal/metaschema/1.0'
9
+ element "root-name"
10
+ namespace ::Metaschema::Namespace
13
11
 
14
12
  map_content to: :content
15
- map_attribute 'index', to: :index
13
+ map_attribute "index", to: :index
16
14
  end
17
15
  end
18
16
  end