reqif 0.1.0 → 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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +7 -4
  3. data/.rubocop.yml +17 -6
  4. data/.rubocop_todo.yml +63 -0
  5. data/CLAUDE.md +73 -0
  6. data/Gemfile +6 -2
  7. data/README.adoc +61 -1
  8. data/lib/reqif/alternative_id.rb +2 -2
  9. data/lib/reqif/attribute_definition_boolean.rb +5 -4
  10. data/lib/reqif/attribute_definition_date.rb +5 -4
  11. data/lib/reqif/attribute_definition_enumeration.rb +5 -4
  12. data/lib/reqif/attribute_definition_integer.rb +5 -4
  13. data/lib/reqif/attribute_definition_real.rb +5 -4
  14. data/lib/reqif/attribute_definition_string.rb +5 -4
  15. data/lib/reqif/attribute_definition_xhtml.rb +5 -4
  16. data/lib/reqif/attribute_value_boolean.rb +3 -2
  17. data/lib/reqif/attribute_value_date.rb +4 -3
  18. data/lib/reqif/attribute_value_enumeration.rb +3 -2
  19. data/lib/reqif/attribute_value_integer.rb +4 -3
  20. data/lib/reqif/attribute_value_real.rb +4 -3
  21. data/lib/reqif/attribute_value_string.rb +3 -2
  22. data/lib/reqif/attribute_value_xhtml.rb +3 -2
  23. data/lib/reqif/children.rb +3 -2
  24. data/lib/reqif/core_content.rb +3 -2
  25. data/lib/reqif/datatype_definition_boolean.rb +5 -4
  26. data/lib/reqif/datatype_definition_date.rb +5 -4
  27. data/lib/reqif/datatype_definition_enumeration.rb +5 -4
  28. data/lib/reqif/datatype_definition_integer.rb +7 -6
  29. data/lib/reqif/datatype_definition_real.rb +7 -6
  30. data/lib/reqif/datatype_definition_string.rb +5 -4
  31. data/lib/reqif/datatype_definition_xhtml.rb +5 -4
  32. data/lib/reqif/datatypes.rb +23 -12
  33. data/lib/reqif/default_value.rb +4 -3
  34. data/lib/reqif/definition.rb +24 -16
  35. data/lib/reqif/doors/identifier.rb +15 -0
  36. data/lib/reqif/doors/module_definition.rb +23 -0
  37. data/lib/reqif/doors/namespace.rb +10 -0
  38. data/lib/reqif/doors/readonly_attributes.rb +48 -0
  39. data/lib/reqif/doors/rif_definition.rb +26 -0
  40. data/lib/reqif/doors/string_type.rb +12 -0
  41. data/lib/reqif/doors.rb +12 -0
  42. data/lib/reqif/editable_atts.rb +24 -16
  43. data/lib/reqif/embedded_value.rb +4 -3
  44. data/lib/reqif/enum_value.rb +4 -4
  45. data/lib/reqif/high_precision_date_time.rb +52 -0
  46. data/lib/reqif/namespace.rb +16 -0
  47. data/lib/reqif/object.rb +3 -3
  48. data/lib/reqif/properties.rb +2 -2
  49. data/lib/reqif/relation_group.rb +5 -4
  50. data/lib/reqif/relation_group_type.rb +5 -4
  51. data/lib/reqif/req_if.rb +7 -2
  52. data/lib/reqif/req_if_content.rb +3 -2
  53. data/lib/reqif/req_if_header.rb +4 -5
  54. data/lib/reqif/req_if_tool_extension.rb +48 -2
  55. data/lib/reqif/reqif_float.rb +98 -0
  56. data/lib/reqif/reqif_integer.rb +36 -0
  57. data/lib/reqif/source.rb +3 -3
  58. data/lib/reqif/source_specification.rb +3 -3
  59. data/lib/reqif/spec_attributes.rb +25 -13
  60. data/lib/reqif/spec_hierarchy.rb +5 -4
  61. data/lib/reqif/spec_object.rb +5 -4
  62. data/lib/reqif/spec_object_type.rb +5 -4
  63. data/lib/reqif/spec_objects.rb +3 -2
  64. data/lib/reqif/spec_relation.rb +5 -4
  65. data/lib/reqif/spec_relation_groups.rb +2 -2
  66. data/lib/reqif/spec_relation_type.rb +5 -4
  67. data/lib/reqif/spec_relations.rb +3 -3
  68. data/lib/reqif/spec_types.rb +3 -2
  69. data/lib/reqif/specification.rb +5 -4
  70. data/lib/reqif/specification_type.rb +5 -4
  71. data/lib/reqif/specifications.rb +3 -2
  72. data/lib/reqif/specified_values.rb +2 -2
  73. data/lib/reqif/string_type.rb +7 -0
  74. data/lib/reqif/target.rb +3 -3
  75. data/lib/reqif/target_specification.rb +3 -3
  76. data/lib/reqif/the_header.rb +3 -2
  77. data/lib/reqif/tool_extensions.rb +2 -2
  78. data/lib/reqif/type.rb +28 -20
  79. data/lib/reqif/values.rb +8 -5
  80. data/lib/reqif/version.rb +1 -1
  81. data/lib/reqif/xhtml/div.rb +18 -0
  82. data/lib/reqif/xhtml/namespace.rb +10 -0
  83. data/lib/reqif/xhtml/p.rb +18 -0
  84. data/lib/reqif/xhtml/span.rb +18 -0
  85. data/lib/reqif/xhtml.rb +12 -0
  86. data/lib/reqif/xhtml_content.rb +181 -2
  87. data/lib/reqif.rb +70 -14
  88. data/references/driver.xsd +270 -270
  89. data/references/reqif.xsd +892 -892
  90. data/reqif.gemspec +4 -3
  91. data/spec/fixtures/antcc_MAG8000-LTE-FeatureSpecReqBL4.reqif +4299 -0
  92. data/spec/fixtures/ea_example.reqif.xml +236 -0
  93. data/spec/fixtures/eclipse_capella_Sample.xml +177 -0
  94. data/spec/fixtures/eclipse_capella_Sample1.xml +239 -0
  95. data/spec/fixtures/eclipse_capella_Sample2.xml +239 -0
  96. data/spec/fixtures/eclipse_capella_Sample3.xml +304 -0
  97. data/spec/fixtures/eclipse_capella_model1.xml +4080 -0
  98. data/spec/fixtures/eclipse_rmf_sample.reqif +96 -0
  99. data/spec/fixtures/eclipse_rmf_specRelationTest.reqif +110 -0
  100. data/spec/fixtures/polarion_export.xml +70 -0
  101. data/spec/fixtures/strictdoc_01_minimal_reqif_sample.reqif +4 -0
  102. data/spec/fixtures/strictdoc_02_read_reqif_input.reqif +3996 -0
  103. data/spec/fixtures/strictdoc_04_convert_reqif_to_json_sample1_polarion.reqif +197 -0
  104. data/spec/fixtures/strictdoc_04_convert_reqif_to_json_sample2_sdoc.reqif +451 -0
  105. data/spec/fixtures/strictdoc_04_convert_reqif_to_json_sample3_eclipse_rmf.reqif +334 -0
  106. data/spec/fixtures/strictdoc_04_convert_reqif_to_json_sample_polarion_reqifz.reqifz +0 -0
  107. data/spec/reqif/data_types_spec.rb +29 -0
  108. data/spec/reqif/polarion_export_spec.rb +22 -0
  109. data/spec/reqif/req_if_header_spec.rb +31 -0
  110. data/spec/reqif/req_if_spec.rb +43 -0
  111. data/spec/reqif/spec_objects_spec.rb +35 -0
  112. data/spec/reqif/spec_relations_spec.rb +33 -0
  113. data/spec/reqif/spec_types_spec.rb +40 -0
  114. data/spec/reqif/specifications_spec.rb +35 -0
  115. data/spec/reqif/tool_extension_spec.rb +27 -0
  116. data/spec/reqif_spec.rb +56 -0
  117. data/spec/spec_helper.rb +70 -0
  118. metadata +58 -11
