modspec 0.1.3 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cd4badc4f810933f2fec27871086eefcc0158e211e13330fb254c6c6b434eb0
4
- data.tar.gz: b43653c35d01208efe9fb99114397488428904549deb1a10db84394b9bdd1b0a
3
+ metadata.gz: c39d089400518c8882fa0cfc55582fa27cd73c9358faf2224aeb5535a238fc55
4
+ data.tar.gz: c7b5fcf2a9c36ab12751ac964b6d95528a21330228872c75851bdf2211a8d885
5
5
  SHA512:
6
- metadata.gz: 2767799e906ee065a3df1eb05b74f53acb839a0e34e37ed70a1a1418a0f80bdfc0de90e0b3155a958da6f5f35dfcb090c06657e882e17f4f86b0c72b4f42a293
7
- data.tar.gz: '08f9a6974ea4726b0d062338f0e687c8c99a74494ff4a62f56b481c01bd72aa62fda8ef164840d1acef0d5b178e3cc9a4f59d51d137cba9cad10280e559d8b03'
6
+ metadata.gz: d8e4371eea18c40f1b660841ff6d1723b8a8536acd248a65d87d6d4526bba35ea0b00970e7199bdeaee51114c1cd214233859c2265d1f43fb742831f19c71568
7
+ data.tar.gz: 7f6f7f555aaa1ce91e300240ce57f37e69d77e1fb4f1ff0fb020e8afc69c195c3a287f2540bbcce31019481915a2fb2d1ba748670f1c9f6ce622eb6d4b720e58
data/Gemfile CHANGED
@@ -9,3 +9,4 @@ gem "equivalent-xml"
9
9
  gem "pry"
10
10
  gem "rake"
11
11
  gem "rspec"
12
+ gem "rubocop"
@@ -42,7 +42,7 @@ module Modspec
42
42
  private
43
43
 
44
44
  def validate_class_children_mapping
45
- if tests.empty?
45
+ if tests.nil? || tests.empty?
46
46
  ["Conformance class #{identifier} has no child conformance tests"]
47
47
  else
48
48
  []
@@ -52,8 +52,10 @@ module Modspec
52
52
  def validate_identifier_prefix
53
53
  errors = []
54
54
  expected_prefix = "#{identifier}/"
55
- tests.each do |test|
56
- errors << "Conformance test #{test.identifier} does not share the expected prefix #{expected_prefix}" unless test.identifier.to_s.start_with?(expected_prefix)
55
+ if tests
56
+ tests.each do |test|
57
+ errors << "Conformance test #{test.identifier} does not share the expected prefix #{expected_prefix}" unless test.identifier.to_s.start_with?(expected_prefix)
58
+ end
57
59
  end
58
60
  errors
59
61
  end
@@ -46,7 +46,7 @@ module Modspec
46
46
  private
47
47
 
48
48
  def validate_requirement_mapping
49
- if corresponding_requirements.empty?
49
+ if corresponding_requirements.nil? || corresponding_requirements.empty?
50
50
  ["Conformance test #{identifier} has no corresponding requirements"]
51
51
  else
52
52
  []
@@ -54,7 +54,7 @@ module Modspec
54
54
  end
55
55
 
56
56
  def validate_class_mapping
57
- if parent_class.nil? || !parent_class.tests.include?(self)
57
+ if parent_class.nil? || parent_class.tests.nil? || !parent_class.tests.include?(self)
58
58
  ["Conformance test #{identifier} does not belong to its parent class"]
59
59
  else
60
60
  []
@@ -55,9 +55,16 @@ module Modspec
55
55
 
56
56
  private
57
57
 
58
+ def all_dependencies
59
+ (
60
+ (dependencies || []) +
61
+ (indirect_dependency || []) +
62
+ (implements || [])
63
+ ).flatten.compact
64
+ end
65
+
58
66
  def validate_dependencies(suite)
59
67
  errors = []
60
- all_dependencies = (dependencies + indirect_dependency + implements).flatten.compact.map(&:to_s)
61
68
  all_identifiers = suite.all_identifiers.map(&:to_s)
62
69
  all_dependencies.each do |dep|
63
70
  errors << "Requirement #{identifier} has an invalid dependency: #{dep}" unless all_identifiers.include?(dep)
@@ -42,16 +42,16 @@ module Modspec
42
42
  private
43
43
 
44
44
  def validate_identifier_prefix
45
- errors = []
45
+ return [] if normative_statements.nil? || normative_statements.empty?
46
+
46
47
  expected_prefix = "#{identifier}/"
47
- normative_statements.each do |statement|
48
+ normative_statements.each_with_object([]) do |statement, errors|
48
49
  errors << "Normative statement #{statement.identifier} does not share the expected prefix #{expected_prefix}" unless statement.identifier.to_s.start_with?(expected_prefix)
