rsmp_schema 0.8.8 → 0.8.9

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: c39b6ab3cc486788feee182e2a9ba6332f01ba1597c5218fdc84f0f4f94fdb7e
4
- data.tar.gz: daa378692c4caa3fdb08364a6aa109932d8eb1a06ec8be358342ccf781415f56
3
+ metadata.gz: e3d517e40ea10e09d966c92de4c6b80f4ca7fef46d455ad0cb1ae729d487801c
4
+ data.tar.gz: 17885aac6cd969bce5a059210658dee89fea7313641d28b45b1b05b526725283
5
5
  SHA512:
6
- metadata.gz: 2e7be3449e7693476a04de6308f7c74b02bd541e3d5cab3ba9fb9a1c8c58b3a48f554e3dafc84405ea41bdefdd9b2d7864a4d8fccc4c73887ead041fc5b0add4
7
- data.tar.gz: 541cb7f75d8169442c6c081f56f679e81e66916be07b0d6c77729d08f7bb3d3141db20f1993b2952f90e4815a6f67bf2ae463351d1c3cf23a09280d369f3e81a
6
+ metadata.gz: e1d6261fc9b66f618996b82aedffec5499928686d737d4fcec33430c67486b82120a8d4d35612b18fa421b3f38f91462f3641d08bb7b4eba38f0f693e434ce97
7
+ data.tar.gz: b44020651b67f07b26a9a1907ca81b346a48d0be1f384cf8d60c870e3aa08ba472dd886390ef06c2434f24310e434ed327d74526a90b9a55d67c08a0d775f2ac
@@ -0,0 +1,22 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3
+ {
4
+ "name": "Ruby",
5
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
+ "image": "mcr.microsoft.com/devcontainers/ruby:1-3.4-bullseye",
7
+
8
+ // Features to add to the dev container. More info: https://containers.dev/features.
9
+ // "features": {},
10
+
11
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
12
+ // "forwardPorts": [],
13
+
14
+ // Use 'postCreateCommand' to run commands after the container is created.
15
+ "postCreateCommand": "bundle install"
16
+
17
+ // Configure tool-specific properties.
18
+ // "customizations": {},
19
+
20
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
21
+ // "remoteUser": "root"
22
+ }
@@ -0,0 +1,197 @@
1
+ # RSMP Schema Ruby Gem
2
+
3
+ RSMP Schema is a Ruby gem that provides JSON Schema validation for RSMP (Road Side Message Protocol) messages. The schema covers both the core RSMP specification and SXL (Signal Exchange List) for Traffic Light Controllers.
4
+
5
+ Always reference these instructions first, and fall back to search or bash commands only when you encounter unexpected information that does not match the info here.
6
+
7
+ ## Environment Setup
8
+ Copilot Agent runs in a minimal Docker container, NOT the devcontainer specified in .devcontainer.
9
+
10
+ Ruby will be available, but bundler and gems must be installed.
11
+ The Ruby version migh not match what's specified in .tool-versions, but it should still be possible to work in the repo
12
+
13
+ ## Installing bundler
14
+ The bundler gem itself is usually included in modern Ruby distributions, but it's NOT included in the copilot agent container, so always install with:
15
+
16
+ ```sh
17
+ gem install bundler --install-dir ~/.local/share/gem
18
+ ```
19
+
20
+ Add gem executables to the PATH so they can be found:
21
+ ```sh
22
+ export PATH="$HOME/.local/share/gem/bin:$PATH"
23
+ ```
24
+
25
+ ## Installing Gems
26
+ Always use the bundler `path` config to install gems in the user’s local directory:
27
+ ```sh
28
+ bundle config set --local path ~/.local/share/gem
29
+ bundle install
30
+ ```
31
+
32
+ ## Using Gem Executables
33
+ Always use 'bundle exec' to run executable from gems.
34
+
35
+ ## Running Tests
36
+ The test suite includes comprehensive RSpec tests covering:
37
+ - Core RSMP message validation
38
+ - Traffic Light Controller SXL validation
39
+
40
+ Run the complete test suite:
41
+ ```bash
42
+ # Test command takes approximately 2 seconds
43
+ bundle exec rspec
44
+ ```
45
+
46
+ All tests should pass on a clean repository.
47
+
48
+ ## CLI Tool Usage
49
+ The gem provides a CLI tool for converting YAML SXL files to JSON Schema:
50
+
51
+ ```bash
52
+ # Show available commands
53
+ bundle exec exe/rsmp_schema --help
54
+
55
+ # Convert YAML SXL to JSON Schema
56
+ bundle exec exe/rsmp_schema convert -i <input.yaml> -o <output_directory>
57
+
58
+ # Example: Convert TLC SXL
59
+ bundle exec exe/rsmp_schema convert -i schemas/tlc/1.2.1/sxl.yaml -o tmp/sxl_1.2.1_schema
60
+ ```
61
+
62
+ ## Schema Regeneration
63
+ Regenerate all TLC JSON schemas from their YAML sources:
64
+
65
+ ```bash
66
+ # Regenerates all schemas in schemas/tlc/*/sxl.yaml
67
+ bundle exec rake regenerate
68
+ ```
69
+
70
+ **WARNING**: This destructively overwrites all JSON schema files in schemas/tlc/. Core schemas are not affected as they are hand-maintained.
71
+
72
+ This rake task and the 'convert' CLI command use the same Ruby code to convert YAML to JSON schema files.
73
+
74
+
75
+ ## Example code
76
+ The file examples/validate.rb shows how to use the gem to validate RSMP messages.
77
+
78
+ Before committing changes, in addition to checking that all RSpec tests pass, also check that the examples/validate.rb script works and outputs the expected result:
79
+
80
+ ```bash
81
+ # Test validation with corrected example script
82
+ bundle exec ruby examples/validate.rb
83
+ ```
84
+
85
+ Expected output: `ok` (indicates successful validation)
86
+
87
+ ## Repository Structure
88
+ Key directories and files:
89
+ - `lib/rsmp_schema/` - Main gem code
90
+ - `lib/rsmp_schema/cli.rb` - CLI tool implementation
91
+ - `lib/rsmp_schema/convert/` - YAML to JSON Schema conversion
92
+ - `exe/rsmp_schema` - Executable CLI wrapper
93
+ - `spec/` - RSpec test files
94
+ - `schemas/core/` - Hand-maintained core RSMP schemas
95
+ - `schemas/tlc/` - Generated Traffic Light Controller schemas
96
+ - `examples/validate.rb` - Example validation code
97
+ - `Rakefile` - Contains regenerate task
98
+ - `.github/workflows/rspec.yaml` - CI pipeline
99
+
100
+ ## Common File Locations
101
+
102
+ ### Schema Files
103
+ - Core schemas: `schemas/core/<version>/rsmp.json`
104
+ - TLC SXL schemas: `schemas/tlc/<version>/rsmp.json`
105
+ - TLC SXL YAML sources: `schemas/tlc/<version>/sxl.yaml`
106
+
107
+ ### Code Files
108
+ - Main entry: `lib/rsmp_schema.rb`
109
+ - CLI: `lib/rsmp_schema/cli.rb`
110
+
111
+ ### Test Files
112
+ - Core tests: `spec/core/`
113
+ - TLC tests: `spec/tlc/`
114
+ - Helper: `spec/schemer_helper.rb`
115
+
116
+ ## CI Pipeline Validation
117
+ The repository uses GitHub Actions with the following requirements:
118
+ - Runs on Ubuntu, macOS, and Windows
119
+ - Tests with different Ruby versions
120
+ - 5-minute timeout for all tests
121
+ - Must pass `bundle exec rspec -f d`
122
+
123
+ Before committing changes, ensure:
124
+ - Schemas are regenerated if any SXL YAML sources were modified
125
+ - All tests pass: `bundle exec rspec`
126
+ - Ruby syntax is valid for modified files
127
+
128
+ ## Validation Scenarios
129
+ After making changes, always test these scenarios:
130
+
131
+ 1. **Schema regeneration**: Run `bundle exec rake regenerate` and verify no unexpected changes.
132
+ 2. **Test suite**: Run `bundle exec rspec` and ensure all tests pass.
133
+ 3. **Example code**: Ensure the examples in examples/ work correctly.
134
+ 4. **CLI functionality**: Test the convert command with actual files.
135
+ 5. **No unrelated changes**: No unrelated changes or files should be included in the commit.
136
+
137
+ Example validation workflow:
138
+
139
+ ```bash
140
+ # Ensure we're in root of the repo folder
141
+ cd /path/to/repo
142
+
143
+ # Regenerate schema files if SXL YAML sources were modified
144
+ # And check that no unexpected changes were introduced
145
+ bundle exec rake regenerate
146
+ git status -- schemas/
147
+
148
+ # Run test suite
149
+ bundle exec rspec
150
+
151
+ # Check example code
152
+ bundle exec ruby examples/validate.rb
153
+
154
+ # Check CLI functionality
155
+ # And check that output contains expected files
156
+ bundle exec exe/rsmp_schema convert -i schemas/tlc/1.2.1/sxl.yaml -o tmp/sxl_1.2.1_schema
157
+ ls -la tmp/sxl_1.2.1_schema # Should show rsmp.json, alarms/, commands/, statuses/
158
+
159
+ # Check that no unrelated changes or files were introduced
160
+ git status
161
+ ```
162
+
163
+
164
+ ## Dependencies and Versions
165
+ See `rsmp_schema.gemspec` for current runtime and development dependencies.
166
+
167
+ Requires the Ruby version specified in .tool-versions.
168
+
169
+ ## Common Issues and Solutions
170
+ **Ruby version or environment issues**:
171
+ - Use mise for automatic Ruby management: `mise install`
172
+
173
+ **Permission errors during bundle install**:
174
+ - Use mise which handles permissions automatically
175
+
176
+ **Missing bundler command**:
177
+ - Run `mise install` first, bundler should be available automatically
178
+
179
+ **JSON Schema validation errors**:
180
+ - Check that schema paths use `schemas/` not `schema/` (common typo in examples)
181
+ - Ensure you're using `bundle exec ruby` for scripts that require gems
182
+
183
+ **Test failures**:
184
+ - Run `bundle exec rspec` not just `rspec`
185
+ - Ensure you've run `bundle install` first
186
+ - Check Ruby version compatibility (see .tool-versions)
187
+
188
+ ## Timing Expectations
189
+ - **NEVER CANCEL**: Bundle install takes 10-15 seconds normally - wait for completion
190
+ - **NEVER CANCEL**: Test suite takes 2 seconds - use 30+ second timeout
191
+ - **NEVER CANCEL**: Schema regeneration takes 0.75 seconds - very fast but allow buffer
192
+ - Initial gem setup may take up to 60 seconds total including bundler installation
193
+
194
+ Set timeouts generously:
195
+ - Bundle operations: 60+ seconds
196
+ - Test operations: 30+ seconds
197
+ - CLI operations: 30+ seconds
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /vendor/bundle/
2
3
  /pkg/