@@ -4,16 +4,17 @@ module Reqif
4
4
  class DatatypeDefinitionEnumeration < Lutaml::Model::Serializable
5
5
  attribute :desc, :string
6
6
  attribute :identifier, :string
7
- attribute :last_change, :time
7
+ attribute :last_change, HighPrecisionDateTime
8
8
  attribute :long_name, :string
9
9
  attribute :alternative_id, AlternativeId
10
10
  attribute :specified_values, SpecifiedValues
11
11
 
12
12
  xml do
13
- root "DATATYPE-DEFINITION-ENUMERATION"
14
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
13
+ element "DATATYPE-DEFINITION-ENUMERATION"
14
+ namespace Namespace
15
+ ordered
15
16
 
16
- map_attribute "DESC", to: :desc
17
+ map_attribute "DESC", to: :desc, render_empty: true
17
18
  map_attribute "IDENTIFIER", to: :identifier
18
19
  map_attribute "LAST-CHANGE", to: :last_change
19
20
  map_attribute "LONG-NAME", to: :long_name
@@ -4,17 +4,18 @@ module Reqif
4
4
  class DatatypeDefinitionInteger < Lutaml::Model::Serializable
5
5
  attribute :desc, :string
6
6
  attribute :identifier, :string
7
- attribute :last_change, :time
7
+ attribute :last_change, HighPrecisionDateTime
8
8
  attribute :long_name, :string
