rsmp_schema 0.2.3 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e82b6ea883b37ce64d134d66ba9980891dd9ecf8f1f7fc12df75df212b77d7a1
4
- data.tar.gz: 242013a26a727cb7ec5281c3e3d60f68e2799999238503ad2701e209fb7112ec
3
+ metadata.gz: 575a89e29f57a294f101abea73f59c22c43d4156ad3b700f5c71bbda7dcbe79b
4
+ data.tar.gz: 2887c0c2f4ccb51ae60f41dfd499035d136317fd5086255c14f26a255d26b365
5
5
  SHA512:
6
- metadata.gz: '046758412e06b7b8ddea3ecb050cd0d0d32d55f901f85b74a2cd1032def20417d7dacdeea9710234730ef2b03b6e29152f230be6ac6eda295154beeaa925b2a5'
7
- data.tar.gz: f27d0648c9023b301caca1a5d311ef02577afe6c8adf54ca07c2ba3dc3b8f71b114dd451a7464e61a93be5d560b6b4a2e07b2c02df15392a60fa6a4d2c777b54
6
+ metadata.gz: 02b3e8b39f2eb04775a6c723bb9b6cffd5e2ab66e987ee77b16c5cfb895a47cf201c1efc557f0a2b90b7e035b8483905f08624999643bcaf823c1614dbefbceb
7
+ data.tar.gz: 99df31b79fe0b7f74f60b441d47d43ad6e8a2ca756907ec0d5f9a61783e5bb3ce4016aa448a731c5825714ea6eae4e62a0fe5e8c9cd684c1ffcce8796c4cb14a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp_schema (0.2.3)
4
+ rsmp_schema (0.3.0)
5
5
  json_schemer (~> 0.2.21)
6
6
  thor (~> 1.2.1)
7
7
 
data/README.md CHANGED
@@ -13,14 +13,14 @@ The schema consists of a core schema shared by all equipment types, and an SXL s
13
13
 
14
14
  Both core and SXL schemas exist in different version, for validation agaist a particular version of the spec.
15
15
 
16
- For example, to validate against the SXL for Trafic Light Controllers (TLCs), version 1.0.15, use the file schemas/tcl/1.0.15/sxl.json.
16
+ For example, to validate against the SXL for Trafic Light Controllers (TLCs), version 1.0.15, use the file schemas/tcl/1.0.15/rsmp.json.
17
17
 
18
18
  Depending on the message type, relevant JSON Schema elements will be included to validate the detailed parameters, arguments, etc.
19
19
 
20
20
  For example, validating a CommandRequest M0001 message will include these parts:
21
21
 
22
22
  ```
23
- sxl.json
23
+ rsmp.json
24
24
  commands.json
25
25
  M0001.json
26
26
  ```
@@ -52,7 +52,7 @@ message = {
52
52
  }
53
53
 
54
54
  # try validating a message against our schema
55
- schema = Pathname.new('schemas/tlc/1.1/sxl.json')
55
+ schema = Pathname.new('schemas/tlc/1.1/rsmp.json')
56
56
  schemer = JSONSchemer.schema(schema)
57
57
  puts schemer.valid? message # => true
