metaschema 0.1.0

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 (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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 96ded33102abf61d6bebf9eeb5ae94432fa3ef93317d7cc63fefeada76cf3e1b
4
+ data.tar.gz: fb9b812a3407d39927a7fb3d4955c902e3559338a393f0edeed8223212745803
5
+ SHA512:
6
+ metadata.gz: d4e7ea5033073e84c24375688b351f59be2c9b2787968160ab79f71a5c4e46346262710ff5952647529d0927b88d982d8c76ec178bf9e0a5b974e60e218a5405
7
+ data.tar.gz: 6e3b3ee833410b6fa2398e7ada654e0f7ec3d3b1ff87a440d0cdef046b4d3379d28707799c1f0ed644ed6bb0a4ccefcf3a352f5c715c4a99bc14e85b0d9efac3
data/README.adoc ADDED
@@ -0,0 +1,128 @@
1
+ = Metaschema
2
+
3
+ image:https://img.shields.io/gem/v/metaschema.svg["Gem Version", link="https://rubygems.org/gems/metaschema"]
4
+ image:https://github.com/lutaml/metaschema/workflows/rake/badge.svg["Build Status", link="https://github.com/lutaml/metaschema/actions?workflow=rake"]
5
+ image:https://codeclimate.com/github/lutaml/metaschema/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/lutaml/metaschema"]
6
+
7
+ == Purpose
8
+
9
+ This Ruby gem implements a parser and generator for the
10
+ https://pages.nist.gov/metaschema[NIST Metaschema Information Modeling Framework].
11
+
12
+ Metaschema is a specification for defining information models in a structured
13
+ format (currently via XML). It provides a way to define and manage information
14
+ model schemas that can be converted into XML and JSON Schemas.
15
+
16
+ This library can be used to parse and generate information schemas defined in
17
+ the Metaschema XML format.
18
+
19
+ This library can also be used to generate XML schemas and JSON Schemas from
20
+ Metaschema XML files.
21
+
22
+ NOTE: The Metaschema gem is a work in progress and may not yet support all
23
+ features of the Metaschema specification.
24
+
25
+ NOTE: The Metaschema gem will support the generation of data accessors for
26
+ Metaschema-defined information models in the future.
27
+
28
+
29
+ == Features
30
+
31
+ TODO: This list is a TODO list. None of them have been completed.
32
+
33
+ . Parse, build and round-trip Metaschema XML files
34
+ . Validate Metaschema XML files against the Metaschema XML Schema
35
+ . Generate XML (XSD) and JSON Schemas from Metaschema XML files
36
+ . Generate Lutaml::Model (Ruby) classes that allow access and manipulation of
37
+ Metaschema-defined information models.
38
+ . Validate Metaschema-defined information models against the Metaschema XML
39
+ Schema
40
+
41
+ == Installation
42
+
43
+ To install the metaschema gem, use one of the following methods.
44
+
45
+ Add this line to your application's Gemfile:
46
+
47
+ [source,ruby]
48
+ ----
49
+ gem 'metaschema'
50
+ ----
51
+
52
+ Then execute:
53
+
54
+ [source,sh]
55
+ ----
56
+ $ bundle install
57
+ ----
58
+
59
+ Or install it directly using:
60
+
61
+ [source,sh]
62
+ ----
63
+ $ gem install metaschema
64
+ ----
65
+
66
+ After installation, you can start using the metaschema gem in your Ruby projects
67
+ or via the command-line interface.
68
+
69
+
70
+ == Ruby API
71
+
72
+ [source,ruby]
73
+ ----
74
+ require 'metaschema'
75
+
76
+ # Load a Metaschema file
77
+ # Sample at spec/fixtures/metaschema/examples/computer-example.xml
78
+ ms = Metaschema::Root.from_file("computer-example.xml")
79
+
80
+ ms.to_xml
81
+ # <METASCHEMA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
82
+ # xsi:schemaLocation="http://csrc.nist.gov/ns/oscal/metaschema/1.0 ../schema/xml/metaschema.xsd"
83
+ # xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0">
84
+ # <schema-name>Computer Model</schema-name>
85
+ # <schema-version>0.0.5</schema-version>
86
+
87
+ ms.schema_name
88
+ # "Computer Model"
89
+
90
+ ms.schema_version
91
+ # "0.0.5"
92
+
93
+ ms.assemblies
94
+ # [Vendor, Computer, ...]
95
+ ----
96
+
97
+
98
+ == Tests
99
+
100
+ The `spec/fixtures` folder contains tests that the Metaschema gem needs to
101
+ comply with.
102
+
103
+ Including:
104
+
105
+ `spec/fixtures/metaschema`:: the submoduled repository from the
106
+ https://github.com/usnistgov/metaschema[Metaschema project]
107
+
108
+ `spec/fixtures/metaschema/examples`:: examples of Metaschema XML files
109
+ (for us to test round-tripping)
110
+
111
+ `spec/fixtures/metaschema/test-suite`:: the test suite for the Metaschema
112
+ project. TODO: This library is to be tested against these files.
113
+
114
+ `spec/fixtures/metaschema/test-suite/schema-generation`:: these files test
115
+ against individual features of Metaschema. TODO: This library needs to run RSpecs
116
+ against every directory here each representing a separate feature.
117
+
118
+ `spec/fixtures/metaschema/test-suite/worked-examples`:: these files are complete
119
+ Metaschema XML examples that exercises all features of Metaschema. TODO: This
120
+ library needs to run RSpecs against each of these files.
121
+
122
+
123
+
124
+ == License
125
+
126
+ Copyright Ribose.
127
+
128
+ BSD-3 license.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/metaschema ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../lib/metaschema"
5
+ require_relative "../lib/metaschema/cli"
6
+
7
+ Metaschema::Cli::Commands.start(ARGV)
@@ -0,0 +1,48 @@
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 AllowedValueType < Lutaml::Model::Serializable
11
+ attribute :content, :string
12
+ attribute :value, :string
13
+ attribute :deprecated, :string
14
+ attribute :a, AnchorType, collection: true
15
+ attribute :insert, InsertType, collection: true
16
+ attribute :br, :string, collection: true
17
+ attribute :code, CodeType, collection: true
18
+ attribute :em, InlineMarkupType, collection: true
19
+ attribute :i, InlineMarkupType, collection: true
20
+ attribute :b, InlineMarkupType, collection: true
21
+ attribute :strong, InlineMarkupType, collection: true
22
+ attribute :sub, InlineMarkupType, collection: true
23
+ attribute :sup, InlineMarkupType, collection: true
24
+ attribute :q, InlineMarkupType, collection: true
25
+ attribute :img, ImageType, collection: true
26
+
27
+ xml do
28
+ root "AllowedValueType"
29
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
30
+
31
+ map_content to: :content
32
+ map_attribute "value", to: :value
33
+ map_attribute "deprecated", to: :deprecated
34
+ map_element "a", to: :a
35
+ map_element "insert", to: :insert
36
+ map_element "br", to: :br
37
+ map_element "code", to: :code
38
+ map_element "em", to: :em
39
+ map_element "i", to: :i
40
+ map_element "b", to: :b
41
+ map_element "strong", to: :strong
42
+ map_element "sub", to: :sub
43
+ map_element "sup", to: :sup
44
+ map_element "q", to: :q
45
+ map_element "img", to: :img
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,35 @@
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 AllowedValuesType < 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 :formal_name, :string
15
+ attribute :description, MarkupLineDatatype
16
+ attribute :prop, PropertyType, collection: true
17
+ attribute :enum, AllowedValueType, collection: true
18
+ attribute :remarks, RemarksType
19
+
20
+ xml do
21
+ root "AllowedValuesType"
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 "allow-other", to: :allow_other
27
+ map_attribute "extensible", to: :extensible
28
+ map_element "formal-name", to: :formal_name
29
+ map_element "description", to: :description
30
+ map_element "prop", to: :prop
31
+ map_element "enum", to: :enum
32
+ map_element "remarks", to: :remarks
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,40 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "code_type"
4
+ require_relative "image_type"
5
+ require_relative "inline_markup_type"
6
+
7
+ module Metaschema
8
+ class AnchorType < Lutaml::Model::Serializable
9
+ attribute :content, :string
10
+ attribute :href, :string
11
+ attribute :title, :string
12
+ attribute :code, CodeType, collection: true
13
+ attribute :em, InlineMarkupType, collection: true
14
+ attribute :i, InlineMarkupType, collection: true
15
+ attribute :b, InlineMarkupType, collection: true
16
+ attribute :strong, InlineMarkupType, collection: true
17
+ attribute :sub, InlineMarkupType, collection: true
18
+ attribute :sup, InlineMarkupType, collection: true
19
+ attribute :q, InlineMarkupType, collection: true
20
+ attribute :img, ImageType, collection: true
21
+
22
+ xml do
23
+ root "anchorType"
24
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
25
+
26
+ map_content to: :content
27
+ map_attribute "href", to: :href
28
+ map_attribute "title", to: :title
29
+ map_element "code", to: :code
30
+ map_element "em", to: :em
31
+ map_element "i", to: :i
32
+ map_element "b", to: :b
33
+ map_element "strong", to: :strong
34
+ map_element "sub", to: :sub
35
+ map_element "sup", to: :sup
36
+ map_element "q", to: :q
37
+ map_element "img", to: :img
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,10 @@
1
+ require "lutaml/model"
2
+
3
+ module Metaschema
4
+ class AnyType < Lutaml::Model::Serializable
5
+ xml do
6
+ root "AnyType"
7
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,42 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "constraint_let_type"
4
+ require_relative "remarks_type"
5
+ require_relative "targeted_allowed_values_constraint_type"
6
+ require_relative "targeted_expect_constraint_type"
7
+ require_relative "targeted_has_cardinality_constraint_type"
8
+ require_relative "targeted_index_constraint_type"
9
+ require_relative "targeted_index_has_key_constraint_type"
10
+ require_relative "targeted_key_constraint_type"
11
+ require_relative "targeted_matches_constraint_type"
12
+
13
+ module Metaschema
14
+ class Assembly < Lutaml::Model::Serializable
15
+ attribute :target, :string
16
+ attribute :let, ConstraintLetType, collection: true
17
+ attribute :allowed_values, TargetedAllowedValuesConstraintType, collection: true
18
+ attribute :matches, TargetedMatchesConstraintType, collection: true
19
+ attribute :index_has_key, TargetedIndexHasKeyConstraintType, collection: true
20
+ attribute :expect, TargetedExpectConstraintType, collection: true
21
+ attribute :index, TargetedIndexConstraintType, collection: true
22
+ attribute :is_unique, TargetedKeyConstraintType, collection: true
23
+ attribute :has_cardinality, TargetedHasCardinalityConstraintType, collection: true
24
+ attribute :remarks, RemarksType
25
+
26
+ xml do
27
+ root "assembly"
28
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
29
+
30
+ map_attribute "target", to: :target
31
+ map_element "let", to: :let
32
+ map_element "allowed-values", to: :allowed_values
33
+ map_element "matches", to: :matches
34
+ map_element "index-has-key", to: :index_has_key
35
+ map_element "expect", to: :expect
36
+ map_element "index", to: :index
37
+ map_element "is-unique", to: :is_unique
38
+ map_element "has-cardinality", to: :has_cardinality
39
+ map_element "remarks", to: :remarks
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,34 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "any_type"
4
+ require_relative "assembly_reference_type"
5
+ require_relative "choice_type"
6
+ require_relative "field_reference_type"
7
+ require_relative "grouped_choice_type"
8
+ require_relative "inline_assembly_definition_type"
9
+ require_relative "inline_field_definition_type"
10
+
11
+ module Metaschema
12
+ class AssemblyModelType < Lutaml::Model::Serializable
13
+ attribute :assembly, AssemblyReferenceType, collection: true
14
+ attribute :field, FieldReferenceType, collection: true
15
+ attribute :define_assembly, InlineAssemblyDefinitionType, collection: true
16
+ attribute :define_field, InlineFieldDefinitionType, collection: true
17
+ attribute :choice, ChoiceType, collection: true
18
+ attribute :choice_group, GroupedChoiceType, collection: true
19
+ attribute :any, AnyType
20
+
21
+ xml do
22
+ root "AssemblyModelType"
23
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
24
+
25
+ map_element "assembly", to: :assembly
26
+ map_element "field", to: :field
27
+ map_element "define-assembly", to: :define_assembly
28
+ map_element "define-field", to: :define_field
29
+ map_element "choice", to: :choice
30
+ map_element "choice-group", to: :choice_group
31
+ map_element "any", to: :any
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,40 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "group_as_type"
4
+ require_relative "markup_line_datatype"
5
+ require_relative "property_type"
6
+ require_relative "remarks_type"
7
+ require_relative "use_name_type"
8
+
9
+ module Metaschema
10
+ class AssemblyReferenceType < Lutaml::Model::Serializable
11
+ attribute :ref, :string
12
+ attribute :index, :integer
13
+ attribute :min_occurs, :integer, default: -> { "0" }
14
+ attribute :max_occurs, :string, default: -> { "1" }
15
+ attribute :deprecated, :string
16
+ attribute :formal_name, :string
17
+ attribute :description, MarkupLineDatatype
18
+ attribute :prop, PropertyType, collection: true
19
+ attribute :use_name, UseNameType
20
+ attribute :group_as, GroupAsType
21
+ attribute :remarks, RemarksType
22
+
23
+ xml do
24
+ root "AssemblyReferenceType"
25
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
26
+
27
+ map_attribute "ref", to: :ref
28
+ map_attribute "index", to: :index
29
+ map_attribute "min-occurs", to: :min_occurs
30
+ map_attribute "max-occurs", to: :max_occurs
31
+ map_attribute "deprecated", to: :deprecated
32
+ map_element "formal-name", to: :formal_name
33
+ map_element "description", to: :description
34
+ map_element "prop", to: :prop
35
+ map_element "use-name", to: :use_name
36
+ map_element "group-as", to: :group_as
37
+ map_element "remarks", to: :remarks
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,47 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "image_type"
4
+ require_relative "inline_markup_type"
5
+ require_relative "list_type"
6
+ require_relative "ordered_list_type"
7
+ require_relative "preformatted_type"
8
+ require_relative "table_type"
9
+
10
+ module Metaschema
11
+ class BlockQuoteType < Lutaml::Model::Serializable
12
+ attribute :h1, InlineMarkupType, collection: true
13
+ attribute :h2, InlineMarkupType, collection: true
14
+ attribute :h3, InlineMarkupType, collection: true
15
+ attribute :h4, InlineMarkupType, collection: true
16
+ attribute :h5, InlineMarkupType, collection: true
17
+ attribute :h6, InlineMarkupType, collection: true
18
+ attribute :ul, ListType, collection: true
19
+ attribute :ol, OrderedListType, collection: true
20
+ attribute :pre, PreformattedType, collection: true
21
+ attribute :hr, :string, collection: true
22
+ attribute :blockquote, BlockQuoteType, collection: true
23
+ attribute :p, InlineMarkupType, collection: true
24
+ attribute :table, TableType, collection: true
25
+ attribute :img, ImageType, collection: true
26
+
27
+ xml do
28
+ root "blockQuoteType"
29
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
30
+
31
+ map_element "h1", to: :h1
32
+ map_element "h2", to: :h2
33
+ map_element "h3", to: :h3
34
+ map_element "h4", to: :h4
35
+ map_element "h5", to: :h5
36
+ map_element "h6", to: :h6
37
+ map_element "ul", to: :ul
38
+ map_element "ol", to: :ol
39
+ map_element "pre", to: :pre
40
+ map_element "hr", to: :hr
41
+ map_element "blockquote", to: :blockquote
42
+ map_element "p", to: :p
43
+ map_element "table", to: :table
44
+ map_element "img", to: :img
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,25 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "assembly_reference_type"
4
+ require_relative "field_reference_type"
5
+ require_relative "inline_assembly_definition_type"
6
+ require_relative "inline_field_definition_type"
7
+
8
+ module Metaschema
9
+ class ChoiceType < Lutaml::Model::Serializable
10
+ attribute :assembly, AssemblyReferenceType, collection: true
11
+ attribute :field, FieldReferenceType, collection: true
12
+ attribute :define_assembly, InlineAssemblyDefinitionType, collection: true
13
+ attribute :define_field, InlineFieldDefinitionType, collection: true
14
+
15
+ xml do
16
+ root "ChoiceType"
17
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
18
+
19
+ map_element "assembly", to: :assembly
20
+ map_element "field", to: :field
21
+ map_element "define-assembly", to: :define_assembly
22
+ map_element "define-field", to: :define_field
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,45 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "anchor_type"
4
+ require_relative "image_type"
5
+ require_relative "inline_markup_type"
6
+ require_relative "insert_type"
7
+
8
+ module Metaschema
9
+ class CodeType < Lutaml::Model::Serializable
10
+ attribute :content, :string
11
+ attribute :class, :string
12
+ attribute :a, AnchorType, collection: true
13
+ attribute :insert, InsertType, collection: true
14
+ attribute :br, :string, collection: true
15
+ attribute :code, CodeType, collection: true
16
+ attribute :em, InlineMarkupType, collection: true
17
+ attribute :i, InlineMarkupType, collection: true
18
+ attribute :b, InlineMarkupType, collection: true
19
+ attribute :strong, InlineMarkupType, collection: true
20
+ attribute :sub, InlineMarkupType, collection: true
21
+ attribute :sup, InlineMarkupType, collection: true
22
+ attribute :q, InlineMarkupType, collection: true
23
+ attribute :img, ImageType, collection: true
24
+
25
+ xml do
26
+ root "codeType"
27
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
28
+
29
+ map_content to: :content
30
+ map_attribute "class", to: :class
31
+ map_element "a", to: :a
32
+ map_element "insert", to: :insert
33
+ map_element "br", to: :br
34
+ map_element "code", to: :code
35
+ map_element "em", to: :em
36
+ map_element "i", to: :i
37
+ map_element "b", to: :b
38
+ map_element "strong", to: :strong
39
+ map_element "sub", to: :sub
40
+ map_element "sup", to: :sup
41
+ map_element "q", to: :q
42
+ map_element "img", to: :img
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,20 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "remarks_type"
4
+
5
+ module Metaschema
6
+ class ConstraintLetType < Lutaml::Model::Serializable
7
+ attribute :var, :string
8
+ attribute :expression, :string
9
+ attribute :remarks, RemarksType
10
+
11
+ xml do
12
+ root "ConstraintLetType"
13
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
14
+
15
+ map_attribute "var", to: :var
16
+ map_attribute "expression", to: :expression
17
+ map_element "remarks", to: :remarks
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,40 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "constraint_let_type"
4
+ require_relative "remarks_type"
5
+ require_relative "targeted_allowed_values_constraint_type"
6
+ require_relative "targeted_expect_constraint_type"
7
+ require_relative "targeted_has_cardinality_constraint_type"
8
+ require_relative "targeted_index_constraint_type"
9
+ require_relative "targeted_index_has_key_constraint_type"
10
+ require_relative "targeted_key_constraint_type"
11
+ require_relative "targeted_matches_constraint_type"
12
+
13
+ module Metaschema
14
+ class DefineAssemblyConstraintsType < Lutaml::Model::Serializable
15
+ attribute :let, ConstraintLetType, collection: true
16
+ attribute :allowed_values, TargetedAllowedValuesConstraintType, collection: true
17
+ attribute :matches, TargetedMatchesConstraintType, collection: true
18
+ attribute :index_has_key, TargetedIndexHasKeyConstraintType, collection: true
19
+ attribute :expect, TargetedExpectConstraintType, collection: true
20
+ attribute :index, TargetedIndexConstraintType, collection: true
21
+ attribute :is_unique, TargetedKeyConstraintType, collection: true
22
+ attribute :has_cardinality, TargetedHasCardinalityConstraintType, collection: true
23
+ attribute :remarks, RemarksType
24
+
25
+ xml do
26
+ root "DefineAssemblyConstraintsType"
27
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
28
+
29
+ map_element "let", to: :let
30
+ map_element "allowed-values", to: :allowed_values
31
+ map_element "matches", to: :matches
32
+ map_element "index-has-key", to: :index_has_key
33
+ map_element "expect", to: :expect
34
+ map_element "index", to: :index
35
+ map_element "is-unique", to: :is_unique
36
+ map_element "has-cardinality", to: :has_cardinality
37
+ map_element "remarks", to: :remarks
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,31 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "constraint_let_type"
4
+ require_relative "remarks_type"
5
+ require_relative "targeted_allowed_values_constraint_type"
6
+ require_relative "targeted_expect_constraint_type"
7
+ require_relative "targeted_index_has_key_constraint_type"
8
+ require_relative "targeted_matches_constraint_type"
9
+
10
+ module Metaschema
11
+ class DefineFieldConstraintsType < Lutaml::Model::Serializable
12
+ attribute :let, ConstraintLetType, collection: true
13
+ attribute :allowed_values, TargetedAllowedValuesConstraintType, collection: true
14
+ attribute :matches, TargetedMatchesConstraintType, collection: true
15
+ attribute :index_has_key, TargetedIndexHasKeyConstraintType, collection: true
16
+ attribute :expect, TargetedExpectConstraintType, collection: true
17
+ attribute :remarks, RemarksType
18
+
19
+ xml do
20
+ root "DefineFieldConstraintsType"
21
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
22
+
23
+ map_element "let", to: :let
24
+ map_element "allowed-values", to: :allowed_values
25
+ map_element "matches", to: :matches
26
+ map_element "index-has-key", to: :index_has_key
27
+ map_element "expect", to: :expect
28
+ map_element "remarks", to: :remarks
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ require "lutaml/model"
2
+
3
+ require_relative "allowed_values_type"
4
+ require_relative "constraint_let_type"
5
+ require_relative "expect_constraint_type"
6
+ require_relative "index_has_key_constraint_type"
7
+ require_relative "matches_constraint_type"
8
+ require_relative "remarks_type"
9
+
10
+ module Metaschema
11
+ class DefineFlagConstraintsType < Lutaml::Model::Serializable
12
+ attribute :let, ConstraintLetType, collection: true
13
+ attribute :allowed_values, AllowedValuesType, collection: true
14
+ attribute :matches, MatchesConstraintType, collection: true
15
+ attribute :index_has_key, IndexHasKeyConstraintType, collection: true
16
+ attribute :expect, ExpectConstraintType, collection: true
17
+ attribute :remarks, RemarksType
18
+
19
+ xml do
20
+ root "DefineFlagConstraintsType"
21
+ namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
22
+
23
+ map_element "let", to: :let
24
+ map_element "allowed-values", to: :allowed_values
25
+ map_element "matches", to: :matches
26
+ map_element "index-has-key", to: :index_has_key
27
+ map_element "expect", to: :expect
28
+ map_element "remarks", to: :remarks
29
+ end
30
+ end
31
+ end