9
- attribute :max, :integer
10
- attribute :min, :integer
9
+ attribute :max, ReqifInteger
10
+ attribute :min, ReqifInteger
11
11
  attribute :alternative_id, AlternativeId
12
12
 
13
13
  xml do
14
- root "DATATYPE-DEFINITION-INTEGER"
15
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
14
+ element "DATATYPE-DEFINITION-INTEGER"
15
+ namespace Namespace
16
+ ordered
16
17
 
17
- map_attribute "DESC", to: :desc
18
+ map_attribute "DESC", to: :desc, render_empty: true
18
19
  map_attribute "IDENTIFIER", to: :identifier
19
20
  map_attribute "LAST-CHANGE", to: :last_change
20
21
  map_attribute "LONG-NAME", to: :long_name
@@ -5,18 +5,19 @@ module Reqif
5
5
  attribute :accuracy, :integer
6
6
  attribute :desc, :string
7
7
  attribute :identifier, :string
8
- attribute :last_change, :time
8
+ attribute :last_change, HighPrecisionDateTime
9
9
  attribute :long_name, :string
10
- attribute :max, :float
11
- attribute :min, :float
10
+ attribute :max, ReqifFloat
11
+ attribute :min, ReqifFloat
12
12
  attribute :alternative_id, AlternativeId
13
13
 
14
14
  xml do
15
- root "DATATYPE-DEFINITION-REAL"
16
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
15
+ element "DATATYPE-DEFINITION-REAL"
16
+ namespace Namespace
17
+ ordered
17
18
 
18
19
  map_attribute "ACCURACY", to: :accuracy
19
- map_attribute "DESC", to: :desc
20
+ map_attribute "DESC", to: :desc, render_empty: true
20
21
  map_attribute "IDENTIFIER", to: :identifier
21
22
  map_attribute "LAST-CHANGE", to: :last_change
22
23
  map_attribute "LONG-NAME", to: :long_name
@@ -4,16 +4,17 @@ module Reqif
4
4
  class DatatypeDefinitionString < Lutaml::Model::Serializable
5
5
  attribute :desc, :string
6
6
  attribute :identifier, :string
7
- attribute :last_change, :time
7
+ attribute :last_change, HighPrecisionDateTime
8
8
  attribute :long_name, :string
9
9
  attribute :max_length, :integer
10
10
  attribute :alternative_id, AlternativeId
11
11
 
12
12
  xml do
13
- root "DATATYPE-DEFINITION-STRING"
14
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
13
+ element "DATATYPE-DEFINITION-STRING"
14
+ namespace Namespace
15
+ ordered
15
16
 
16
- map_attribute "DESC", to: :desc
17
+ map_attribute "DESC", to: :desc, render_empty: true
17
18
  map_attribute "IDENTIFIER", to: :identifier
18
19
  map_attribute "LAST-CHANGE", to: :last_change
19
20
  map_attribute "LONG-NAME", to: :long_name
@@ -4,15 +4,16 @@ module Reqif
4
4
  class DatatypeDefinitionXhtml < Lutaml::Model::Serializable
5
5
  attribute :desc, :string
6
6
  attribute :identifier, :string
7
- attribute :last_change, :time
7
+ attribute :last_change, HighPrecisionDateTime
8
8
  attribute :long_name, :string
9
9
  attribute :alternative_id, AlternativeId
10
10
 
11
11
  xml do
12
- root "DATATYPE-DEFINITION-XHTML"
13
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
12
+ element "DATATYPE-DEFINITION-XHTML"
13
+ namespace Namespace
14
+ ordered
14
15
 
15
- map_attribute "DESC", to: :desc
16
+ map_attribute "DESC", to: :desc, render_empty: true
16
17
  map_attribute "IDENTIFIER", to: :identifier
17
18
  map_attribute "LAST-CHANGE", to: :last_change
18
19
  map_attribute "LONG-NAME", to: :long_name
@@ -2,22 +2,33 @@ require "lutaml/model"
2
2
 
3
3
  module Reqif
4
4
  class Datatypes < Lutaml::Model::Serializable
