rsmp_schema 0.2.4 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08fdb15db7535c41ae6420b4879f3100708b779d839871eab1607d672d94edb7'
4
- data.tar.gz: fa0078aa7402d62e429d35ff5f536ce12834c57dab395316b232aeb050c62f2b
3
+ metadata.gz: fda24f8e280bdeeb92c3cb80b62901bfc7215b1612b10d8bfc429d59313bd973
4
+ data.tar.gz: b9845dfc72855ff12949949c85d63c88cbd3d3d9c7e11971e4ed6d02e09bb43b
5
5
  SHA512:
6
- metadata.gz: b145c9e112d584e7402a6e20c32683068381a64e84627f677629e1c482fa83104abc6680a970d8a74451410008900720590815e51cda14e57811e34449f47e2c
7
- data.tar.gz: c8c1d7ee7206be31a2b0665437649fcc8b0a1e4ff2db1f9cba2db2b4d8d0672eaaca7ece9cfe07331aa8796b653e6cce739c074558b8ae1402f94c4127ec4fed
6
+ metadata.gz: bb9ffbae5e2533a9a4cfcd3d5d3fc4791aa2d3b9798f5d30098cf42996b0e18f44176f59b9573a24570634e691c9bf8d9ab48175a66308f8ac9587f201b61aab
7
+ data.tar.gz: 9e0554e11ab58a89b33d349683a66362b7fb4d1a8780cf0f7beca74306a935454441d1990cd6683bcaeb44443540f718e19af7d1e42fa5171ad25e82ffb776a6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp_schema (0.2.4)
4
+ rsmp_schema (0.3.1)
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.4"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -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" : "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.4
4
+ version: 0.3.1
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-26 00:00:00.000000000 Z
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_schemer
@@ -156,6 +156,7 @@ files:
156
156
  - schemas/core/3.2/core.json
157
157
  - schemas/core/3.2/rsmp.json
158
158
  - schemas/core/3.2/status_response.json
159
+ - schemas/core/3.2/status_update.json
159
160
  - schemas/tlc/1.0.10/alarms/A0001.json
160
161
  - schemas/tlc/1.0.10/alarms/A0002.json
161
162
  - schemas/tlc/1.0.10/alarms/A0003.json
@@ -189,6 +190,7 @@ files:
189
190
  - schemas/tlc/1.0.10/commands/command_requests.json
190
191
  - schemas/tlc/1.0.10/commands/command_responses.json
191
192
  - schemas/tlc/1.0.10/commands/commands.json
193
+ - schemas/tlc/1.0.10/rsmp.json
192
194
  - schemas/tlc/1.0.10/statuses/S0001.json
193
195
  - schemas/tlc/1.0.10/statuses/S0002.json
194
196
  - schemas/tlc/1.0.10/statuses/S0003.json
@@ -219,7 +221,6 @@ files:
219
221
  - schemas/tlc/1.0.10/statuses/S0203.json
220
222
  - schemas/tlc/1.0.10/statuses/S0204.json
221
223
  - schemas/tlc/1.0.10/statuses/statuses.json
222
- - schemas/tlc/1.0.10/sxl.json
223
224
  - schemas/tlc/1.0.10/sxl.yaml
224
225
  - schemas/tlc/1.0.13/alarms/A0001.json
225
226
  - schemas/tlc/1.0.13/alarms/A0002.json
@@ -259,6 +260,7 @@ files:
259
260
  - schemas/tlc/1.0.13/commands/command_requests.json
260
261
  - schemas/tlc/1.0.13/commands/command_responses.json
261
262
  - schemas/tlc/1.0.13/commands/commands.json
263
+ - schemas/tlc/1.0.13/rsmp.json
262
264
  - schemas/tlc/1.0.13/statuses/S0001.json
263
265
  - schemas/tlc/1.0.13/statuses/S0002.json
264
266
  - schemas/tlc/1.0.13/statuses/S0003.json
@@ -297,7 +299,6 @@ files:
297
299
  - schemas/tlc/1.0.13/statuses/S0203.json
298
300
  - schemas/tlc/1.0.13/statuses/S0204.json
299
301
  - schemas/tlc/1.0.13/statuses/statuses.json
300
- - schemas/tlc/1.0.13/sxl.json
301
302
  - schemas/tlc/1.0.13/sxl.yaml
302
303
  - schemas/tlc/1.0.14/alarms/A0001.json
303
304
  - schemas/tlc/1.0.14/alarms/A0002.json
@@ -337,6 +338,7 @@ files:
337
338
  - schemas/tlc/1.0.14/commands/command_requests.json
338
339
  - schemas/tlc/1.0.14/commands/command_responses.json
339
340
  - schemas/tlc/1.0.14/commands/commands.json
341
+ - schemas/tlc/1.0.14/rsmp.json
340
342
  - schemas/tlc/1.0.14/statuses/S0001.json
341
343
  - schemas/tlc/1.0.14/statuses/S0002.json
342
344
  - schemas/tlc/1.0.14/statuses/S0003.json
@@ -379,7 +381,6 @@ files:
379
381
  - schemas/tlc/1.0.14/statuses/S0207.json
380
382
  - schemas/tlc/1.0.14/statuses/S0208.json
381
383
  - schemas/tlc/1.0.14/statuses/statuses.json
382
- - schemas/tlc/1.0.14/sxl.json
383
384
  - schemas/tlc/1.0.14/sxl.yaml
384
385
  - schemas/tlc/1.0.15/alarms/A0001.json
