rsmp_schema 0.10.0 → 0.10.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 +4 -4
- data/.rubocop.yml +55 -0
- data/Gemfile +13 -1
- data/Gemfile.lock +80 -3
- data/Rakefile +4 -4
- data/examples/validate.rb +14 -14
- data/lib/rsmp_schema/cli.rb +31 -23
- data/lib/rsmp_schema/convert/export/json_schema.rb +193 -182
- data/lib/rsmp_schema/convert/import/yaml.rb +17 -19
- data/lib/rsmp_schema/error.rb +14 -8
- data/lib/rsmp_schema/schema.rb +175 -165
- data/lib/rsmp_schema/version.rb +3 -2
- data/lib/rsmp_schema.rb +2 -2
- data/rsmp_schema.gemspec +19 -21
- metadata +3 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0579ab443900805112f5375443998cee0bb6e2519d0ac14240fd596b0662d37
|
|
4
|
+
data.tar.gz: 23f4c0411c5b3a823af27c1ff4ac4b9228cb41dd57c31e6bcac13a3ef5580941
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a33b36f1c75147d6d222e4d519ad0952f96cb20ddc8cae33106bfd6959c952bc541148d5e61215fe706e0c5461dc8fceb2699c8e61e9c31dcfb7da2e2402c508
|
|
7
|
+
data.tar.gz: 5d238fe7f584fe68c4282fce2dfc11c68a04171828239c1828f622314f7ee0aa1604b1a4526d056f8d9346141e0173429b145da9887a77f6800cab1dccf267cb
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-rspec
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
NewCops: enable
|
|
6
|
+
SuggestExtensions: false
|
|
7
|
+
Exclude:
|
|
8
|
+
- 'vendor/**/*'
|
|
9
|
+
|
|
10
|
+
# Allow longer line lengths for tests with long JSON strings
|
|
11
|
+
Layout/LineLength:
|
|
12
|
+
Exclude:
|
|
13
|
+
- 'spec/**/*'
|
|
14
|
+
|
|
15
|
+
# Allow some reasonable flexibility for domain-specific code
|
|
16
|
+
Metrics/MethodLength:
|
|
17
|
+
Max: 25
|
|
18
|
+
|
|
19
|
+
Metrics/ClassLength:
|
|
20
|
+
Max: 200
|
|
21
|
+
|
|
22
|
+
Metrics/ModuleLength:
|
|
23
|
+
Max: 300
|
|
24
|
+
|
|
25
|
+
Metrics/AbcSize:
|
|
26
|
+
Max: 20
|
|
27
|
+
|
|
28
|
+
Metrics/CyclomaticComplexity:
|
|
29
|
+
Max: 10
|
|
30
|
+
|
|
31
|
+
Metrics/PerceivedComplexity:
|
|
32
|
+
Max: 10
|
|
33
|
+
|
|
34
|
+
# These specs often have multiple expectations to verify the behavior of a feature end-to-end.
|
|
35
|
+
RSpec/MultipleExpectations:
|
|
36
|
+
Enabled: false
|
|
37
|
+
|
|
38
|
+
RSpec/ExampleLength:
|
|
39
|
+
Max: 40
|
|
40
|
+
|
|
41
|
+
# Integration/schema specs describe features, not a specific class
|
|
42
|
+
RSpec/DescribeClass:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
# RSMP signal IDs use uppercase (M0001, A0303, S0007, etc.)
|
|
46
|
+
Naming/FileName:
|
|
47
|
+
Enabled: false
|
|
48
|
+
|
|
49
|
+
# Version strings in let names are meaningful (message_v3_1_2 etc.)
|
|
50
|
+
Naming/VariableNumber:
|
|
51
|
+
EnforcedStyle: snake_case
|
|
52
|
+
|
|
53
|
+
# frozen string literals is on by default from Ruby 3.4
|
|
54
|
+
Style/FrozenStringLiteralComment:
|
|
55
|
+
Enabled: false
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
source
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
# Specify your gem's dependencies in rsmp_schema.gemspec
|
|
4
4
|
gemspec
|
|
5
|
+
|
|
6
|
+
group :development do
|
|
7
|
+
gem 'bundler', '~> 4.0'
|
|
8
|
+
gem 'cucumber', '~> 9.2'
|
|
9
|
+
gem 'rake', '~> 13.2'
|
|
10
|
+
gem 'rspec', '~> 3.13'
|
|
11
|
+
gem 'rspec-expectations', '~> 3.13'
|
|
12
|
+
gem 'rubocop', '~> 1.65'
|
|
13
|
+
gem 'rubocop-rake', require: false
|
|
14
|
+
gem 'rubocop-rspec', require: false
|
|
15
|
+
gem 'timecop', '~> 0.9'
|
|
16
|
+
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,21 +1,63 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rsmp_schema (0.10.
|
|
4
|
+
rsmp_schema (0.10.1)
|
|
5
5
|
json_schemer (~> 2.5)
|
|
6
6
|
thor (~> 1.5)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
+
ast (2.4.3)
|
|
11
12
|
bigdecimal (4.0.1)
|
|
13
|
+
builder (3.3.0)
|
|
14
|
+
cucumber (9.2.1)
|
|
15
|
+
builder (~> 3.2)
|
|
16
|
+
cucumber-ci-environment (> 9, < 11)
|
|
17
|
+
cucumber-core (> 13, < 14)
|
|
18
|
+
cucumber-cucumber-expressions (~> 17.0)
|
|
19
|
+
cucumber-gherkin (> 24, < 28)
|
|
20
|
+
cucumber-html-formatter (> 20.3, < 22)
|
|
21
|
+
cucumber-messages (> 19, < 25)
|
|
22
|
+
diff-lcs (~> 1.5)
|
|
23
|
+
mini_mime (~> 1.1)
|
|
24
|
+
multi_test (~> 1.1)
|
|
25
|
+
sys-uname (~> 1.2)
|
|
26
|
+
cucumber-ci-environment (10.0.1)
|
|
27
|
+
cucumber-core (13.0.3)
|
|
28
|
+
cucumber-gherkin (>= 27, < 28)
|
|
29
|
+
cucumber-messages (>= 20, < 23)
|
|
30
|
+
cucumber-tag-expressions (> 5, < 7)
|
|
31
|
+
cucumber-cucumber-expressions (17.1.0)
|
|
32
|
+
bigdecimal
|
|
33
|
+
cucumber-gherkin (27.0.0)
|
|
34
|
+
cucumber-messages (>= 19.1.4, < 23)
|
|
35
|
+
cucumber-html-formatter (21.15.1)
|
|
36
|
+
cucumber-messages (> 19, < 28)
|
|
37
|
+
cucumber-messages (22.0.0)
|
|
38
|
+
cucumber-tag-expressions (6.1.2)
|
|
12
39
|
diff-lcs (1.6.2)
|
|
40
|
+
ffi (1.17.4)
|
|
41
|
+
ffi (1.17.4-x86_64-darwin)
|
|
13
42
|
hana (1.3.7)
|
|
43
|
+
json (2.19.3)
|
|
14
44
|
json_schemer (2.5.0)
|
|
15
45
|
bigdecimal
|
|
16
46
|
hana (~> 1.3)
|
|
17
47
|
regexp_parser (~> 2.0)
|
|
18
48
|
simpleidn (~> 0.2)
|
|
49
|
+
language_server-protocol (3.17.0.5)
|
|
50
|
+
lint_roller (1.1.0)
|
|
51
|
+
memoist3 (1.0.0)
|
|
52
|
+
mini_mime (1.1.5)
|
|
53
|
+
multi_test (1.1.0)
|
|
54
|
+
parallel (1.27.0)
|
|
55
|
+
parser (3.3.11.1)
|
|
56
|
+
ast (~> 2.4.1)
|
|
57
|
+
racc
|
|
58
|
+
prism (1.9.0)
|
|
59
|
+
racc (1.8.1)
|
|
60
|
+
rainbow (3.1.1)
|
|
19
61
|
rake (13.3.1)
|
|
20
62
|
regexp_parser (2.11.3)
|
|
21
63
|
rspec (3.13.2)
|
|
@@ -31,17 +73,52 @@ GEM
|
|
|
31
73
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
32
74
|
rspec-support (~> 3.13.0)
|
|
33
75
|
rspec-support (3.13.7)
|
|
76
|
+
rubocop (1.86.0)
|
|
77
|
+
json (~> 2.3)
|
|
78
|
+
language_server-protocol (~> 3.17.0.2)
|
|
79
|
+
lint_roller (~> 1.1.0)
|
|
80
|
+
parallel (~> 1.10)
|
|
81
|
+
parser (>= 3.3.0.2)
|
|
82
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
83
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
84
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
85
|
+
ruby-progressbar (~> 1.7)
|
|
86
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
87
|
+
rubocop-ast (1.49.1)
|
|
88
|
+
parser (>= 3.3.7.2)
|
|
89
|
+
prism (~> 1.7)
|
|
90
|
+
rubocop-rake (0.7.1)
|
|
91
|
+
lint_roller (~> 1.1)
|
|
92
|
+
rubocop (>= 1.72.1)
|
|
93
|
+
rubocop-rspec (3.9.0)
|
|
94
|
+
lint_roller (~> 1.1)
|
|
95
|
+
rubocop (~> 1.81)
|
|
96
|
+
ruby-progressbar (1.13.0)
|
|
34
97
|
simpleidn (0.2.3)
|
|
98
|
+
sys-uname (1.5.1)
|
|
99
|
+
ffi (~> 1.1)
|
|
100
|
+
memoist3 (~> 1.0.0)
|
|
35
101
|
thor (1.5.0)
|
|
102
|
+
timecop (0.9.10)
|
|
103
|
+
unicode-display_width (3.2.0)
|
|
104
|
+
unicode-emoji (~> 4.1)
|
|
105
|
+
unicode-emoji (4.2.0)
|
|
36
106
|
|
|
37
107
|
PLATFORMS
|
|
38
108
|
ruby
|
|
109
|
+
x86_64-darwin-22
|
|
39
110
|
|
|
40
111
|
DEPENDENCIES
|
|
41
|
-
|
|
112
|
+
bundler (~> 4.0)
|
|
113
|
+
cucumber (~> 9.2)
|
|
114
|
+
rake (~> 13.2)
|
|
42
115
|
rsmp_schema!
|
|
43
116
|
rspec (~> 3.13)
|
|
44
117
|
rspec-expectations (~> 3.13)
|
|
118
|
+
rubocop (~> 1.65)
|
|
119
|
+
rubocop-rake
|
|
120
|
+
rubocop-rspec
|
|
121
|
+
timecop (~> 0.9)
|
|
45
122
|
|
|
46
123
|
BUNDLED WITH
|
|
47
|
-
|
|
124
|
+
4.0.9
|
data/Rakefile
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
require "bundler/gem_tasks"
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "rsmp_schema"
|
|
5
2
|
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'rsmp_schema'
|
|
6
6
|
|
|
7
7
|
task default: %i[]
|
|
8
8
|
|
|
9
9
|
# Regenerate all SXL JSON Schemas.
|
|
10
10
|
# Warning: This will destructively override all relevant files. Any changes will be lost!
|
|
11
11
|
task :regenerate do
|
|
12
|
-
puts
|
|
12
|
+
puts 'Regenerating SXL JSON Schemas:'
|
|
13
13
|
Dir.glob('schemas/tlc/*/sxl.yaml').each do |path|
|
|
14
14
|
puts " #{File.dirname(path)}"
|
|
15
15
|
sxl = RSMP::Convert::Import::YAML.read path
|
data/examples/validate.rb
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
require 'rsmp_schema'
|
|
2
2
|
|
|
3
3
|
message = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
{
|
|
4
|
+
'mType' => 'rSMsg',
|
|
5
|
+
'mId' => '4173c2c8-a933-43cb-9425-66d4613731ed',
|
|
6
|
+
'type' => 'CommandRequest',
|
|
7
|
+
'siteId' => [
|
|
8
|
+
{ 'sId' => 'RN+SI0001' }
|
|
9
9
|
],
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
'cId' => 'O+14439=481WA001',
|
|
11
|
+
'arg' => [
|
|
12
12
|
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
'cCI' => 'M0002',
|
|
14
|
+
'n' => 'timeplan',
|
|
15
|
+
'cO' => 'setPlan',
|
|
16
|
+
'v' => '1'
|
|
17
17
|
}
|
|
18
18
|
]
|
|
19
19
|
}
|
|
@@ -21,9 +21,9 @@ message = {
|
|
|
21
21
|
# load schemas
|
|
22
22
|
RSMP::Schema.setup
|
|
23
23
|
|
|
24
|
-
# validating a message against core and tlc schemas
|
|
25
|
-
result = RSMP::Schema.validate(
|
|
26
|
-
if result
|
|
24
|
+
# validating a message against core and tlc schemas
|
|
25
|
+
result = RSMP::Schema.validate(message, core: '3.2.1', tlc: '1.2.1')
|
|
26
|
+
if result.nil?
|
|
27
27
|
puts 'ok'
|
|
28
28
|
else
|
|
29
29
|
puts "failed: #{result.inspect}"
|
data/lib/rsmp_schema/cli.rb
CHANGED
|
@@ -1,35 +1,43 @@
|
|
|
1
1
|
require 'thor'
|
|
2
2
|
require 'rsmp_schema'
|
|
3
3
|
|
|
4
|
-
module RSMP
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
module RSMP
|
|
5
|
+
module Schema
|
|
6
|
+
# Command-line interface for rsmp_schema tools.
|
|
7
|
+
class CLI < Thor
|
|
8
|
+
desc 'convert', 'Convert SXL from YAML to JSON Schema'
|
|
9
|
+
method_option :in, type: :string, aliases: '-i', banner: 'Path to YAML input file'
|
|
10
|
+
method_option :out, type: :string, aliases: '-o', banner: 'Path to JSON Schema output file'
|
|
11
|
+
def convert
|
|
12
|
+
validate_convert_options!
|
|
13
|
+
sxl = RSMP::Convert::Import::YAML.read options[:in]
|
|
14
|
+
RSMP::Convert::Export::JSONSchema.write sxl, options[:out]
|
|
13
15
|
end
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
# avoid Thor returnin 0 on failures, see
|
|
18
|
+
# https://github.com/coinbase/salus/pull/380/files
|
|
19
|
+
def self.exit_on_failure?
|
|
20
|
+
true
|
|
18
21
|
end
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def validate_convert_options!
|
|
26
|
+
unless options[:in]
|
|
27
|
+
puts 'Error: Input option missing'
|
|
28
|
+
exit
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
unless options[:out]
|
|
32
|
+
puts 'Error: Output option missing'
|
|
33
|
+
exit
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
return if File.exist? options[:in]
|
|
37
|
+
|
|
21
38
|
puts "Error: Input path file #{options[:in]} not found"
|
|
22
39
|
exit
|
|
23
40
|
end
|
|
24
|
-
|
|
25
|
-
sxl = RSMP::Convert::Import::YAML.read options[:in]
|
|
26
|
-
RSMP::Convert::Export::JSONSchema.write sxl, options[:out]
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# avoid Thor returnin 0 on failures, see
|
|
30
|
-
# https://github.com/coinbase/salus/pull/380/files
|
|
31
|
-
def self.exit_on_failure?
|
|
32
|
-
true
|
|
33
41
|
end
|
|
34
42
|
end
|
|
35
|
-
end
|
|
43
|
+
end
|