5
- attribute :datatype_definition_boolean, DatatypeDefinitionBoolean, collection: true
6
- attribute :datatype_definition_date, DatatypeDefinitionDate, collection: true
7
- attribute :datatype_definition_enumeration, DatatypeDefinitionEnumeration, collection: true
8
- attribute :datatype_definition_integer, DatatypeDefinitionInteger, collection: true
9
- attribute :datatype_definition_real, DatatypeDefinitionReal, collection: true
10
- attribute :datatype_definition_string, DatatypeDefinitionString, collection: true
11
- attribute :datatype_definition_xhtml, DatatypeDefinitionXhtml, collection: true
5
+ attribute :datatype_definition_boolean, DatatypeDefinitionBoolean,
6
+ collection: true
7
+ attribute :datatype_definition_date, DatatypeDefinitionDate,
8
+ collection: true
9
+ attribute :datatype_definition_enumeration, DatatypeDefinitionEnumeration,
10
+ collection: true
11
+ attribute :datatype_definition_integer, DatatypeDefinitionInteger,
12
+ collection: true
13
+ attribute :datatype_definition_real, DatatypeDefinitionReal,
14
+ collection: true
15
+ attribute :datatype_definition_string, DatatypeDefinitionString,
16
+ collection: true
17
+ attribute :datatype_definition_xhtml, DatatypeDefinitionXhtml,
18
+ collection: true
12
19
 
13
20
  xml do
14
- root "DATATYPES"
15
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
21
+ element "DATATYPES"
22
+ namespace Namespace
23
+ ordered
16
24
 
17
- map_element "DATATYPE-DEFINITION-BOOLEAN", to: :datatype_definition_boolean
25
+ map_element "DATATYPE-DEFINITION-BOOLEAN",
26
+ to: :datatype_definition_boolean
18
27
  map_element "DATATYPE-DEFINITION-DATE", to: :datatype_definition_date
19
- map_element "DATATYPE-DEFINITION-ENUMERATION", to: :datatype_definition_enumeration
20
- map_element "DATATYPE-DEFINITION-INTEGER", to: :datatype_definition_integer
28
+ map_element "DATATYPE-DEFINITION-ENUMERATION",
29
+ to: :datatype_definition_enumeration
30
+ map_element "DATATYPE-DEFINITION-INTEGER",
31
+ to: :datatype_definition_integer
21
32
  map_element "DATATYPE-DEFINITION-REAL", to: :datatype_definition_real
22
33
  map_element "DATATYPE-DEFINITION-STRING", to: :datatype_definition_string
23
34
  map_element "DATATYPE-DEFINITION-XHTML", to: :datatype_definition_xhtml
@@ -11,13 +11,14 @@ module Reqif
11
11
  attribute :attribute_value_xhtml, AttributeValueXhtml
12
12
 
13
13
  xml do
14
- root "DEFAULT-VALUE"
15
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
14
+ element "DEFAULT-VALUE"
15
+ namespace Namespace
16
16
 
17
17
  # TODO: Only one of these values can be active at the same time
18
18
  map_element "ATTRIBUTE-VALUE-BOOLEAN", to: :attribute_value_boolean
19
19
  map_element "ATTRIBUTE-VALUE-DATE", to: :attribute_value_date
20
- map_element "ATTRIBUTE-VALUE-ENUMERATION", to: :attribute_value_enumeration
20
+ map_element "ATTRIBUTE-VALUE-ENUMERATION",
21
+ to: :attribute_value_enumeration
21
22
  map_element "ATTRIBUTE-VALUE-INTEGER", to: :attribute_value_integer
22
23
  map_element "ATTRIBUTE-VALUE-REAL", to: :attribute_value_real
23
24
  map_element "ATTRIBUTE-VALUE-STRING", to: :attribute_value_string
@@ -2,26 +2,34 @@ require "lutaml/model"
2
2
 
3
3
  module Reqif
4
4
  class Definition < Lutaml::Model::Serializable
5
- attribute :attribute_definition_boolean_ref, :string
6
- attribute :attribute_definition_date_ref, :string
7
- attribute :attribute_definition_enumeration_ref, :string
8
- attribute :attribute_definition_integer_ref, :string
9
- attribute :attribute_definition_real_ref, :string
10
- attribute :attribute_definition_string_ref, :string
11
- attribute :attribute_definition_xhtml_ref, :string
5
+ attribute :attribute_definition_boolean_ref, ::Reqif::StringType
6
+ attribute :attribute_definition_date_ref, ::Reqif::StringType
7
+ attribute :attribute_definition_enumeration_ref, ::Reqif::StringType
8
+ attribute :attribute_definition_integer_ref, ::Reqif::StringType
9
+ attribute :attribute_definition_real_ref, ::Reqif::StringType
10
+ attribute :attribute_definition_string_ref, ::Reqif::StringType
11
+ attribute :attribute_definition_xhtml_ref, ::Reqif::StringType
12
12
 
13
13
  xml do
14
- root "DEFINITION"
15
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
14
+ element "DEFINITION"
15
+ namespace Namespace
16
+ ordered
16
17
 
17
18
  # TODO: Only one of these values can be active at the same time