385
386
  - schemas/tlc/1.0.15/alarms/A0002.json
@@ -422,6 +423,7 @@ files:
422
423
  - schemas/tlc/1.0.15/commands/command_requests.json
423
424
  - schemas/tlc/1.0.15/commands/command_responses.json
424
425
  - schemas/tlc/1.0.15/commands/commands.json
426
+ - schemas/tlc/1.0.15/rsmp.json
425
427
  - schemas/tlc/1.0.15/statuses/S0001.json
426
428
  - schemas/tlc/1.0.15/statuses/S0002.json
427
429
  - schemas/tlc/1.0.15/statuses/S0003.json
@@ -468,7 +470,6 @@ files:
468
470
  - schemas/tlc/1.0.15/statuses/S0207.json
469
471
  - schemas/tlc/1.0.15/statuses/S0208.json
470
472
  - schemas/tlc/1.0.15/statuses/statuses.json
471
- - schemas/tlc/1.0.15/sxl.json
472
473
  - schemas/tlc/1.0.15/sxl.yaml
473
474
  - schemas/tlc/1.0.7/alarms/A0001.json
474
475
  - schemas/tlc/1.0.7/alarms/A0002.json
@@ -501,6 +502,7 @@ files:
501
502
  - schemas/tlc/1.0.7/commands/command_requests.json
502
503
  - schemas/tlc/1.0.7/commands/command_responses.json
503
504
  - schemas/tlc/1.0.7/commands/commands.json
505
+ - schemas/tlc/1.0.7/rsmp.json
504
506
  - schemas/tlc/1.0.7/statuses/S0001.json
505
507
  - schemas/tlc/1.0.7/statuses/S0002.json
506
508
  - schemas/tlc/1.0.7/statuses/S0003.json
@@ -532,7 +534,6 @@ files:
532
534
  - schemas/tlc/1.0.7/statuses/S0203.json
533
535
  - schemas/tlc/1.0.7/statuses/S0204.json
534
536
  - schemas/tlc/1.0.7/statuses/statuses.json
535
- - schemas/tlc/1.0.7/sxl.json
536
537
  - schemas/tlc/1.0.7/sxl.yaml
537
538
  - schemas/tlc/1.0.8/alarms/A0001.json
538
539
  - schemas/tlc/1.0.8/alarms/A0002.json
@@ -567,6 +568,7 @@ files:
567
568
  - schemas/tlc/1.0.8/commands/command_requests.json
568
569
  - schemas/tlc/1.0.8/commands/command_responses.json
569
570
  - schemas/tlc/1.0.8/commands/commands.json
571
+ - schemas/tlc/1.0.8/rsmp.json
570
572
  - schemas/tlc/1.0.8/statuses/S0001.json
571
573
  - schemas/tlc/1.0.8/statuses/S0002.json
572
574
  - schemas/tlc/1.0.8/statuses/S0003.json
@@ -598,7 +600,6 @@ files:
598
600
  - schemas/tlc/1.0.8/statuses/S0203.json
599
601
  - schemas/tlc/1.0.8/statuses/S0204.json
600
602
  - schemas/tlc/1.0.8/statuses/statuses.json
601
- - schemas/tlc/1.0.8/sxl.json
602
603
  - schemas/tlc/1.0.8/sxl.yaml
603
604
  - schemas/tlc/1.0.9/alarms/A0001.json
604
605
  - schemas/tlc/1.0.9/alarms/A0002.json
@@ -633,6 +634,7 @@ files:
633
634
  - schemas/tlc/1.0.9/commands/command_requests.json
634
635
  - schemas/tlc/1.0.9/commands/command_responses.json
635
636
  - schemas/tlc/1.0.9/commands/commands.json
637
+ - schemas/tlc/1.0.9/rsmp.json
636
638
  - schemas/tlc/1.0.9/statuses/S0001.json
637
639
  - schemas/tlc/1.0.9/statuses/S0002.json
638
640
  - schemas/tlc/1.0.9/statuses/S0003.json
@@ -664,7 +666,6 @@ files:
664
666
  - schemas/tlc/1.0.9/statuses/S0203.json
665
667
  - schemas/tlc/1.0.9/statuses/S0204.json
666
668
  - schemas/tlc/1.0.9/statuses/statuses.json
667
- - schemas/tlc/1.0.9/sxl.json
668
669
  - schemas/tlc/1.0.9/sxl.yaml
669
670
  - schemas/tlc/1.1/alarms/A0001.json
670
671
  - schemas/tlc/1.1/alarms/A0002.json
@@ -711,6 +712,7 @@ files:
711
712
  - schemas/tlc/1.1/commands/command_requests.json
712
713
  - schemas/tlc/1.1/commands/command_responses.json
713
714
  - schemas/tlc/1.1/commands/commands.json
715
+ - schemas/tlc/1.1/rsmp.json
714
716
  - schemas/tlc/1.1/statuses/S0001.json
715
717
  - schemas/tlc/1.1/statuses/S0002.json
716
718
  - schemas/tlc/1.1/statuses/S0003.json
@@ -760,7 +762,6 @@ files:
760
762
  - schemas/tlc/1.1/statuses/S0207.json
761
763
  - schemas/tlc/1.1/statuses/S0208.json
762
764
  - schemas/tlc/1.1/statuses/statuses.json
763
- - schemas/tlc/1.1/sxl.json
764
765
  - schemas/tlc/1.1/sxl.yaml
765
766
  homepage: https://github.com/rsmp-nordic/rsmp_schema
766
767
  licenses: