modspec 0.1.0 → 0.1.2

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.rubocop_todo.yml +118 -0
  4. data/Gemfile +4 -2
  5. data/README.adoc +508 -17
  6. data/lib/modspec/conformance_class.rb +39 -10
  7. data/lib/modspec/conformance_test.rb +40 -13
  8. data/lib/modspec/identifier.rb +5 -3
  9. data/lib/modspec/normative_statement.rb +49 -14
  10. data/lib/modspec/normative_statements_class.rb +39 -12
  11. data/lib/modspec/suite.rb +242 -5
  12. data/lib/modspec/version.rb +1 -1
  13. data/lib/modspec.rb +14 -4
  14. data/modspec.gemspec +8 -14
  15. data/spec/conformance_class.liquid +98 -0
  16. data/spec/fixtures/advanced-cc.yaml +52 -0
  17. data/spec/fixtures/advanced-json-cc.yaml +24 -0
  18. data/spec/fixtures/advanced-json-rc.yaml +16 -0
  19. data/spec/fixtures/advanced-rc.yaml +43 -0
  20. data/spec/fixtures/basic-quaternion-cc.yaml +44 -0
  21. data/spec/fixtures/basic-quaternion-json-cc.yaml +24 -0
  22. data/spec/fixtures/basic-quaternion-json-rc.yaml +17 -0
  23. data/spec/fixtures/basic-quaternion-json-strict-cc.yaml +22 -0
  24. data/spec/fixtures/basic-quaternion-json-strict-rc.yaml +19 -0
  25. data/spec/fixtures/basic-quaternion-rc.yaml +34 -0
  26. data/spec/fixtures/basic-ypr-cc.yaml +39 -0
  27. data/spec/fixtures/basic-ypr-json-cc.yaml +23 -0
  28. data/spec/fixtures/basic-ypr-json-rc.yaml +21 -0
  29. data/spec/fixtures/basic-ypr-rc.yaml +32 -0
  30. data/spec/fixtures/chain-cc.yaml +50 -0
  31. data/spec/fixtures/chain-json-cc.yaml +24 -0
  32. data/spec/fixtures/chain-json-rc.yaml +20 -0
  33. data/spec/fixtures/chain-rc.yaml +36 -0
  34. data/spec/fixtures/frame-spec-cc.yaml +43 -0
  35. data/spec/fixtures/frame-spec-rc.yaml +27 -0
  36. data/spec/fixtures/global-cc.yaml +38 -0
  37. data/spec/fixtures/global-rc.yaml +23 -0
  38. data/spec/fixtures/graph-cc.yaml +48 -0
  39. data/spec/fixtures/graph-json-cc.yaml +24 -0
  40. data/spec/fixtures/graph-json-rc.yaml +20 -0
  41. data/spec/fixtures/graph-rc.yaml +38 -0
  42. data/spec/fixtures/series-irregular-cc.yaml +58 -0
  43. data/spec/fixtures/series-irregular-json-cc.yaml +24 -0
  44. data/spec/fixtures/series-irregular-json-rc.yaml +20 -0
  45. data/spec/fixtures/series-irregular-rc.yaml +41 -0
  46. data/spec/fixtures/series-regular-cc.yaml +63 -0
  47. data/spec/fixtures/series-regular-json-cc.yaml +24 -0
  48. data/spec/fixtures/series-regular-json-rc.yaml +20 -0
  49. data/spec/fixtures/series-regular-rc.yaml +46 -0
  50. data/spec/fixtures/stream-cc.yaml +49 -0
  51. data/spec/fixtures/stream-json-cc.yaml +48 -0
  52. data/spec/fixtures/stream-json-rc.yaml +32 -0
  53. data/spec/fixtures/stream-rc.yaml +36 -0
  54. data/spec/fixtures/tangent-point-cc.yaml +43 -0
  55. data/spec/fixtures/tangent-point-rc.yaml +38 -0
  56. data/spec/fixtures/time-cc.yaml +32 -0
  57. data/spec/fixtures/time-rc.yaml +20 -0
  58. data/spec/modspec/conformance_class_spec.rb +154 -0
  59. data/spec/modspec/conformance_test_spec.rb +76 -0
  60. data/spec/modspec/normative_statement_spec.rb +81 -0
  61. data/spec/modspec/normative_statements_class_spec.rb +61 -0
  62. data/spec/modspec/suite_spec.rb +109 -0
  63. data/spec/modspec_spec.rb +25 -0
  64. data/spec/requirements_class.liquid +93 -0
  65. data/spec/spec_helper.rb +16 -0
  66. metadata +71 -61
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Modspec::Suite do
4
+ let(:rc_yaml) { File.read("spec/fixtures/basic-ypr-rc.yaml") }
5
+ let(:cc_yaml) { File.read("spec/fixtures/basic-ypr-cc.yaml") }
6
+
7
+ let(:global_rc) { File.read("spec/fixtures/global-rc.yaml") }
8
+ let(:tangent_point_rc) { File.read("spec/fixtures/tangent-point-rc.yaml") }
9
+ let(:time_rc) { File.read("spec/fixtures/time-rc.yaml") }
10
+ let(:frame_spec_rc) { File.read("spec/fixtures/frame-spec-rc.yaml") }
11
+
12
+ let(:global_suite) { Modspec::Suite.from_yaml(global_rc) }
13
+ let(:tangent_point_suite) { Modspec::Suite.from_yaml(tangent_point_rc) }
14
+ let(:time_suite) { Modspec::Suite.from_yaml(time_rc) }
15
+ let(:frame_spec_suite) { Modspec::Suite.from_yaml(frame_spec_rc) }
16
+
17
+ describe ".from_yaml" do
18
+ it "parses a requirements class YAML file" do
19
+ suite = described_class.from_yaml(rc_yaml)
20
+ expect(suite).to be_a(described_class)
21
+ expect(suite.normative_statements_classes).not_to be_empty
22
+ end
23
+
24
+ it "parses a conformance class YAML file" do
25
+ suite = described_class.from_yaml(cc_yaml)
26
+ expect(suite).to be_a(described_class)
27
+ expect(suite.conformance_classes).not_to be_empty
28
+ end
29
+ end
30
+
31
+ describe "#validate" do
32
+ it "returns no errors for a valid combined suite" do
33
+ base_suite = described_class.from_yaml(rc_yaml)
34
+ combined_suite = base_suite
35
+ .combine(global_suite)
36
+ .combine(tangent_point_suite)
37
+ .combine(time_suite)
38
+ .combine(frame_spec_suite)
39
+
40
+ errors = combined_suite.validate
41
+ if errors.any?
42
+ puts "Validation errors:"
43
+ errors.each { |error| puts " #{error}" }
44
+ end
45
+ expect(errors).to be_empty
46
+ end
47
+ end
48
+
49
+ describe "#combine" do
50
+ let(:suite1) { described_class.from_yaml(File.read("spec/fixtures/basic-ypr-rc.yaml")) }
51
+ let(:suite2) { described_class.from_yaml(File.read("spec/fixtures/basic-quaternion-rc.yaml")) }
52
+
53
+ it "combines two suites" do
54
+ combined_suite = suite1.combine(suite2)
55
+ expect(combined_suite.name).to eq("#{suite1.name} + #{suite2.name}")
56
+ expect(combined_suite.normative_statements_classes.count).to eq(
57
+ suite1.normative_statements_classes.count +
58
+ suite2.normative_statements_classes.count
59
+ )
60
+ end
61
+
62
+ it "resolves conflicts when combining suites" do
63
+ combined_suite = suite1
64
+ .combine(suite2)
65
+ .combine(global_suite)
66
+ .combine(tangent_point_suite)
67
+ .combine(time_suite)
68
+ .combine(frame_spec_suite)
69
+
70
+ errors = combined_suite.validate
71
+ if errors.any?
72
+ puts "Validation errors:"
73
+ errors.each { |error| puts " #{error}" }
74
+ end
75
+ expect(errors).to be_empty
76
+ end
77
+ end
78
+
79
+ describe ".from_yaml_files" do
80
+ it "combines all YAML files in spec/fixtures and validates the combined suite" do
81
+ yaml_files = Dir.glob("spec/fixtures/*.yaml")
82
+ expect(yaml_files).not_to be_empty
83
+
84
+ combined_suite = described_class.from_yaml_files(*yaml_files)
85
+ expect(combined_suite).to be_a(described_class)
86
+ expect(combined_suite.name).to eq("Combined Suite")
87
+
88
+ # Ensure the combined suite has content
89
+ expect(combined_suite.normative_statements_classes).not_to be_empty
90
+ expect(combined_suite.conformance_classes).not_to be_empty
91
+
92
+ # Validate the combined suite
93
+ errors = combined_suite.validate
94
+
95
+ if errors.any?
96
+ puts "Validation errors:"
97
+ errors.each { |error| puts " #{error}" }
98
+ end
99
+
100
+ # Check for specific error types
101
+ expect(errors).not_to include(a_string_matching(/Conformance test .* has no corresponding requirement/))
102
+ expect(errors).not_to include(a_string_matching(/Cycle detected/))
103
+ expect(errors).not_to include(a_string_matching(/Requirement .* has an invalid dependency/))
104
+
105
+ # If there are still errors, they should be of a different nature
106
+ expect(errors).to be_empty
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Modspec do
4
+ it "has a version number" do
5
+ expect(Modspec::VERSION).not_to be nil
6
+ end
7
+
8
+ Dir.glob("spec/fixtures/*-rc.yaml").each do |file|
9
+ it "parses normative statements class #{file}" do
10
+ yaml = IO.read(file)
11
+ Modspec::Suite.from_yaml(yaml)
12
+
13
+ # TODO: tests
14
+ end
15
+ end
16
+
17
+ Dir.glob("spec/fixtures/*-cc.yaml").each do |file|
18
+ it "parses conformance class #{file}" do
19
+ yaml = IO.read(file)
20
+ Modspec::Suite.from_yaml(yaml)
21
+
22
+ # TODO: tests
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,93 @@
1
+ {% assign rc_count = 0 %}
2
+
3
+ {% for scope in group.scopes %}
4
+ {% assign rc_count = rc_count | plus: 1 %}
5
+ [[rc-{{prefix}}-{{rc_count}}]]
6
+ .{{scope.name}}
7
+ [requirements_class]
8
+ ====
9
+ [%metadata]
10
+ identifier:: {{scope.identifier}}
11
+ description::
12
+ +
13
+ --
14
+ {{scope.description}}
15
+ --
16
+
17
+ {% if {{scope.subject}} %}
18
+ subject:: {{scope.subject}}
19
+ {% endif %}
20
+
21
+ {% if {{scope.source}} %}
22
+ Source:: {{scope.source}}
23
+ {% endif %}
24
+
25
+ {% for depend in {{scope.dependencies}} %}
26
+ inherit:: {{depend}}
27
+ {% endfor %}
28
+
29
+ {% for requirement in {{scope.requirements}} %}
30
+ requirement:: {{requirement.identifier}}
31
+ {% endfor %}
32
+
33
+ {% if {{scope.guidance}} %}
34
+ guidance::
35
+ +
36
+ --
37
+ {% for rec in {{scope.guidance}} %}
38
+ * {{rec}}
39
+ {% endfor %}
40
+ --
41
+ {% endif %}
42
+
43
+ ====
44
+
45
+ {% assign r_count = 0 %}
46
+ {% for requirement in {{scope.requirements}} %}
47
+ {% assign r_count = r_count | plus: 1 %}
48
+ {% if {{requirement.name}} %}
49
+ .{{requirement.name}}
50
+ {% endif %}
51
+ [[r-{{prefix}}-{{rc_count}}-{{r_count}}]]
52
+ [requirement]
53
+ ====
54
+ [%metadata]
55
+ identifier:: {{requirement.identifier}}
56
+ description::
57
+ +
58
+ --
59
+ {{requirement.description}}
60
+ --
61
+
62
+ {% for depend in {{requirement.dependencies}} %}
63
+ inherit:: {{depend}}
64
+ {% endfor %}
65
+
66
+ {% if {{requirement.subject}} %}
67
+ subject:: {{requirement.subject}}
68
+ {% endif %}
69
+
70
+ {% if {{requirement.uml-source}} %}
71
+ UML source:: {{requirement.uml-source}}
72
+ {% endif %}
73
+
74
+ {% if {{requirement.uml-package}} %}
75
+ UML package:: {{requirement.uml-package}}
76
+ {% endif %}
77
+
78
+
79
+ {% if {{requirement.guidance}} %}
80
+ guidance::
81
+ +
82
+ --
83
+ {% for rec in {{requirement.guidance}} %}
84
+ * {{rec}}
85
+ {% endfor %}
86
+ --
87
+ {% endif %}
88
+
89
+ ====
90
+
91
+ {% endfor %}
92
+
93
+ {% endfor %}
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "modspec"
4
+ require "yaml"
5
+
6
+ RSpec.configure do |config|
7
+ # Enable flags like --only-failures and --next-failure
8
+ config.example_status_persistence_file_path = ".rspec_status"
9
+
10
+ # Disable RSpec exposing methods globally on `Module` and `main`
11
+ config.disable_monkey_patching!
12
+
13
+ config.expect_with :rspec do |c|
14
+ c.syntax = :expect
15
+ end
16
+ end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
11
+ date: 2025-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: nokogiri
14
+ name: lutaml-model
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.3.10
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.3.10
27
27
  - !ruby/object:Gem::Dependency