18
- map_element "ATTRIBUTE-DEFINITION-BOOLEAN-REF", to: :attribute_definition_boolean_ref
19
- map_element "ATTRIBUTE-DEFINITION-DATE-REF", to: :attribute_definition_date_ref
20
- map_element "ATTRIBUTE-DEFINITION-ENUMERATION-REF", to: :attribute_definition_enumeration_ref
21
- map_element "ATTRIBUTE-DEFINITION-INTEGER-REF", to: :attribute_definition_integer_ref
22
- map_element "ATTRIBUTE-DEFINITION-REAL-REF", to: :attribute_definition_real_ref
23
- map_element "ATTRIBUTE-DEFINITION-STRING-REF", to: :attribute_definition_string_ref
24
- map_element "ATTRIBUTE-DEFINITION-XHTML-REF", to: :attribute_definition_xhtml_ref
19
+ map_element "ATTRIBUTE-DEFINITION-BOOLEAN-REF",
20
+ to: :attribute_definition_boolean_ref
21
+ map_element "ATTRIBUTE-DEFINITION-DATE-REF",
22
+ to: :attribute_definition_date_ref
23
+ map_element "ATTRIBUTE-DEFINITION-ENUMERATION-REF",
24
+ to: :attribute_definition_enumeration_ref
25
+ map_element "ATTRIBUTE-DEFINITION-INTEGER-REF",
26
+ to: :attribute_definition_integer_ref
27
+ map_element "ATTRIBUTE-DEFINITION-REAL-REF",
28
+ to: :attribute_definition_real_ref
29
+ map_element "ATTRIBUTE-DEFINITION-STRING-REF",
30
+ to: :attribute_definition_string_ref
31
+ map_element "ATTRIBUTE-DEFINITION-XHTML-REF",
32
+ to: :attribute_definition_xhtml_ref
25
33
  end
26
34
  end
27
35
  end
@@ -0,0 +1,15 @@
1
+ require "lutaml/model"
2
+
3
+ module Reqif
4
+ module Doors
5
+ class Identifier < Lutaml::Model::Serializable
6
+ attribute :content, :string
7
+
8
+ xml do
9
+ element "IDENTIFIER"
10
+ namespace Namespace
11
+ map_content to: :content
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ require "lutaml/model"
2
+
3
+ module Reqif
4
+ module Doors
5
+ class ModuleDefinition < Lutaml::Model::Serializable
6
+ # <MODULE-DEFINITION>
7
+ # <DDC-MODE>DDC_FULL_MODULE</DDC-MODE>
8
+ # <SPECIFICATION-REF░xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd">_3166b6de-d4b9-4334-a13f-a55792546604</SPECIFICATION-REF>
9
+ # </MODULE-DEFINITION>
10
+
11
+ attribute :ddc_mode, :string
12
+ attribute :specification_ref, ::Reqif::Doors::StringType
13
+
14
+ xml do
15
+ element "MODULE-DEFINITION"
16
+ namespace Namespace
17
+
18
+ map_element "DDC-MODE", to: :ddc_mode
19
+ map_element "SPECIFICATION-REF", to: :specification_ref
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ require "lutaml/model"
2
+
3
+ module Reqif
4
+ module Doors
5
+ class Namespace < Lutaml::Xml::Namespace
6
+ uri "http://www.ibm.com/rdm/doors/REQIF/xmlns/1.0"
7
+ prefix_default "doors"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,48 @@
1
+ require "lutaml/model"
2
+
3
+ module Reqif
4
+ module Doors
5
+ class ReadonlyAttributes < Lutaml::Model::Serializable
6
+ # <READONLY-ATTRIBUTES░xmlns="http://www.ibm.com/rdm/doors/REQIF/xmlns/1.0">
7
+ # <ATTRIBUTE-DEFINITION-STRING-REF░xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd">rmf-0d13686b-83c4-487b-9bcc-2f11a673c97a</ATTRIBUTE-DEFINITION-STRING-REF>
8
+ # <ATTRIBUTE-DEFINITION-DATE-REF░xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd">rmf-b5ff951b-70fc-440f-b775-cda530e97083</ATTRIBUTE-DEFINITION-DATE-REF>
9
+ # <ATTRIBUTE-DEFINITION-XHTML-REF░xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd">rmf-0c2fc6c9-50e9-43ae-970b-c04ab506d834</ATTRIBUTE-DEFINITION-XHTML-REF>
10
+
11
+ attribute :attribute_definition_boolean_ref, ::Reqif::Doors::StringType,
12
+ collection: true
13
+ attribute :attribute_definition_date_ref, ::Reqif::Doors::StringType,
14
+ collection: true
15
+ attribute :attribute_definition_enumeration_ref,
16
+ ::Reqif::Doors::StringType, collection: true
17
+ attribute :attribute_definition_integer_ref, ::Reqif::Doors::StringType,
18
+ collection: true
19
+ attribute :attribute_definition_real_ref, ::Reqif::Doors::StringType,
20
+ collection: true
21
+ attribute :attribute_definition_string_ref, ::Reqif::Doors::StringType,
22
+ collection: true
23
+ attribute :attribute_definition_xhtml_ref, ::Reqif::Doors::StringType,
24
+ collection: true
25
+
26
+ xml do
27
+ element "READONLY-ATTRIBUTES"
28
+ namespace ::Reqif::Doors::Namespace
29
+ ordered
30
+
31
+ map_element "ATTRIBUTE-DEFINITION-BOOLEAN-REF",
32
+ to: :attribute_definition_boolean_ref
33
+ map_element "ATTRIBUTE-DEFINITION-DATE-REF",
34
+ to: :attribute_definition_date_ref
35
+ map_element "ATTRIBUTE-DEFINITION-ENUMERATION-REF",
36
+ to: :attribute_definition_enumeration_ref
37
+ map_element "ATTRIBUTE-DEFINITION-INTEGER-REF",
38
+ to: :attribute_definition_integer_ref
39
+ map_element "ATTRIBUTE-DEFINITION-REAL-REF",
40
+ to: :attribute_definition_real_ref
41
+ map_element "ATTRIBUTE-DEFINITION-STRING-REF",
42
+ to: :attribute_definition_string_ref
43
+ map_element "ATTRIBUTE-DEFINITION-XHTML-REF",
44
+ to: :attribute_definition_xhtml_ref
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,26 @@
1
+ require "lutaml/model"
2
+
3
+ module Reqif
4
+ module Doors
5
+ class RifDefinition < Lutaml::Model::Serializable
6
+ # <DOORS-RIF-DEFINITION░xmlns="http://www.ibm.com/rdm/doors/REQIF/xmlns/1.0">
7
+ # <IDENTIFIER>_ae71eb64-2aa6-4780-9212-bda594614a7f</IDENTIFIER>
8
+ # <MODULE-DEFINITION>
9
+ # <DDC-MODE>DDC_FULL_MODULE</DDC-MODE>
10
+ # <SPECIFICATION-REF░xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd">_3166b6de-d4b9-4334-a13f-a55792546604</SPECIFICATION-REF>
11
+ # </MODULE-DEFINITION>
12
+ # </DOORS-RIF-DEFINITION>
13
+
14
+ attribute :identifier, ::Reqif::Doors::Identifier
15
+ attribute :module_definition, ::Reqif::Doors::ModuleDefinition
16
+
17
+ xml do
18
+ element "DOORS-RIF-DEFINITION"
19
+ namespace ::Reqif::Doors::Namespace
20
+
21
+ map_element "IDENTIFIER", to: :identifier
22
+ map_element "MODULE-DEFINITION", to: :module_definition
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,12 @@
1
+ module Reqif
2
+ module Doors
3
+ # String type that uses the ReqIF namespace, not Doors namespace.
4
+ # This is because elements like ATTRIBUTE-DEFINITION-*-REF inside
5
+ # Doors elements like READONLY-ATTRIBUTES still belong to the ReqIF namespace.
6
+ class StringType < Lutaml::Model::Type::String
7
+ xml do
8
+ namespace ::Reqif::Namespace
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require "lutaml/model"
2
+
3
+ module Reqif
4
+ module Doors
5
+ autoload :Namespace, "#{__dir__}/doors/namespace.rb"
6
+ autoload :Identifier, "#{__dir__}/doors/identifier.rb"
7
+ autoload :ModuleDefinition, "#{__dir__}/doors/module_definition.rb"
8
+ autoload :RifDefinition, "#{__dir__}/doors/rif_definition.rb"
9
+ autoload :ReadonlyAttributes, "#{__dir__}/doors/readonly_attributes.rb"
10
+ autoload :StringType, "#{__dir__}/doors/string_type.rb"
11
+ end
12
+ end
@@ -2,25 +2,33 @@ require "lutaml/model"
2
2
 
3
3
  module Reqif
4
4
  class EditableAtts < Lutaml::Model::Serializable
5
- attribute :attribute_definition_boolean_ref, :string, collection: true
6
- attribute :attribute_definition_date_ref, :string, collection: true
7
- attribute :attribute_definition_enumeration_ref, :string, collection: true
8
- attribute :attribute_definition_integer_ref, :string, collection: true
9
- attribute :attribute_definition_real_ref, :string, collection: true
10
- attribute :attribute_definition_string_ref, :string, collection: true
11
- attribute :attribute_definition_xhtml_ref, :string, collection: true
5
+ attribute :attribute_definition_boolean_ref, StringType, collection: true
6
+ attribute :attribute_definition_date_ref, StringType, collection: true
7
+ attribute :attribute_definition_enumeration_ref, StringType,
8
+ collection: true
9
+ attribute :attribute_definition_integer_ref, StringType, collection: true
10
+ attribute :attribute_definition_real_ref, StringType, collection: true
11
+ attribute :attribute_definition_string_ref, StringType, collection: true
12
+ attribute :attribute_definition_xhtml_ref, StringType, collection: true
12
13
 