49
50
  end
50
- errors
51
51
  end
52
52
 
53
53
  def validate_class_children_mapping
54
- if normative_statements.empty?
54
+ if normative_statements.nil? || normative_statements.empty?
55
55
  ["Requirement class #{identifier} has no child requirements"]
56
56
  else
57
57
  []
data/lib/modspec/suite.rb CHANGED
@@ -20,12 +20,12 @@ module Modspec
20
20
  def validate
21
21
  setup_relationships
22
22
  self.all_identifiers = nil
23
- errors = super()
23
+ errors = super
24
24
  errors.concat(validate_cycles)
25
25
  errors.concat(validate_label_uniqueness)
26
26
  errors.concat(validate_dependencies)
27
- errors.concat(normative_statements_classes.flat_map { |n| n.validate(self) })
28
- errors.concat(conformance_classes.flat_map(&:validate))
27
+ errors.concat(normative_statements_classes.flat_map { |n| n.validate(self) }) unless normative_statements_classes.nil?
28
+ errors.concat(conformance_classes.flat_map(&:validate)) unless conformance_classes.nil?
29
29
  errors
30
30
  end
31
31
 
@@ -34,12 +34,20 @@ module Modspec
34
34
 
35
35
  combined_suite = dup
36
36
  combined_suite.all_identifiers = nil
37
- combined_suite.normative_statements_classes += other_suite.normative_statements_classes
38
- combined_suite.conformance_classes += other_suite.conformance_classes
37
+ if other_suite.normative_statements_classes
38
+ combined_suite.normative_statements_classes ||= []
39
+ combined_suite.normative_statements_classes += other_suite.normative_statements_classes
40
+ end
41
+
42
+ if other_suite.conformance_classes
43
+ combined_suite.conformance_classes ||= []
44
+ combined_suite.conformance_classes += other_suite.conformance_classes
45
+ end
39
46
 
40
47
  # Ensure uniqueness of identifiers
41
- combined_suite.normative_statements_classes.uniq!(&:identifier)
42
- combined_suite.conformance_classes.uniq!(&:identifier)
48
+ combined_suite.normative_statements_classes.uniq!(&:identifier) if combined_suite.normative_statements_classes
49
+
50
+ combined_suite.conformance_classes.uniq!(&:identifier) if combined_suite.conformance_classes
43
51
 
44
52
  combined_suite.name = "#{name} + #{other_suite.name}"
45
53
 
@@ -47,10 +55,15 @@ module Modspec
47
55
  end
48
56
 
49
57
  def all_identifiers
50
- @all_identifiers ||= (normative_statements_classes.flat_map(&:normative_statements) +
51
- conformance_classes.flat_map(&:tests) +
52
- normative_statements_classes +
53
- conformance_classes).map(&:identifier)
58
+ return @all_identifiers if @all_identifiers
59
+
60
+ nsc = normative_statements_classes || []
61
+ cc = conformance_classes || []
62
+
63
+ @all_identifiers = (nsc.flat_map(&:normative_statements) +
64
+ cc.flat_map(&:tests) +
65
+ nsc +
66
+ cc).map(&:identifier)
54
67
  end
55
68
 
56
69
  attr_writer :all_identifiers
@@ -71,7 +84,13 @@ module Modspec
71
84
  end
72
85
 
73
86
  def setup_relationships
74
- all_requirements = normative_statements_classes.flat_map(&:normative_statements)
87
+ all_requirements = if normative_statements_classes
88
+ normative_statements_classes.flat_map(&:normative_statements)
89
+ else
90
+ []
91
+ end
92
+
93
+ return unless conformance_classes
75
94
 
76
95
  conformance_classes.each do |cc|
77
96
  cc.tests.each do |ct|
@@ -86,6 +105,8 @@ module Modspec
86
105
  private
87
106
 
88
107
  def resolve_conflicts_for(self_collection, other_collection)
108
+ return if self_collection.nil? || other_collection.nil?
109
+
89
110
  other_collection.each do |other_item|
90
111
  existing_item = self_collection.find { |item| item.identifier == other_item.identifier }
91
112
  if existing_item
@@ -115,18 +136,36 @@ module Modspec
115
136
  cycles.map { |cycle| "Cycle detected: #{cycle.join(" -> ")}" }
116
137
  end
117
138
 
139
+ # Combine all statements into a single array
140
+ # This includes both normative statements and conformance tests
141
+ def all_statements
142
+ nsc = if normative_statements_classes
143
+ normative_statements_classes.flat_map(&:normative_statements)
144
+ else
145
+ []
146
+ end
147
+ cc = if conformance_classes
148
+ conformance_classes.flat_map(&:tests)
149
+ else
150
+ []
151
+ end
152
+
153
+ nsc + cc
154
+ end
155
+
118
156
  def build_dependency_graph