28
- name: shale
28
+ name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,62 +39,20 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: pry
42
+ name: toml-rb
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.14.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.14.0
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '13.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '13.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.10'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.10'
83
- - !ruby/object:Gem::Dependency
84
- name: equivalent-xml
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
45
+ - - ">="
88
46
  - !ruby/object:Gem::Version
89
- version: '0.6'
90
- type: :development
47
+ version: '0'
48
+ type: :runtime
91
49
  prerelease: false
92
50
  version_requirements: !ruby/object:Gem::Requirement
93
51
  requirements:
94
- - - "~>"
52
+ - - ">="
95
53
  - !ruby/object:Gem::Version
96
- version: '0.6'
97
- description:
54
+ version: '0'
55
+ description:
98
56
  email:
99
57
  - open.source@ribose.com
100
58
  executables: []
@@ -106,6 +64,7 @@ files:
106
64
  - ".gitignore"
107
65
  - ".rspec"
108
66
  - ".rubocop.yml"
67
+ - ".rubocop_todo.yml"
109
68
  - CODE_OF_CONDUCT.md
110
69
  - Gemfile
111
70
  - README.adoc
@@ -120,6 +79,57 @@ files:
120
79
  - lib/modspec/version.rb
121
80
  - modspec.gemspec
122
81
  - sig/modspec.rbs