13
14
  xml do
14
- root "EDITABLE-ATTS"
15
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
15
+ element "EDITABLE-ATTS"
16
+ namespace Namespace
16
17
 
17
- map_element "ATTRIBUTE-DEFINITION-BOOLEAN-REF", to: :attribute_definition_boolean_ref
18
- map_element "ATTRIBUTE-DEFINITION-DATE-REF", to: :attribute_definition_date_ref
19
- map_element "ATTRIBUTE-DEFINITION-ENUMERATION-REF", to: :attribute_definition_enumeration_ref
20
- map_element "ATTRIBUTE-DEFINITION-INTEGER-REF", to: :attribute_definition_integer_ref
21
- map_element "ATTRIBUTE-DEFINITION-REAL-REF", to: :attribute_definition_real_ref
22
- map_element "ATTRIBUTE-DEFINITION-STRING-REF", to: :attribute_definition_string_ref
23
- map_element "ATTRIBUTE-DEFINITION-XHTML-REF", to: :attribute_definition_xhtml_ref
18
+ map_element "ATTRIBUTE-DEFINITION-BOOLEAN-REF",
19
+ to: :attribute_definition_boolean_ref
20
+ map_element "ATTRIBUTE-DEFINITION-DATE-REF",
21
+ to: :attribute_definition_date_ref
22
+ map_element "ATTRIBUTE-DEFINITION-ENUMERATION-REF",
23
+ to: :attribute_definition_enumeration_ref
24
+ map_element "ATTRIBUTE-DEFINITION-INTEGER-REF",
25
+ to: :attribute_definition_integer_ref
26
+ map_element "ATTRIBUTE-DEFINITION-REAL-REF",
27
+ to: :attribute_definition_real_ref
28
+ map_element "ATTRIBUTE-DEFINITION-STRING-REF",
29
+ to: :attribute_definition_string_ref
30
+ map_element "ATTRIBUTE-DEFINITION-XHTML-REF",
31
+ to: :attribute_definition_xhtml_ref
24
32
  end
25
33
  end
26
34
  end
@@ -6,11 +6,12 @@ module Reqif
6
6
  attribute :other_content, :string
7
7
 
8
8
  xml do
9
- root "EMBEDDED-VALUE"
10
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
9
+ element "EMBEDDED-VALUE"
10
+ namespace Namespace
11
+ ordered
11
12
 
12
13
  map_attribute "KEY", to: :key
13
- map_attribute "OTHER-CONTENT", to: :other_content
14
+ map_attribute "OTHER-CONTENT", to: :other_content, render_empty: true
14
15
  end
15
16
  end
16
17
  end
@@ -4,16 +4,16 @@ module Reqif
4
4
  class EnumValue < Lutaml::Model::Serializable
5
5
  attribute :desc, :string
6
6
  attribute :identifier, :string
7
- attribute :last_change, :time
7
+ attribute :last_change, HighPrecisionDateTime
8
8
  attribute :long_name, :string
9
9
  attribute :alternative_id, AlternativeId
10
10
  attribute :properties, Properties
11
11
 
12
12
  xml do
13
- root "ENUM-VALUE"
14
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
13
+ element "ENUM-VALUE"
14
+ namespace Namespace
15
15
 
16
- map_attribute "DESC", to: :desc
16
+ map_attribute "DESC", to: :desc, render_empty: true
17
17
  map_attribute "IDENTIFIER", to: :identifier
18
18
  map_attribute "LAST-CHANGE", to: :last_change
