metaschema 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/README.adoc +128 -0
  3. data/Rakefile +12 -0
  4. data/exe/metaschema +7 -0
  5. data/lib/metaschema/allowed_value_type.rb +48 -0
  6. data/lib/metaschema/allowed_values_type.rb +35 -0
  7. data/lib/metaschema/anchor_type.rb +40 -0
  8. data/lib/metaschema/any_type.rb +10 -0
  9. data/lib/metaschema/assembly.rb +42 -0
  10. data/lib/metaschema/assembly_model_type.rb +34 -0
  11. data/lib/metaschema/assembly_reference_type.rb +40 -0
  12. data/lib/metaschema/block_quote_type.rb +47 -0
  13. data/lib/metaschema/choice_type.rb +25 -0
  14. data/lib/metaschema/code_type.rb +45 -0
  15. data/lib/metaschema/constraint_let_type.rb +20 -0
  16. data/lib/metaschema/define_assembly_constraints_type.rb +40 -0
  17. data/lib/metaschema/define_field_constraints_type.rb +31 -0
  18. data/lib/metaschema/define_flag_constraints_type.rb +31 -0
  19. data/lib/metaschema/example_type.rb +23 -0
  20. data/lib/metaschema/expect_constraint_type.rb +32 -0
  21. data/lib/metaschema/field.rb +33 -0
  22. data/lib/metaschema/field_reference_type.rb +44 -0
  23. data/lib/metaschema/flag.rb +33 -0
  24. data/lib/metaschema/flag_reference_type.rb +37 -0
  25. data/lib/metaschema/global_assembly_definition_type.rb +56 -0
  26. data/lib/metaschema/global_field_definition_type.rb +59 -0
  27. data/lib/metaschema/global_flag_definition_type.rb +45 -0
  28. data/lib/metaschema/group_as_type.rb +18 -0
  29. data/lib/metaschema/grouped_assembly_reference_type.rb +33 -0
  30. data/lib/metaschema/grouped_choice_type.rb +37 -0
  31. data/lib/metaschema/grouped_field_reference_type.rb +33 -0
  32. data/lib/metaschema/grouped_inline_assembly_definition_type.rb +50 -0
  33. data/lib/metaschema/grouped_inline_field_definition_type.rb +58 -0
  34. data/lib/metaschema/image_type.rb +18 -0
  35. data/lib/metaschema/import.rb +14 -0
  36. data/lib/metaschema/index_has_key_constraint_type.rb +33 -0
  37. data/lib/metaschema/inline_assembly_definition_type.rb +62 -0
  38. data/lib/metaschema/inline_field_definition_type.rb +65 -0
  39. data/lib/metaschema/inline_flag_definition_type.rb +42 -0
  40. data/lib/metaschema/inline_markup_type.rb +49 -0
  41. data/lib/metaschema/insert_type.rb +16 -0
  42. data/lib/metaschema/json_key_type.rb +14 -0
  43. data/lib/metaschema/json_value_key_flag_type.rb +14 -0
  44. data/lib/metaschema/key_field.rb +20 -0
  45. data/lib/metaschema/list_item_type.rb +75 -0
  46. data/lib/metaschema/list_type.rb +16 -0
  47. data/lib/metaschema/markup_line_datatype.rb +44 -0
  48. data/lib/metaschema/matches_constraint_type.rb +32 -0
  49. data/lib/metaschema/metaschema_import_type.rb +14 -0
  50. data/lib/metaschema/metaschemaconstraints.rb +29 -0
  51. data/lib/metaschema/namespace_binding_type.rb +16 -0
  52. data/lib/metaschema/ordered_list_type.rb +20 -0
  53. data/lib/metaschema/preformatted_type.rb +44 -0
  54. data/lib/metaschema/property_type.rb +18 -0
  55. data/lib/metaschema/remarks_type.rb +50 -0
  56. data/lib/metaschema/root.rb +47 -0
  57. data/lib/metaschema/root_name.rb +16 -0
  58. data/lib/metaschema/scope.rb +26 -0
  59. data/lib/metaschema/table_cell_type.rb +46 -0
  60. data/lib/metaschema/table_row_type.rb +18 -0
  61. data/lib/metaschema/table_type.rb +16 -0
  62. data/lib/metaschema/targeted_allowed_values_constraint_type.rb +37 -0
  63. data/lib/metaschema/targeted_expect_constraint_type.rb +34 -0
  64. data/lib/metaschema/targeted_has_cardinality_constraint_type.rb +34 -0
  65. data/lib/metaschema/targeted_index_constraint_type.rb +35 -0
  66. data/lib/metaschema/targeted_index_has_key_constraint_type.rb +35 -0
  67. data/lib/metaschema/targeted_key_constraint_type.rb +33 -0
  68. data/lib/metaschema/targeted_matches_constraint_type.rb +34 -0
  69. data/lib/metaschema/use_name_type.rb +16 -0
  70. data/lib/metaschema/version.rb +5 -0
  71. data/lib/metaschema.rb +20 -0
  72. data/sig/metaschema.rbs +4 -0
  73. metadata +243 -0