82
+ - spec/conformance_class.liquid
83
+ - spec/fixtures/advanced-cc.yaml
84
+ - spec/fixtures/advanced-json-cc.yaml
85
+ - spec/fixtures/advanced-json-rc.yaml
86
+ - spec/fixtures/advanced-rc.yaml
87
+ - spec/fixtures/basic-quaternion-cc.yaml
88
+ - spec/fixtures/basic-quaternion-json-cc.yaml
89
+ - spec/fixtures/basic-quaternion-json-rc.yaml
90
+ - spec/fixtures/basic-quaternion-json-strict-cc.yaml
91
+ - spec/fixtures/basic-quaternion-json-strict-rc.yaml
92
+ - spec/fixtures/basic-quaternion-rc.yaml
93
+ - spec/fixtures/basic-ypr-cc.yaml
94
+ - spec/fixtures/basic-ypr-json-cc.yaml
95
+ - spec/fixtures/basic-ypr-json-rc.yaml
96
+ - spec/fixtures/basic-ypr-rc.yaml
97
+ - spec/fixtures/chain-cc.yaml
98
+ - spec/fixtures/chain-json-cc.yaml
99
+ - spec/fixtures/chain-json-rc.yaml
100
+ - spec/fixtures/chain-rc.yaml
101
+ - spec/fixtures/frame-spec-cc.yaml
102
+ - spec/fixtures/frame-spec-rc.yaml
103
+ - spec/fixtures/global-cc.yaml
104
+ - spec/fixtures/global-rc.yaml
105
+ - spec/fixtures/graph-cc.yaml
106
+ - spec/fixtures/graph-json-cc.yaml
107
+ - spec/fixtures/graph-json-rc.yaml
108
+ - spec/fixtures/graph-rc.yaml
109
+ - spec/fixtures/series-irregular-cc.yaml
110
+ - spec/fixtures/series-irregular-json-cc.yaml
111
+ - spec/fixtures/series-irregular-json-rc.yaml
112
+ - spec/fixtures/series-irregular-rc.yaml
113
+ - spec/fixtures/series-regular-cc.yaml
114
+ - spec/fixtures/series-regular-json-cc.yaml
115
+ - spec/fixtures/series-regular-json-rc.yaml
116
+ - spec/fixtures/series-regular-rc.yaml
117
+ - spec/fixtures/stream-cc.yaml
118
+ - spec/fixtures/stream-json-cc.yaml
119
+ - spec/fixtures/stream-json-rc.yaml
120
+ - spec/fixtures/stream-rc.yaml
121
+ - spec/fixtures/tangent-point-cc.yaml
122
+ - spec/fixtures/tangent-point-rc.yaml
123
+ - spec/fixtures/time-cc.yaml
124
+ - spec/fixtures/time-rc.yaml
125
+ - spec/modspec/conformance_class_spec.rb
126
+ - spec/modspec/conformance_test_spec.rb
127
+ - spec/modspec/normative_statement_spec.rb
128
+ - spec/modspec/normative_statements_class_spec.rb
129
+ - spec/modspec/suite_spec.rb
130
+ - spec/modspec_spec.rb
131
+ - spec/requirements_class.liquid
132
+ - spec/spec_helper.rb
123
133
  homepage: https://github.com/metanorma/modspec-ruby
124
134
  licenses:
125
135
  - BSD-2-Clause
@@ -127,7 +137,7 @@ metadata:
127
137
  homepage_uri: https://github.com/metanorma/modspec-ruby
128
138
  source_code_uri: https://github.com/metanorma/modspec-ruby
129
139
  bug_tracker_uri: https://github.com/metanorma/modspec-ruby/issues
130
- post_install_message:
140
+ post_install_message:
131
141
  rdoc_options: []
132
142
  require_paths:
133
143
  - lib
@@ -142,8 +152,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
152
  - !ruby/object:Gem::Version
143
153
  version: '0'
144
154
  requirements: []
145
- rubygems_version: 3.3.26
146
- signing_key:
155
+ rubygems_version: 3.3.27
156
+ signing_key:
147
157
  specification_version: 4
148
158
  summary: Library to work with OGC ModSpec.
149
159
  test_files: []