rsmp 0.48.2 → 0.48.3
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 +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +25 -2
- data/lib/rsmp/convert/export/json_schema/index.rb +38 -17
- data/lib/rsmp/convert/export/json_schema.rb +29 -0
- data/lib/rsmp/version.rb +1 -1
- data/schemas/tlc/1.0.10/commands/M0001.json +4 -4
- data/schemas/tlc/1.0.10/{sxl.yaml → source/sxl.yaml} +60 -63
- data/schemas/tlc/1.0.10/sxl_index.json +3 -3
- data/schemas/tlc/1.0.13/commands/M0001.json +4 -4
- data/schemas/tlc/1.0.13/{sxl.yaml → source/sxl.yaml} +67 -70
- data/schemas/tlc/1.0.13/sxl_index.json +3 -3
- data/schemas/tlc/1.0.14/commands/M0001.json +4 -4
- data/schemas/tlc/1.0.14/{sxl.yaml → source/sxl.yaml} +67 -70
- data/schemas/tlc/1.0.14/sxl_index.json +3 -3
- data/schemas/tlc/1.0.15/commands/M0001.json +4 -4
- data/schemas/tlc/1.0.15/{sxl.yaml → source/sxl.yaml} +70 -73
- data/schemas/tlc/1.0.15/sxl_index.json +3 -3
- data/schemas/tlc/1.0.7/commands/M0001.json +4 -4
- data/schemas/tlc/1.0.7/{sxl.yaml → source/sxl.yaml} +62 -65
- data/schemas/tlc/1.0.7/sxl_index.json +3 -3
- data/schemas/tlc/1.0.8/commands/M0001.json +4 -4
- data/schemas/tlc/1.0.8/{sxl.yaml → source/sxl.yaml} +60 -63
- data/schemas/tlc/1.0.8/sxl_index.json +3 -3
- data/schemas/tlc/1.0.9/commands/M0001.json +4 -4
- data/schemas/tlc/1.0.9/{sxl.yaml → source/sxl.yaml} +60 -63
- data/schemas/tlc/1.0.9/sxl_index.json +3 -3
- data/schemas/tlc/1.1.0/commands/M0022.json +8 -8
- data/schemas/tlc/1.1.0/{sxl.yaml → source/sxl.yaml} +74 -74
- data/schemas/tlc/1.1.0/statuses/S0033.json +2 -2
- data/schemas/tlc/1.1.0/sxl_index.json +10 -10
- data/schemas/tlc/1.2.0/commands/M0022.json +8 -8
- data/schemas/tlc/1.2.0/{sxl.yaml → source/sxl.yaml} +76 -76
- data/schemas/tlc/1.2.0/statuses/S0033.json +2 -2
- data/schemas/tlc/1.2.0/sxl_index.json +10 -10
- data/schemas/tlc/1.2.1/commands/M0022.json +8 -8
- data/schemas/tlc/1.2.1/{sxl.yaml → source/sxl.yaml} +76 -76
- data/schemas/tlc/1.2.1/statuses/S0033.json +2 -2
- data/schemas/tlc/1.2.1/sxl_index.json +10 -10
- data/schemas/tlc/1.3.0/commands/command_requests.json +0 -16
- data/schemas/tlc/1.3.0/{sxl.yaml → source/sxl.yaml} +1 -0
- data/schemas/tlc/1.3.0/sxl_index.json +1 -1
- metadata +12 -17
- data/schemas/tlc/1.0.8/statuses/S0025.json +0 -181
- data/schemas/tlc/1.0.9/statuses/S0025.json +0 -181
- data/schemas/tlc/1.2.0/statuses/S0018.json +0 -61
- data/schemas/tlc/1.2.1/statuses/S0018.json +0 -61
- data/schemas/tlc/1.3.0/statuses/S0018.json +0 -61
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a1022065ed55946e06f4b312bafbc205eeb9c4ab26aab7cd251e682127f1c57
|
|
4
|
+
data.tar.gz: ee0364563ca3b85e39fda32fc6f2e769be26406aab01919c09da5f28da07d02f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2bc65697e462f74a43b3412d7248b36e69cb11c265dc0a66b486528d4f9f86f8a72461c21affc29f9ee7915e1934ca8764ae20c7f8108bec8f0c956d977a2634
|
|
7
|
+
data.tar.gz: 0d886469084cc50a0b03343b9ad098d4a89a8f7e8ed20e9d91d96a194c180d693826c8b035555ec282621a84baa64fb59b6bbf37889e68aa426d3eec0792be8a
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
require 'bundler/gem_tasks'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'open3'
|
|
4
|
+
require 'yaml'
|
|
5
|
+
|
|
6
|
+
require_relative 'lib/rsmp/convert/import/yaml'
|
|
7
|
+
require_relative 'lib/rsmp/convert/export/json_schema'
|
|
2
8
|
|
|
3
9
|
task :test do
|
|
4
10
|
sh 'bundle exec sus'
|
|
@@ -7,6 +13,19 @@ end
|
|
|
7
13
|
CORE_VERSIONS = %w[3.1.2 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.3.0].freeze
|
|
8
14
|
TLC_VERSIONS = %w[1.0.7 1.0.8 1.0.9 1.0.10 1.0.13 1.0.14 1.0.15 1.1.0 1.2.0 1.2.1 1.3.0].freeze
|
|
9
15
|
|
|
16
|
+
def git_show!(repo_path, ref)
|
|
17
|
+
output, status = Open3.capture2e('git', '-C', repo_path, 'show', ref)
|
|
18
|
+
raise "Could not read #{ref} from #{repo_path}:\n#{output}" unless status.success?
|
|
19
|
+
|
|
20
|
+
output
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def require_minimum_core_version!(source_path)
|
|
24
|
+
yaml = YAML.load_file(source_path)
|
|
25
|
+
minimum_core_version = yaml.dig('meta', 'minimum_core_version')
|
|
26
|
+
raise "Missing meta.minimum_core_version in #{source_path}" if minimum_core_version.nil? || minimum_core_version.to_s.empty?
|
|
27
|
+
end
|
|
28
|
+
|
|
10
29
|
# Update vendored schemas from source repos.
|
|
11
30
|
# Usage: rake schemas:update[/path/to/rsmp_core,/path/to/rsmp_sxl_traffic_lights]
|
|
12
31
|
# Defaults to sibling directories ../rsmp_core and ../rsmp_sxl_traffic_lights.
|
|
@@ -32,10 +51,14 @@ namespace :schemas do
|
|
|
32
51
|
puts "Updating TLC schemas from #{tlc_path}:"
|
|
33
52
|
TLC_VERSIONS.each do |ver|
|
|
34
53
|
target = "schemas/tlc/#{ver}"
|
|
54
|
+
source = File.join(target, 'source', 'sxl.yaml')
|
|
35
55
|
puts " #{ver}"
|
|
36
56
|
FileUtils.rm_rf(target)
|
|
37
|
-
FileUtils.mkdir_p(
|
|
38
|
-
|
|
57
|
+
FileUtils.mkdir_p(File.dirname(source))
|
|
58
|
+
File.write(source, git_show!(tlc_path, "refs/heads/#{ver}:schema/sxl.yaml"))
|
|
59
|
+
require_minimum_core_version!(source)
|
|
60
|
+
sxl = RSMP::Convert::Import::YAML.read(source)
|
|
61
|
+
RSMP::Convert::Export::JSONSchema.write(sxl, target)
|
|
39
62
|
end
|
|
40
63
|
end
|
|
41
64
|
end
|
|
@@ -6,56 +6,77 @@ module RSMP
|
|
|
6
6
|
def self.output_sxl_index(out, sxl)
|
|
7
7
|
out['sxl_index.json'] = output_json({
|
|
8
8
|
'meta' => sxl[:meta],
|
|
9
|
-
'statuses' => index_items(sxl[:statuses]),
|
|
10
|
-
'commands' => index_items(sxl[:commands]),
|
|
11
|
-
'alarms' => index_items(sxl[:alarms])
|
|
9
|
+
'statuses' => index_items(sxl[:statuses], legacy_types: legacy_types?(sxl)),
|
|
10
|
+
'commands' => index_items(sxl[:commands], legacy_types: legacy_types?(sxl)),
|
|
11
|
+
'alarms' => index_items(sxl[:alarms], legacy_types: legacy_types?(sxl))
|
|
12
12
|
})
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def self.
|
|
15
|
+
def self.legacy_types?(sxl)
|
|
16
|
+
Gem::Version.new(minimum_core_version(sxl).to_s) < Gem::Version.new('3.3.0')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.index_items(items, legacy_types:)
|
|
16
20
|
items.keys.sort.to_h do |key|
|
|
17
|
-
[key, index_item(items[key])]
|
|
21
|
+
[key, index_item(items[key], legacy_types: legacy_types)]
|
|
18
22
|
end
|
|
19
23
|
end
|
|
20
24
|
|
|
21
|
-
def self.index_item(item)
|
|
25
|
+
def self.index_item(item, legacy_types:)
|
|
22
26
|
arguments = item['arguments'] || {}
|
|
23
27
|
entry = {}
|
|
24
|
-
required = typed_arguments(arguments.reject { |_name, argument| argument['optional'] == true }
|
|
25
|
-
|
|
28
|
+
required = typed_arguments(arguments.reject { |_name, argument| argument['optional'] == true },
|
|
29
|
+
legacy_types: legacy_types)
|
|
30
|
+
optional = typed_arguments(arguments.select { |_name, argument| argument['optional'] == true },
|
|
31
|
+
legacy_types: legacy_types)
|
|
26
32
|
entry['required'] = required unless required.empty?
|
|
27
33
|
entry['optional'] = optional unless optional.empty?
|
|
28
34
|
entry
|
|
29
35
|
end
|
|
30
36
|
|
|
31
|
-
def self.typed_arguments(arguments)
|
|
37
|
+
def self.typed_arguments(arguments, legacy_types:)
|
|
32
38
|
arguments.keys.sort.to_h do |name|
|
|
33
|
-
[name, argument_type_descriptor(arguments[name])]
|
|
39
|
+
[name, argument_type_descriptor(arguments[name], legacy_types: legacy_types)]
|
|
34
40
|
end
|
|
35
41
|
end
|
|
36
42
|
|
|
37
|
-
def self.argument_type_descriptor(argument)
|
|
43
|
+
def self.argument_type_descriptor(argument, legacy_types:)
|
|
38
44
|
type = argument['type']
|
|
39
45
|
case type
|
|
40
46
|
when 'array'
|
|
41
|
-
argument_array_descriptor(argument)
|
|
47
|
+
argument_array_descriptor(argument, legacy_types: legacy_types)
|
|
42
48
|
when 'object'
|
|
43
|
-
argument_object_descriptor(argument)
|
|
49
|
+
argument_object_descriptor(argument, legacy_types: legacy_types)
|
|
50
|
+
else
|
|
51
|
+
legacy_types ? legacy_index_type(type) : type
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.legacy_index_type(type)
|
|
56
|
+
case type
|
|
57
|
+
when 'boolean'
|
|
58
|
+
'boolean_as_string'
|
|
59
|
+
when 'integer'
|
|
60
|
+
'integer_as_string'
|
|
61
|
+
when 'long'
|
|
62
|
+
'long_as_string'
|
|
63
|
+
when 'number'
|
|
64
|
+
'number_as_string'
|
|
44
65
|
else
|
|
45
66
|
type
|
|
46
67
|
end
|
|
47
68
|
end
|
|
48
69
|
|
|
49
|
-
def self.argument_array_descriptor(argument)
|
|
70
|
+
def self.argument_array_descriptor(argument, legacy_types:)
|
|
50
71
|
descriptor = { 'type' => argument['type'] }
|
|
51
|
-
descriptor['items'] = typed_arguments(argument['items']) if argument['items'].is_a?(Hash)
|
|
72
|
+
descriptor['items'] = typed_arguments(argument['items'], legacy_types: legacy_types) if argument['items'].is_a?(Hash)
|
|
52
73
|
descriptor
|
|
53
74
|
end
|
|
54
75
|
|
|
55
|
-
def self.argument_object_descriptor(argument)
|
|
76
|
+
def self.argument_object_descriptor(argument, legacy_types:)
|
|
56
77
|
descriptor = { 'type' => argument['type'] }
|
|
57
78
|
properties = argument['properties'] || argument['items']
|
|
58
|
-
descriptor['properties'] = typed_arguments(properties) if properties.is_a?(Hash)
|
|
79
|
+
descriptor['properties'] = typed_arguments(properties, legacy_types: legacy_types) if properties.is_a?(Hash)
|
|
59
80
|
descriptor
|
|
60
81
|
end
|
|
61
82
|
end
|
|
@@ -43,6 +43,7 @@ module RSMP
|
|
|
43
43
|
|
|
44
44
|
# generate the json schema from a string containing yaml
|
|
45
45
|
def self.generate(sxl)
|
|
46
|
+
sxl = normalize_legacy_types(sxl) if legacy_types?(sxl)
|
|
46
47
|
out = {}
|
|
47
48
|
output_root out, sxl[:meta]
|
|
48
49
|
output_alarms out, sxl[:alarms]
|
|
@@ -52,6 +53,34 @@ module RSMP
|
|
|
52
53
|
out
|
|
53
54
|
end
|
|
54
55
|
|
|
56
|
+
def self.normalize_legacy_types(value)
|
|
57
|
+
case value
|
|
58
|
+
when Hash
|
|
59
|
+
value.each_with_object({}) do |(key, child), memo|
|
|
60
|
+
memo[key] = key == 'type' ? legacy_type(child) : normalize_legacy_types(child)
|
|
61
|
+
end
|
|
62
|
+
when Array
|
|
63
|
+
value.map { |child| normalize_legacy_types(child) }
|
|
64
|
+
else
|
|
65
|
+
value
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def self.legacy_type(type)
|
|
70
|
+
case type
|
|
71
|
+
when 'boolean'
|
|
72
|
+
'boolean_as_string'
|
|
73
|
+
when 'integer'
|
|
74
|
+
'integer_as_string'
|
|
75
|
+
when 'long'
|
|
76
|
+
'long_as_string'
|
|
77
|
+
when 'number'
|
|
78
|
+
'number_as_string'
|
|
79
|
+
else
|
|
80
|
+
type
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
55
84
|
# convert yaml to json schema and write files to a folder
|
|
56
85
|
def self.write(sxl, folder)
|
|
57
86
|
out = generate sxl
|
data/lib/rsmp/version.rb
CHANGED
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"properties" : {
|
|
55
55
|
"v" : {
|
|
56
56
|
"description" : "Security code 2",
|
|
57
|
-
"
|
|
57
|
+
"$ref" : "../defs/definitions.json#/string_list"
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"properties" : {
|
|
72
72
|
"v" : {
|
|
73
73
|
"description" : "Time in minutes until controller automatically reverts to previous functional position.\n0=no automatic return",
|
|
74
|
-
"$ref" : "../defs/definitions.json#/
|
|
74
|
+
"$ref" : "../defs/definitions.json#/integer_list"
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"then" : {
|
|
88
88
|
"properties" : {
|
|
89
89
|
"v" : {
|
|
90
|
-
"description" : "Intersection number
|
|
91
|
-
"$ref" : "../defs/definitions.json#/
|
|
90
|
+
"description" : "Intersection number",
|
|
91
|
+
"$ref" : "../defs/definitions.json#/integer_list"
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|