119
157
  graph = {}
120
- all_statements = normative_statements_classes.flat_map(&:normative_statements) +
121
- conformance_classes.flat_map(&:tests)
122
158
 
123
159
  all_statements.each do |statement|
124
160
  id = statement.identifier.to_s
125
161
  graph[id] = Set.new
126
- graph[id].merge(statement.dependencies.map(&:to_s)) if statement.respond_to?(:dependencies)
127
- graph[id].merge(statement.indirect_dependency.map(&:to_s)) if statement.respond_to?(:indirect_dependency)
128
- graph[id].merge(statement.implements.map(&:to_s)) if statement.respond_to?(:implements)
129
- graph[id].merge(statement.targets.map(&:to_s)) if statement.respond_to?(:targets)
162
+
163
+ # Define all dependency-like properties to check
164
+ dependency_properties = %i[dependencies indirect_dependency implements targets]
165
+
166
+ dependency_properties.each do |property|
167
+ graph[id].merge(statement.send(property).map(&:to_s)) if statement.respond_to?(property) && !statement.send(property).nil?
168
+ end
130
169
  end
131
170
 
132
171
  graph
@@ -175,8 +214,6 @@ module Modspec
175
214
  def validate_label_uniqueness
176
215
  labels = {}
177
216
  errors = []
178
- all_statements = normative_statements_classes.flat_map(&:normative_statements) +
179
- conformance_classes.flat_map(&:tests)
180
217
  all_statements.each do |statement|
181
218
  if labels[statement.identifier]
182
219
  errors << "Duplicate identifier found: #{statement.identifier}"
@@ -191,17 +228,21 @@ module Modspec
191
228
  all_identifiers = collect_all_identifiers
192
229
 
193
230
  errors = []
194
- normative_statements_classes.each do |nsc|
195
- errors.concat(validate_class_dependencies(nsc, all_identifiers))
196
- nsc.normative_statements.each do |ns|
197
- errors.concat(validate_statement_dependencies(ns, all_identifiers))
231
+ if normative_statements_classes
232
+ normative_statements_classes.each do |nsc|
233
+ errors.concat(validate_class_dependencies(nsc, all_identifiers))
234
+ nsc.normative_statements.each do |ns|
235
+ errors.concat(validate_statement_dependencies(ns, all_identifiers))
236
+ end
198
237
  end
199
238
  end
200
239
 
201
- conformance_classes.each do |cc|
202
- errors.concat(validate_class_dependencies(cc, all_identifiers))
203
- cc.tests.each do |ct|
204
- errors.concat(validate_test_targets(ct, all_identifiers))
240
+ if conformance_classes
241
+ conformance_classes.each do |cc|
242
+ errors.concat(validate_class_dependencies(cc, all_identifiers))
243
+ cc.tests.each do |ct|
244
+ errors.concat(validate_test_targets(ct, all_identifiers))
245
+ end
205
246
  end
206
247
  end
207
248
 
@@ -211,17 +252,21 @@ module Modspec
211
252
  def collect_all_identifiers
212
253
  identifiers = {}
213
254
 
214
- normative_statements_classes.each do |nsc|
215
- identifiers[nsc.identifier.to_s] = nsc
216
- nsc.normative_statements.each do |ns|
217
- identifiers[ns.identifier.to_s] = ns
255
+ if normative_statements_classes
256
+ normative_statements_classes.each do |nsc|
257
+ identifiers[nsc.identifier.to_s] = nsc
258
+ nsc.normative_statements.each do |ns|
259
+ identifiers[ns.identifier.to_s] = ns
260
+ end
218
261
  end
219
262
  end
220
263
 
221
- conformance_classes.each do |cc|
222
- identifiers[cc.identifier.to_s] = cc
223
- cc.tests.each do |ct|
224
- identifiers[ct.identifier.to_s] = ct
264
+ if conformance_classes
265
+ conformance_classes.each do |cc|
266
+ identifiers[cc.identifier.to_s] = cc
267
+ cc.tests.each do |ct|
268
+ identifiers[ct.identifier.to_s] = ct
269
+ end
225
270
  end
226
271
  end
227
272
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Modspec
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
data/modspec.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
- spec.add_dependency "lutaml-model", "~> 0.6"
32
+ spec.add_dependency "lutaml-model", "~>0.7"
33
33
  spec.add_dependency "nokogiri"
34
34
  spec.add_dependency "toml-rb"
35
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-28 00:00:00.000000000 Z
11
+ date: 2025-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.6'
19
+ version: '0.7'
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.6'
26
+ version: '0.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
- rubygems_version: 3.3.27
155
+ rubygems_version: 3.5.22
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: Library to work with OGC ModSpec.