3
4
  /spec/reports/
4
5
  /tmp/
data/Gemfile.lock CHANGED
@@ -1,48 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp_schema (0.8.8)
5
- json_schemer (~> 2.3.0)
6
- thor (~> 1.3.1)
4
+ rsmp_schema (0.8.9)
5
+ json_schemer (~> 2.4.0)
6
+ thor (~> 1.4.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- bigdecimal (3.1.8)
12
- diff-lcs (1.5.1)
11
+ bigdecimal (3.2.2)
12
+ diff-lcs (1.6.2)
13
13
  hana (1.3.7)
14
- json_schemer (2.3.0)
14
+ json_schemer (2.4.0)
15
15
  bigdecimal
16
16
  hana (~> 1.3)
17
17
  regexp_parser (~> 2.0)
18
18
  simpleidn (~> 0.2)
19
- rake (13.2.1)
20
- regexp_parser (2.8.2)
21
- rspec (3.13.0)
19
+ rake (13.3.0)
20
+ regexp_parser (2.11.2)
21
+ rspec (3.13.1)
22
22
  rspec-core (~> 3.13.0)
23
23
  rspec-expectations (~> 3.13.0)
24
24
  rspec-mocks (~> 3.13.0)
25
- rspec-core (3.13.0)
25
+ rspec-core (3.13.5)
26
26
  rspec-support (~> 3.13.0)
27
- rspec-expectations (3.13.0)
27
+ rspec-expectations (3.13.5)
28
28
  diff-lcs (>= 1.2.0, < 2.0)
29
29
  rspec-support (~> 3.13.0)
30
- rspec-mocks (3.13.1)
30
+ rspec-mocks (3.13.5)
31
31
  diff-lcs (>= 1.2.0, < 2.0)
32
32
  rspec-support (~> 3.13.0)
33
- rspec-support (3.13.1)
34
- simpleidn (0.2.1)
35
- unf (~> 0.1.4)
36
- thor (1.3.1)
37
- unf (0.1.4)
38
- unf_ext
39
- unf_ext (0.0.9.1)
33
+ rspec-support (3.13.5)
34
+ simpleidn (0.2.3)
35
+ thor (1.4.0)
40
36
 
41
37
  PLATFORMS
42
38
  ruby
43
39
 
44
40
  DEPENDENCIES
45
- rake (~> 13.2.1)
41
+ rake (~> 13.3.0)
46
42
  rsmp_schema!
47
43
  rspec (~> 3.13.0)
48
44
  rspec-expectations (~> 3.13.0)
data/examples/validate.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'json_schemer'
1
+ require 'rsmp_schema'
2
2
 
3
3
  message = {
4
4
  "mType" => "rSMsg",
@@ -18,15 +18,13 @@ message = {
18
18
  ]
19
19
  }
20
20
 
21
- # try validating a message against our schema
22
- schema = Pathname.new('schema/tlc/1.2.1/rsmp.json')
23
- schemer = JSONSchemer.schema(schema)
24
- if schemer.valid? message
21
+ # load schemas
22
+ RSMP::Schema.setup
23
+
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
25
27
  puts 'ok'
26
28
  else
27
- schemer.validate(message).each do |item|
28
- puts [item['data_pointer'],item['type'],item['details']].compact.join(' ')
29
- end
29
+ puts "failed: #{result.inspect}"
30
30
  end
31
-
32
-
@@ -1,5 +1,5 @@
1
1
  module RSMP
2
2
  module Schema
3
- VERSION = "0.8.8"
3
+ VERSION = "0.8.9"
4
4
  end
5
5
  end
data/rsmp_schema.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Emil Tin"]
10
10
  spec.email = ["zf0f@kk.dk"]
11
11
 
12
- spec.summary = "Validate RSMP message against RSMP JSON Schema."
13
- spec.description = "Validate RSMP message against RSMP JSON Schema. Support validating against core and different SXL's, in different versions."
12
+ spec.summary = "Validate RSMP message using RSMP JSON Schema."
13
+ spec.description = "Validate RSMP message using RSMP JSON Schema. Support validating against core and different SXL's, in different versions."
14
14
  spec.homepage = "https://github.com/rsmp-nordic/rsmp_schema"
15
15
  spec.licenses = ['MIT']
16
16
  spec.required_ruby_version = '>= 3.0.0'
@@ -30,10 +30,10 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_dependency "json_schemer", "~> 2.3.0"
34
- spec.add_dependency "thor", "~> 1.3.1"
33
+ spec.add_dependency "json_schemer", "~> 2.4.0"
34
+ spec.add_dependency "thor", "~> 1.4.0"
35
35
 
36
- spec.add_development_dependency "rake", "~> 13.2.1"
36
+ spec.add_development_dependency "rake", "~> 13.3.0"
37
37
  spec.add_development_dependency "rspec", "~> 3.13.0"
38
38
  spec.add_development_dependency "rspec-expectations", "~> 3.13.0"
39
39
  end
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.8.8
4
+ version: 0.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Tin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-05 00:00:00.000000000 Z
11
+ date: 2025-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_schemer
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.0
19
+ version: 2.4.0
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: 2.3.0
26
+ version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3.1
33
+ version: 1.4.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.3.1
40
+ version: 1.4.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 13.2.1
47
+ version: 13.3.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 13.2.1
54
+ version: 13.3.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 3.13.0
83
- description: Validate RSMP message against RSMP JSON Schema. Support validating against
83
+ description: Validate RSMP message using RSMP JSON Schema. Support validating against
84
84
  core and different SXL's, in different versions.
85
85
  email:
86
86
  - zf0f@kk.dk
@@ -89,6 +89,8 @@ executables:
89
89
  extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
92
+ - ".devcontainer/devcontainer.json"
93
+ - ".github/copilot-instructions.md"
92
94
  - ".github/workflows/rspec.yaml"
93
95
  - ".gitignore"
94
96
  - ".rspec"
@@ -981,5 +983,5 @@ requirements: []
981
983
  rubygems_version: 3.5.9
982
984
  signing_key:
983
985
  specification_version: 4
984
- summary: Validate RSMP message against RSMP JSON Schema.
986
+ summary: Validate RSMP message using RSMP JSON Schema.
985
987
  test_files: []