@@ -0,0 +1,47 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "global_assembly_definition_type"
4
+ require_relative "global_field_definition_type"
5
+ require_relative "global_flag_definition_type"
6
+ require_relative "markup_line_datatype"
7
+ require_relative "metaschema_import_type"
8
+ require_relative "namespace_binding_type"
9
+ require_relative "property_type"
10
+ require_relative "remarks_type"
11
+
12
+ module Metaschema
13
+ class Root < Lutaml::Model::Serializable
14
+ attribute :abstract, :string, default: -> { "no" }
15
+ attribute :schema_name, MarkupLineDatatype
16
+ attribute :schema_version, :string
17
+ attribute :short_name, :string
18
+ attribute :namespace, :string
19
+ attribute :json_base_uri, :string
20
+ attribute :prop, PropertyType, collection: true
21
+ attribute :remarks, RemarksType
22
+ attribute :import, MetaschemaImportType, collection: true
23
+ attribute :namespace_binding, NamespaceBindingType, collection: true
24
+ attribute :define_assembly, GlobalAssemblyDefinitionType, collection: true
25
+ attribute :define_field, GlobalFieldDefinitionType, collection: true
26
+ attribute :define_flag, GlobalFlagDefinitionType, collection: true
27
+
28
+ xml do
29
+ root "METASCHEMA"
30
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
31
+
32
+ map_attribute "abstract", to: :abstract
33
+ map_element "schema-name", to: :schema_name
34
+ map_element "schema-version", to: :schema_version
35
+ map_element "short-name", to: :short_name
36
+ map_element "namespace", to: :namespace
37
+ map_element "json-base-uri", to: :json_base_uri
38
+ map_element "prop", to: :prop
39
+ map_element "remarks", to: :remarks
40
+ map_element "import", to: :import
41
+ map_element "namespace-binding", to: :namespace_binding
42
+ map_element "define-assembly", to: :define_assembly
43
+ map_element "define-field", to: :define_field
44
+ map_element "define-flag", to: :define_flag
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,16 @@
1
+ require "lutaml/model"
2
+
3
+ module Metaschema
4
+ class RootName < Lutaml::Model::Serializable
5
+ attribute :content, :string
6
+ attribute :index, :integer
7
+
8
+ xml do
9
+ root "root-name"
10
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
11
+
12
+ map_content to: :content
13
+ map_attribute "index", to: :index
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "assembly"
4
+ require_relative "field"
5
+ require_relative "flag"
6
+
7
+ module Metaschema
8
+ class Scope < Lutaml::Model::Serializable
9
+ attribute :metaschema_namespace, :string
10
+ attribute :metaschema_short_name, :string
11
+ attribute :assembly, Assembly, collection: true
12
+ attribute :field, Field, collection: true
13
+ attribute :flag, Flag, collection: true
14
+
15
+ xml do
16
+ root "scope"
17
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
18
+
19
+ map_attribute "metaschema-namespace", to: :metaschema_namespace
20
+ map_attribute "metaschema-short-name", to: :metaschema_short_name
21
+ map_element "assembly", to: :assembly
22
+ map_element "field", to: :field
23
+ map_element "flag", to: :flag
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,46 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "anchor_type"
4
+ require_relative "code_type"
5
+ require_relative "image_type"
6
+ require_relative "inline_markup_type"
7
+ require_relative "insert_type"
8
+
9
+ module Metaschema
10
+ class TableCellType < Lutaml::Model::Serializable
11
+ attribute :content, :string
12
+ attribute :align, :string, default: -> { "left" }
13
+ attribute :a, AnchorType, collection: true
14
+ attribute :insert, InsertType, collection: true
15
+ attribute :br, :string, collection: true
16
+ attribute :code, CodeType, collection: true
17
+ attribute :em, InlineMarkupType, collection: true
18
+ attribute :i, InlineMarkupType, collection: true
19
+ attribute :b, InlineMarkupType, collection: true
20
+ attribute :strong, InlineMarkupType, collection: true
21
+ attribute :sub, InlineMarkupType, collection: true
22
+ attribute :sup, InlineMarkupType, collection: true
23
+ attribute :q, InlineMarkupType, collection: true
24
+ attribute :img, ImageType, collection: true
25
+
26
+ xml do
27
+ root "tableCellType"
28
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
29
+
30
+ map_content to: :content
31
+ map_attribute "align", to: :align
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
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,18 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "table_cell_type"
4
+
5
+ module Metaschema
6
+ class TableRowType < Lutaml::Model::Serializable
7
+ attribute :td, TableCellType, collection: true
8
+ attribute :th, TableCellType, collection: true
9
+
10
+ xml do
11
+ root "tableRowType"
12
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
13
+
14
+ map_element "td", to: :td
15
+ map_element "th", to: :th
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "table_row_type"
4
+
5
+ module Metaschema
6
+ class TableType < Lutaml::Model::Serializable
7
+ attribute :tr, TableRowType, collection: true
8
+
9
+ xml do
10
+ root "tableType"
11
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
12
+
13
+ map_element "tr", to: :tr
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "allowed_value_type"
4
+ require_relative "markup_line_datatype"
5
+ require_relative "property_type"
6
+ require_relative "remarks_type"
7
+
8
+ module Metaschema
9
+ class TargetedAllowedValuesConstraintType < Lutaml::Model::Serializable
10
+ attribute :id, :string
11
+ attribute :level, :string, default: -> { "ERROR" }
12
+ attribute :allow_other, :string, default: -> { "no" }
13
+ attribute :extensible, :string, default: -> { "external" }
14
+ attribute :target, :string
15
+ attribute :formal_name, :string
16
+ attribute :description, MarkupLineDatatype
17
+ attribute :prop, PropertyType, collection: true
18
+ attribute :enum, AllowedValueType, collection: true
19
+ attribute :remarks, RemarksType
20
+
21
+ xml do
22
+ root "TargetedAllowedValuesConstraintType"
23
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
24
+
25
+ map_attribute "id", to: :id
26
+ map_attribute "level", to: :level
27
+ map_attribute "allow-other", to: :allow_other
28
+ map_attribute "extensible", to: :extensible
29
+ map_attribute "target", to: :target
30
+ map_element "formal-name", to: :formal_name
31
+ map_element "description", to: :description
32
+ map_element "prop", to: :prop
33
+ map_element "enum", to: :enum
34
+ map_element "remarks", to: :remarks
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,34 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "markup_line_datatype"
4
+ require_relative "property_type"
5
+ require_relative "remarks_type"
6
+
7
+ module Metaschema
8
+ class TargetedExpectConstraintType < Lutaml::Model::Serializable
9
+ attribute :id, :string
10
+ attribute :level, :string, default: -> { "ERROR" }
11
+ attribute :test, :string
12
+ attribute :target, :string
13
+ attribute :formal_name, :string
14
+ attribute :description, MarkupLineDatatype
15
+ attribute :prop, PropertyType, collection: true
16
+ attribute :message, :string
17
+ attribute :remarks, RemarksType
18
+
19
+ xml do
20
+ root "TargetedExpectConstraintType"
21
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
22
+
23
+ map_attribute "id", to: :id
24
+ map_attribute "level", to: :level
25
+ map_attribute "test", to: :test
26
+ map_attribute "target", to: :target
27
+ map_element "formal-name", to: :formal_name
28
+ map_element "description", to: :description
29
+ map_element "prop", to: :prop
30
+ map_element "message", to: :message
31
+ map_element "remarks", to: :remarks
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "markup_line_datatype"
4
+ require_relative "property_type"
5
+ require_relative "remarks_type"
6
+
7
+ module Metaschema
8
+ class TargetedHasCardinalityConstraintType < Lutaml::Model::Serializable
9
+ attribute :id, :string
10
+ attribute :level, :string, default: -> { "ERROR" }
11
+ attribute :target, :string
12
+ attribute :min_occurs, :integer
13
+ attribute :max_occurs, :integer
14
+ attribute :formal_name, :string
15
+ attribute :description, MarkupLineDatatype
16
+ attribute :prop, PropertyType, collection: true
17
+ attribute :remarks, RemarksType
18
+
19
+ xml do
20
+ root "TargetedHasCardinalityConstraintType"
21
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
22
+
23
+ map_attribute "id", to: :id
24
+ map_attribute "level", to: :level
25
+ map_attribute "target", to: :target
26
+ map_attribute "min-occurs", to: :min_occurs
27
+ map_attribute "max-occurs", to: :max_occurs
28
+ map_element "formal-name", to: :formal_name
29
+ map_element "description", to: :description
30
+ map_element "prop", to: :prop
31
+ map_element "remarks", to: :remarks
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,35 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "key_field"
4
+ require_relative "markup_line_datatype"
5
+ require_relative "property_type"
6
+ require_relative "remarks_type"
7
+
8
+ module Metaschema
9
+ class TargetedIndexConstraintType < Lutaml::Model::Serializable
10
+ attribute :id, :string
11
+ attribute :level, :string, default: -> { "ERROR" }
12
+ attribute :target, :string
13
+ attribute :name, :string
14
+ attribute :formal_name, :string
15
+ attribute :description, MarkupLineDatatype
16
+ attribute :prop, PropertyType, collection: true
17
+ attribute :key_field, KeyField, collection: true
18
+ attribute :remarks, RemarksType
19
+
20
+ xml do
21
+ root "TargetedIndexConstraintType"
22
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
23
+
24
+ map_attribute "id", to: :id
25
+ map_attribute "level", to: :level
26
+ map_attribute "target", to: :target
27
+ map_attribute "name", to: :name
28
+ map_element "formal-name", to: :formal_name
29
+ map_element "description", to: :description
30
+ map_element "prop", to: :prop
31
+ map_element "key-field", to: :key_field
32
+ map_element "remarks", to: :remarks
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "key_field"
4
+ require_relative "markup_line_datatype"
5
+ require_relative "property_type"
6
+ require_relative "remarks_type"
7
+
8
+ module Metaschema
9
+ class TargetedIndexHasKeyConstraintType < Lutaml::Model::Serializable
10
+ attribute :id, :string
11
+ attribute :level, :string, default: -> { "ERROR" }
12
+ attribute :name, :string
13
+ attribute :target, :string
14
+ attribute :formal_name, :string
15
+ attribute :description, MarkupLineDatatype
16
+ attribute :prop, PropertyType, collection: true
17
+ attribute :key_field, KeyField, collection: true
18
+ attribute :remarks, RemarksType
19
+
20
+ xml do
21
+ root "TargetedIndexHasKeyConstraintType"
22
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
23
+
24
+ map_attribute "id", to: :id
25
+ map_attribute "level", to: :level
26
+ map_attribute "name", to: :name
27
+ map_attribute "target", to: :target
28
+ map_element "formal-name", to: :formal_name
29
+ map_element "description", to: :description
30
+ map_element "prop", to: :prop
31
+ map_element "key-field", to: :key_field
32
+ map_element "remarks", to: :remarks
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "key_field"
4
+ require_relative "markup_line_datatype"
5
+ require_relative "property_type"
6
+ require_relative "remarks_type"
7
+
8
+ module Metaschema
9
+ class TargetedKeyConstraintType < Lutaml::Model::Serializable
10
+ attribute :id, :string
11
+ attribute :level, :string, default: -> { "ERROR" }
12
+ attribute :target, :string
13
+ attribute :formal_name, :string
14
+ attribute :description, MarkupLineDatatype
15
+ attribute :prop, PropertyType, collection: true
16
+ attribute :key_field, KeyField, collection: true
17
+ attribute :remarks, RemarksType
18
+
19
+ xml do
20
+ root "TargetedKeyConstraintType"
21
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
22
+
23
+ map_attribute "id", to: :id
24
+ map_attribute "level", to: :level
25
+ map_attribute "target", to: :target
26
+ map_element "formal-name", to: :formal_name
27
+ map_element "description", to: :description
28
+ map_element "prop", to: :prop
29
+ map_element "key-field", to: :key_field
30
+ map_element "remarks", to: :remarks
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "markup_line_datatype"
4
+ require_relative "property_type"
5
+ require_relative "remarks_type"
6
+
7
+ module Metaschema
8
+ class TargetedMatchesConstraintType < Lutaml::Model::Serializable
9
+ attribute :id, :string
10
+ attribute :level, :string, default: -> { "ERROR" }
11
+ attribute :regex, :string
12
+ attribute :datatype, :string
13
+ attribute :target, :string
14
+ attribute :formal_name, :string
15
+ attribute :description, MarkupLineDatatype
16
+ attribute :prop, PropertyType, collection: true
17
+ attribute :remarks, RemarksType
18
+
19
+ xml do
20
+ root "TargetedMatchesConstraintType"
21
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
22
+
23
+ map_attribute "id", to: :id
24
+ map_attribute "level", to: :level
25
+ map_attribute "regex", to: :regex
26
+ map_attribute "datatype", to: :datatype
27
+ map_attribute "target", to: :target
28
+ map_element "formal-name", to: :formal_name
29
+ map_element "description", to: :description
30
+ map_element "prop", to: :prop
31
+ map_element "remarks", to: :remarks
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,16 @@
1
+ require "lutaml/model"
2
+
3
+ module Metaschema
4
+ class UseNameType < Lutaml::Model::Serializable
5
+ attribute :content, :string
6
+ attribute :index, :integer
7
+
8
+ xml do
9
+ root "UseNameType"
10
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
11
+
12
+ map_content to: :content
13
+ map_attribute "index", to: :index
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metaschema
4
+ VERSION = "0.1.0"
5
+ end
data/lib/metaschema.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ Lutaml::Model::Config.configure do |config|
6
+ require "lutaml/model/xml_adapter/nokogiri_adapter"
7
+ config.xml_adapter = Lutaml::Model::XmlAdapter::NokogiriAdapter
8
+ end
9
+
10
+ require_relative "metaschema/version"
11
+ require_relative "metaschema/root"
12
+
13
+ module Metaschema
14
+ class Error < StandardError; end
15
+
16
+ def self.validate(file_path)
17
+ root = Root.from_file(file_path)
18
+ root.validate_verbose
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ module Metaschema
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end