19
19
  map_attribute "LONG-NAME", to: :long_name
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model/type/date_time"
4
+
5
+ module Reqif
6
+ # High precision DateTime type that preserves fractional seconds precision
7
+ class HighPrecisionDateTime < Lutaml::Model::Type::DateTime
8
+ attr_accessor :precision, :has_explicit_timezone
9
+
10
+ def initialize(value = nil)
11
+ super
12
+ @precision = 0
13
+ end
14
+
15
+ # The format looks like this `2012-04-07T01:51:37.112+02:00`
16
+ # or this `2021-07-01T01:12:06.749Z`
17
+ def self.from_xml(xml_string)
18
+ new(::DateTime.parse(xml_string)).tap do |date_time|
19
+ date_time.precision = extract_precision(xml_string)
20
+ date_time.has_explicit_timezone = xml_string.match?(/[Zz]|[+-]\d{2}:\d{2}$/)
21
+ end
22
+ end
23
+
24
+ # Extract the precision of the milliseconds from the XML string
25
+ def self.extract_precision(xml_string)
26
+ if xml_string.include?(".")
27
+ milliseconds_part = xml_string.split(".").last.split(/Z|\+|-/).first
28
+ milliseconds_part.length
29
+ else
30
+ 0
31
+ end
32
+ end
33
+
34
+ def to_xml
35
+ base = "%Y-%m-%dT%H:%M:%S"
36
+ pattern = precision.positive? ? "#{base}.%#{precision}N" : base
37
+ if has_explicit_timezone
38
+ value.offset.zero? ? value.strftime("#{pattern}Z") : value.strftime("#{pattern}%:z")
39
+ else
40
+ value.strftime(pattern)
41
+ end
42
+ end
43
+
44
+ def iso8601(precision = nil)
45
+ if precision.nil? || precision.zero?
46
+ value.iso8601
47
+ else
48
+ value.strftime("%Y-%m-%dT%H:%M:%S.%#{precision}N%z")
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/xml/namespace"
4
+
5
+ module Reqif
6
+ # Namespace class for ReqIF XML elements.
7
+ # Supports alias URIs for backwards compatibility with different ReqIF versions.
8
+ # ReqIF 1.1 uses http://www.omg.org/spec/ReqIF/20110401/reqif.xsd
9
+ # Some older tools (e.g., Eclipse RMF) used http://www.omg.org/spec/ReqIF/20101201
10
+ class Namespace < Lutaml::Xml::Namespace
11
+ uri "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd"
12
+ uri_aliases "http://www.omg.org/spec/ReqIF/20101201"
13
+ element_form_default :qualified
14
+ attribute_form_default :qualified
15
+ end
16
+ end
data/lib/reqif/object.rb CHANGED
@@ -2,11 +2,11 @@ require "lutaml/model"
2
2
 
3
3
  module Reqif
4
4
  class Object < Lutaml::Model::Serializable
5
- attribute :spec_object_ref, :string
5
+ attribute :spec_object_ref, StringType
6
6
 
7
7
  xml do
8
- root "OBJECT"
9
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
8
+ element "OBJECT"
9
+ namespace Namespace
10
10
 
11
11
  map_element "SPEC-OBJECT-REF", to: :spec_object_ref
12
12
  end
@@ -5,8 +5,8 @@ module Reqif
5
5
  attribute :embedded_value, EmbeddedValue
6
6
 
7
7
  xml do
8
- root "PROPERTIES"
9
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
8
+ element "PROPERTIES"
9
+ namespace Namespace
10
10
 
11
11
  map_element "EMBEDDED-VALUE", to: :embedded_value
12
12
  end
@@ -4,7 +4,7 @@ module Reqif
4
4
  class RelationGroup < Lutaml::Model::Serializable
5
5
  attribute :desc, :string
6
6
  attribute :identifier, :string
7
- attribute :last_change, :time
7
+ attribute :last_change, HighPrecisionDateTime
8
8
  attribute :long_name, :string
9
9
  attribute :alternative_id, AlternativeId
10
10
  attribute :source_specification, SourceSpecification
@@ -13,10 +13,11 @@ module Reqif
13
13
  attribute :type, Type
14
14
 
15
15
  xml do
16
- root "RELATION-GROUP"
17
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
16
+ element "RELATION-GROUP"
17
+ namespace Namespace
18
+ ordered
18
19
 
19
- map_attribute "DESC", to: :desc
20
+ map_attribute "DESC", to: :desc, render_empty: true
20
21
  map_attribute "IDENTIFIER", to: :identifier
21
22
  map_attribute "LAST-CHANGE", to: :last_change
22
23
  map_attribute "LONG-NAME", to: :long_name
@@ -4,16 +4,17 @@ module Reqif
4
4
  class RelationGroupType < Lutaml::Model::Serializable
5
5
  attribute :desc, :string
6
6
  attribute :identifier, :string
7
- attribute :last_change, :time
7
+ attribute :last_change, HighPrecisionDateTime
8
8
  attribute :long_name, :string
9
9
  attribute :alternative_id, AlternativeId
10
10
  attribute :spec_attributes, SpecAttributes
11
11
 
12
12
  xml do
13
- root "RELATION-GROUP-TYPE"
14
- namespace "http://www.omg.org/spec/ReqIF/20110401/reqif.xsd", "REQIF"
13
+ element "RELATION-GROUP-TYPE"
14
+ namespace Namespace
15
+ ordered
15
16
 
16
- map_attribute "DESC", to: :desc
17
+ map_attribute "DESC", to: :desc, render_empty: true
17
18
  map_attribute "IDENTIFIER", to: :identifier
18
19
  map_attribute "LAST-CHANGE", to: :last_change
19
20
  map_attribute "LONG-NAME", to: :long_name