58
58
  ```
data/examples/validate.rb CHANGED
@@ -19,7 +19,7 @@ message = {
19
19
  }
20
20
 
21
21
  # try validating a message against our schema
22
- schema = Pathname.new('schema/tlc/sxl.json')
22
+ schema = Pathname.new('schema/tlc/1.1/rsmp.json')
23
23
  schemer = JSONSchemer.schema(schema)
24
24
  if schemer.valid? message
25
25
  puts 'ok'
@@ -242,7 +242,7 @@ module RSMP
242
242
  }
243
243
  ]
244
244
  }
245
- out["sxl.json"] = output_json json
245
+ out["rsmp.json"] = output_json json
246
246
  end
247
247
 
248
248
  # generate the json schema from a string containing yaml
@@ -11,21 +11,41 @@ module RSMP::Schema
11
11
  schemas_path = File.expand_path( File.join(__dir__,'..','..','schemas') )
12
12
  Dir.glob("#{schemas_path}/*").select {|f| File.directory? f}.each do |type_path|
13
13
  type = File.basename(type_path).to_sym
14
- @@schemas[type] = {}
15
- Dir.glob("#{type_path}/*").select {|f| File.directory? f}.each do |schema_path|
16
- version = File.basename(schema_path)
17
- if type == :core
18
- file = 'rsmp.json'
19
- else
20
- file = 'sxl.json'
21
- end
22
- @@schemas[type][version] = JSONSchemer.schema(
23
- Pathname.new(File.join(schema_path,file))
24
- )
25
- end
14
+ load_schema_type type, type_path
15
+ end
16
+ end
17
+
18
+ # load an schema from a folder. schemas are organized by version, and contain
19
+ # json schema files, with the entry point being rsmp.jspon, eg:
20
+ # tlc
21
+ # 1.0.7
22
+ # rsmp.json
23
+ # other jon schema files...
24
+ # 1.0.8
25
+ # ...
26
+ #
27
+ # an error is raised if the schema type already exists, and force is not set to true
28
+ def self.load_schema_type type, type_path, force:false
29
+ raise RuntimeError.new("Schema type #{type} already loaded") if @@schemas[type] && force!=true
30
+ @@schemas[type] = {}
31
+ Dir.glob("#{type_path}/*").select {|f| File.directory? f}.each do |schema_path|
32
+ version = File.basename(schema_path)
33
+ @@schemas[type][version] = JSONSchemer.schema(
34
+ Pathname.new(File.join(schema_path,'rsmp.json'))
35
+ )
26
36
  end
27
37
  end
28
38
 
39
+ # remove a schema type
40
+ def self.remove_schema_type type
41
+ schemas.delete type
42
+ end
43
+
44
+ # get schemas types
45
+ def self.schema_types
46
+ schemas.keys
47
+ end
48
+
29
49
  # get all schemas, oganized by type and version
30
50
  def self.schemas
31
51
  raise RuntimeError.new("No schemas available, perhaps Schema.setup was never called?") unless @@schemas
@@ -1,5 +1,5 @@
1
1
  module RSMP
2
2
  module Schema
3
- VERSION = "0.2.3"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -99,7 +99,7 @@
99
99
  "properties": { "type": { "const": "StatusResponse" } }
100
100
  },
101
101
  "then": {
102
- "$ref": "../3.1.3/status_response.json"
102
+ "$ref": "../3.2/status_response.json"
103
103
  }
104
104
  },
105
105
  {
@@ -126,7 +126,7 @@
126
126
  "properties": { "type": { "const": "StatusUpdate" } }
127
127
  },
128
128
  "then": {
129
- "$ref": "../3.1.3/status_update.json"
129
+ "$ref": "../3.2/status_update.json"
130
130
  }
131
131
  }
132
132
  ]
@@ -0,0 +1,30 @@
1
+ {
2
+ "title" : "StatusResponse",
3
+ "description" : "Status response",
4
+ "properties" : {
5
+ "mId" : { "$ref": "../3.1.1/definitions.json#/message_id" },
6
+ "cId" : { "$ref": "../3.1.1/definitions.json#/component_id" },
7
+ "sTs" : { "$ref": "../3.1.1/definitions.json#/timestamp" },
8
+ "sS" : {
9
+ "description" : "Status response arguments",
10
+ "type" : "array",
11
+ "minItems": 1,
12
+ "items" : {
13
+ "type" : "object",
14
+ "properties": {
15
+ "sCI" : { "$ref": "../3.1.1/definitions.json#/status_code" },
16
+ "n" : { "description" : "Unique reference of the value", "type" : "string" },
17
+ "s" : { "description" : "Value", "type" : ["string"," array"] }, // 3.2 allow arrays
18
+ "q" : {
19
+ "description" : "Value",
20
+ "type" : "string",
21
+ "enum" : [ "recent", "old", "undefined", "unknown" ]
22
+ }
23
+ },
24
+ "required" : [ "sCI", "n", "s", "q" ],
25
+ "additionalProperties": false
26
+ }
27
+ }
28
+ },
29
+ "required" : [ "mId", "cId", "sTs", "sS" ]
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "title" : "StatusUpdate",
3
+ "description" : "Status update",
4
+ "properties" : {
5
+ "mId" : { "$ref": "../3.1.1/definitions.json#/message_id" },
6
+ "cId" : { "$ref": "../3.1.1/definitions.json#/component_id" },
7
+ "sTs" : { "$ref": "../3.1.1/definitions.json#/timestamp" },
8
+ "sS" : {
9
+ "description" : "Status update arguments",
10
+ "type" : "array",
11
+ "minItems": 1,
12
+ "items" : {
13
+ "type" : "object",
14
+ "properties": {
15
+ "sCI" : { "$ref": "../3.1.1/definitions.json#/status_code" },
16
+ "n" : { "description" : "Unique reference of the value", "type" : "string" },
17
+ "s" : { "description" : "Value", "type" : ["string","array"] }, // array is allowed from 3.2
18
+ "q" : {
19
+ "description" : "Value",
20
+ "type" : "string",
21
+ "enum" : [ "recent", "old", "undefined", "unknown" ]
22
+ }
23
+ },
24
+ "required" : [ "sCI", "n", "s", "q" ],
25
+ "additionalProperties": false
26
+ }
27
+ }
28
+ },
29
+ "required" : [ "mId", "cId", "sTs", "sS" ]
30
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsmp_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Tin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-25 00:00:00.000000000 Z
11
+ date: 2022-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_schemer
@@ -155,6 +155,8 @@ files:
155
155
  - schemas/core/3.2/alarm.json
156
156
  - schemas/core/3.2/core.json
157
157
  - schemas/core/3.2/rsmp.json
158
+ - schemas/core/3.2/status_response.json
159
+ - schemas/core/3.2/status_update.json
158
160
  - schemas/tlc/1.0.10/alarms/A0001.json
159
161
  - schemas/tlc/1.0.10/alarms/A0002.json
160
162
  - schemas/tlc/1.0.10/alarms/A0003.json
@@ -188,6 +190,7 @@ files:
188
190
  - schemas/tlc/1.0.10/commands/command_requests.json
189
191
  - schemas/tlc/1.0.10/commands/command_responses.json
190
192
  - schemas/tlc/1.0.10/commands/commands.json
193
+ - schemas/tlc/1.0.10/rsmp.json
191
194
  - schemas/tlc/1.0.10/statuses/S0001.json
192
195
  - schemas/tlc/1.0.10/statuses/S0002.json
193
196
  - schemas/tlc/1.0.10/statuses/S0003.json
@@ -218,7 +221,6 @@ files:
218
221
  - schemas/tlc/1.0.10/statuses/S0203.json
219
222
  - schemas/tlc/1.0.10/statuses/S0204.json
220
223
  - schemas/tlc/1.0.10/statuses/statuses.json
221
- - schemas/tlc/1.0.10/sxl.json
222
224
  - schemas/tlc/1.0.10/sxl.yaml
223
225
  - schemas/tlc/1.0.13/alarms/A0001.json
224
226
  - schemas/tlc/1.0.13/alarms/A0002.json
@@ -258,6 +260,7 @@ files:
258
260
  - schemas/tlc/1.0.13/commands/command_requests.json
259
261
  - schemas/tlc/1.0.13/commands/command_responses.json
260
262
  - schemas/tlc/1.0.13/commands/commands.json
263
+ - schemas/tlc/1.0.13/rsmp.json
261
264
  - schemas/tlc/1.0.13/statuses/S0001.json
262
265
  - schemas/tlc/1.0.13/statuses/S0002.json
263
266
  - schemas/tlc/1.0.13/statuses/S0003.json
@@ -296,7 +299,6 @@ files:
296
299
  - schemas/tlc/1.0.13/statuses/S0203.json
297
300
  - schemas/tlc/1.0.13/statuses/S0204.json
298
301
  - schemas/tlc/1.0.13/statuses/statuses.json
299
- - schemas/tlc/1.0.13/sxl.json
300
302
  - schemas/tlc/1.0.13/sxl.yaml
301
303
  - schemas/tlc/1.0.14/alarms/A0001.json
302
304
  - schemas/tlc/1.0.14/alarms/A0002.json
@@ -336,6 +338,7 @@ files:
336
338
  - schemas/tlc/1.0.14/commands/command_requests.json
337
339
  - schemas/tlc/1.0.14/commands/command_responses.json
338
340
  - schemas/tlc/1.0.14/commands/commands.json
341
+ - schemas/tlc/1.0.14/rsmp.json
339
342
  - schemas/tlc/1.0.14/statuses/S0001.json
340
343
  - schemas/tlc/1.0.14/statuses/S0002.json
341
344
  - schemas/tlc/1.0.14/statuses/S0003.json
@@ -378,7 +381,6 @@ files:
378
381
  - schemas/tlc/1.0.14/statuses/S0207.json
379
382
  - schemas/tlc/1.0.14/statuses/S0208.json
380
383
  - schemas/tlc/1.0.14/statuses/statuses.json
381
- - schemas/tlc/1.0.14/sxl.json
382
384
  - schemas/tlc/1.0.14/sxl.yaml
383
385
  - schemas/tlc/1.0.15/alarms/A0001.json
384
386
  - schemas/tlc/1.0.15/alarms/A0002.json
@@ -421,6 +423,7 @@ files:
421
423
  - schemas/tlc/1.0.15/commands/command_requests.json
422
424
  - schemas/tlc/1.0.15/commands/command_responses.json
423
425
  - schemas/tlc/1.0.15/commands/commands.json
426
+ - schemas/tlc/1.0.15/rsmp.json
424
427
  - schemas/tlc/1.0.15/statuses/S0001.json
425
428
  - schemas/tlc/1.0.15/statuses/S0002.json
426
429
  - schemas/tlc/1.0.15/statuses/S0003.json
@@ -467,7 +470,6 @@ files:
467
470
  - schemas/tlc/1.0.15/statuses/S0207.json
468
471
  - schemas/tlc/1.0.15/statuses/S0208.json
469
472
  - schemas/tlc/1.0.15/statuses/statuses.json
470
- - schemas/tlc/1.0.15/sxl.json
471
473
  - schemas/tlc/1.0.15/sxl.yaml
472
474
  - schemas/tlc/1.0.7/alarms/A0001.json
473
475
  - schemas/tlc/1.0.7/alarms/A0002.json
@@ -500,6 +502,7 @@ files:
500
502
  - schemas/tlc/1.0.7/commands/command_requests.json
501
503
  - schemas/tlc/1.0.7/commands/command_responses.json
502
504
  - schemas/tlc/1.0.7/commands/commands.json
505
+ - schemas/tlc/1.0.7/rsmp.json
503
506
  - schemas/tlc/1.0.7/statuses/S0001.json
504
507
  - schemas/tlc/1.0.7/statuses/S0002.json
505
508
  - schemas/tlc/1.0.7/statuses/S0003.json
@@ -531,7 +534,6 @@ files:
531
534
  - schemas/tlc/1.0.7/statuses/S0203.json
532
535
  - schemas/tlc/1.0.7/statuses/S0204.json
533
536
  - schemas/tlc/1.0.7/statuses/statuses.json
534
- - schemas/tlc/1.0.7/sxl.json
535
537
  - schemas/tlc/1.0.7/sxl.yaml
536
538
  - schemas/tlc/1.0.8/alarms/A0001.json
537
539
  - schemas/tlc/1.0.8/alarms/A0002.json
@@ -566,6 +568,7 @@ files:
566
568
  - schemas/tlc/1.0.8/commands/command_requests.json
567
569
  - schemas/tlc/1.0.8/commands/command_responses.json
568
570
  - schemas/tlc/1.0.8/commands/commands.json
571
+ - schemas/tlc/1.0.8/rsmp.json
569
572
  - schemas/tlc/1.0.8/statuses/S0001.json
570
573
  - schemas/tlc/1.0.8/statuses/S0002.json
571
574
  - schemas/tlc/1.0.8/statuses/S0003.json
@@ -597,7 +600,6 @@ files:
597
600
  - schemas/tlc/1.0.8/statuses/S0203.json
598
601
  - schemas/tlc/1.0.8/statuses/S0204.json
599
602
  - schemas/tlc/1.0.8/statuses/statuses.json
600
- - schemas/tlc/1.0.8/sxl.json
601
603
  - schemas/tlc/1.0.8/sxl.yaml
602
604
  - schemas/tlc/1.0.9/alarms/A0001.json
603
605
  - schemas/tlc/1.0.9/alarms/A0002.json
@@ -632,6 +634,7 @@ files:
632
634
  - schemas/tlc/1.0.9/commands/command_requests.json
633
635
  - schemas/tlc/1.0.9/commands/command_responses.json
634
636
  - schemas/tlc/1.0.9/commands/commands.json
637
+ - schemas/tlc/1.0.9/rsmp.json
635
638
  - schemas/tlc/1.0.9/statuses/S0001.json
636
639
  - schemas/tlc/1.0.9/statuses/S0002.json
637
640
  - schemas/tlc/1.0.9/statuses/S0003.json
@@ -663,7 +666,6 @@ files:
663
666
  - schemas/tlc/1.0.9/statuses/S0203.json
664
667
  - schemas/tlc/1.0.9/statuses/S0204.json
665
668
  - schemas/tlc/1.0.9/statuses/statuses.json
666
- - schemas/tlc/1.0.9/sxl.json
667
669
  - schemas/tlc/1.0.9/sxl.yaml
668
670
  - schemas/tlc/1.1/alarms/A0001.json
669
671
  - schemas/tlc/1.1/alarms/A0002.json
@@ -710,6 +712,7 @@ files:
710
712
  - schemas/tlc/1.1/commands/command_requests.json
711
713
  - schemas/tlc/1.1/commands/command_responses.json
712
714
  - schemas/tlc/1.1/commands/commands.json
715
+ - schemas/tlc/1.1/rsmp.json
713
716
  - schemas/tlc/1.1/statuses/S0001.json
714
717
  - schemas/tlc/1.1/statuses/S0002.json
715
718
  - schemas/tlc/1.1/statuses/S0003.json
@@ -759,7 +762,6 @@ files:
759
762
  - schemas/tlc/1.1/statuses/S0207.json
760
763
  - schemas/tlc/1.1/statuses/S0208.json
761
764
  - schemas/tlc/1.1/statuses/statuses.json
762
- - schemas/tlc/1.1/sxl.json
763
765
  - schemas/tlc/1.1/sxl.yaml
764
766
  homepage: https://github.com/rsmp-nordic/rsmp_schema
765
767
  licenses: