rsmp 0.38.0 → 0.40.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -16
  3. data/.tool-versions +1 -1
  4. data/Gemfile +2 -1
  5. data/Gemfile.lock +40 -38
  6. data/README.md +4 -3
  7. data/documentation/configuration.md +76 -0
  8. data/lib/rsmp/cli.rb +15 -12
  9. data/lib/rsmp/collect/alarm_matcher.rb +4 -4
  10. data/lib/rsmp/collect/collector/logging.rb +1 -0
  11. data/lib/rsmp/collect/command_matcher.rb +3 -3
  12. data/lib/rsmp/collect/matcher.rb +3 -3
  13. data/lib/rsmp/collect/queue.rb +3 -3
  14. data/lib/rsmp/collect/receiver.rb +2 -4
  15. data/lib/rsmp/collect/status_matcher.rb +7 -6
  16. data/lib/rsmp/component/alarm_state.rb +3 -4
  17. data/lib/rsmp/component/component_base.rb +0 -1
  18. data/lib/rsmp/component/components.rb +1 -2
  19. data/lib/rsmp/convert/export/json_schema.rb +2 -0
  20. data/lib/rsmp/convert/import/yaml.rb +1 -0
  21. data/lib/rsmp/helpers/clock.rb +3 -5
  22. data/lib/rsmp/helpers/deep_merge.rb +1 -0
  23. data/lib/rsmp/helpers/error.rb +1 -0
  24. data/lib/rsmp/helpers/inspect.rb +11 -12
  25. data/lib/rsmp/log/archive.rb +2 -3
  26. data/lib/rsmp/log/logger.rb +1 -0
  27. data/lib/rsmp/log/logging.rb +1 -0
  28. data/lib/rsmp/message.rb +26 -0
  29. data/lib/rsmp/node/node.rb +1 -2
  30. data/lib/rsmp/node/protocol.rb +1 -0
  31. data/lib/rsmp/node/site/site.rb +9 -36
  32. data/lib/rsmp/node/supervisor/modules/configuration.rb +3 -19
  33. data/lib/rsmp/node/supervisor/supervisor.rb +1 -4
  34. data/lib/rsmp/node/task.rb +1 -0
  35. data/lib/rsmp/options/options.rb +185 -0
  36. data/lib/rsmp/options/schemas/site.json +49 -0
  37. data/lib/rsmp/options/schemas/supervisor.json +43 -0
  38. data/lib/rsmp/options/schemas/traffic_controller_site.json +18 -0
  39. data/lib/rsmp/options/site_options.rb +44 -0
  40. data/lib/rsmp/options/supervisor_options.rb +28 -0
  41. data/lib/rsmp/options/traffic_controller_site_options.rb +12 -0
  42. data/lib/rsmp/proxy/proxy.rb +2 -4
  43. data/lib/rsmp/proxy/site/site_proxy.rb +1 -2
  44. data/lib/rsmp/proxy/supervisor/supervisor_proxy.rb +1 -2
  45. data/lib/rsmp/tlc/detector_logic.rb +1 -0
  46. data/lib/rsmp/tlc/signal_group.rb +1 -0
  47. data/lib/rsmp/tlc/signal_priority.rb +1 -0
  48. data/lib/rsmp/tlc/traffic_controller_site.rb +4 -0
  49. data/lib/rsmp/version.rb +1 -1
  50. data/lib/rsmp.rb +4 -0
  51. metadata +10 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f1f32aacd75ffad7d36662c3e7abd0b0a851b35b287f444dd63cdebc9db1c00
4
- data.tar.gz: 32d9db803bc5ef274c1838cb961f677863745bb2e2eca105eb17b8ee4f39cea1
3
+ metadata.gz: 7db642eae802d3f31456b221ab6297516eb081375f1778cf06cd25b597ae3d07
4
+ data.tar.gz: e64b67b905975ca8862dd3610a2c3553c8527378db05fc0242dbd56996f850a5
5
5
  SHA512:
6
- metadata.gz: a655dab4868d9544a0242303da7d26254f3d953ecc5d789c78f7e4553e946b98eebab7f59fa4ee69c736123dfa198417885595db490724b6238fa051b1fb2a87
7
- data.tar.gz: f24fe238a17439e6e0b91e75f816733da49f9e348dd22cc00f3c68938505ca68ba7ed32575a71e9dfc18330a10f2b92fe23ade7679bdb3f0878b37e894fd55aa
6
+ metadata.gz: 9dbceb076fdfd4aee419daceb587c7802eaf664f3bde3bcd7bb944e9e1408e78b9da0987ca7b56ab0e29d65cc120822f2e2c501bff3de2f22676141194394af3
7
+ data.tar.gz: 25cdeff92403011140b4164541ad94a785ad8b62449563a49f1ae1ccdc99f8489e940a310d140ddda3db34f66bcded08382d5e3bfdc5cf5307cb7529c11f94d7
data/.rubocop.yml CHANGED
@@ -1,3 +1,7 @@
1
+ plugins:
2
+ - rubocop-rspec
3
+ - rubocop-rake
4
+
1
5
  AllCops:
2
6
  NewCops: enable
3
7
  TargetRubyVersion: 3.4
@@ -43,17 +47,10 @@ Metrics/BlockLength:
43
47
  - 'features/**/*'
44
48
  - '*.gemspec'
45
49
 
46
- # Keep some reasonable exceptions
47
- Style/Documentation:
48
- Enabled: false
49
-
50
+ # From Ruby 3.4, frozen string literals are the default anyways
50
51
  Style/FrozenStringLiteralComment:
51
52
  Enabled: false
52
53
 
53
- # Allow double negation for boolean coercion - common Ruby pattern
54
- Style/DoubleNegation:
55
- Enabled: false
56
-
57
54
  # Allow mix-in usage at top level in test files
58
55
  Style/MixinUsage:
59
56
  Exclude:
@@ -65,14 +62,6 @@ Lint/ConstantDefinitionInBlock:
65
62
  Exclude:
66
63
  - 'spec/**/*'
67
64
 
68
- # Keep critical domain-specific logic intact
69
- Style/ReturnNilInPredicateMethodDefinition:
70
- Enabled: false
71
-
72
-
73
- plugins:
74
- - rubocop-rspec
75
-
76
65
  RSpec/MultipleExpectations:
77
66
  Max: 20
78
67
 
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.4
1
+ ruby 4
data/Gemfile CHANGED
@@ -6,12 +6,13 @@ gemspec
6
6
 
7
7
  group :development do
8
8
  gem 'aruba', '~> 2.3'
9
- gem 'bundler', '~> 2.6'
9
+ gem 'bundler', '~> 4.0'
10
10
  gem 'cucumber', '~> 9.2'
11
11
  gem 'rake', '~> 13.2'
12
12
  gem 'rspec', '~> 3.13'
13
13
  gem 'rspec-expectations', '~> 3.13'
14
14
  gem 'rubocop', '~> 1.65'
15
+ gem 'rubocop-rake', require: false
15
16
  gem 'rubocop-rspec', require: false
16
17
  gem 'timecop', '~> 0.9'
17
18
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.38.0)
4
+ rsmp (0.40.0)
5
5
  async (~> 2.32)
6
6
  colorize (~> 1.1)
7
7
  io-endpoint (~> 0.15)
@@ -13,27 +13,27 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- aruba (2.3.1)
17
- bundler (>= 1.17, < 3.0)
16
+ aruba (2.3.3)
17
+ bundler (>= 1.17)
18
18
  contracts (>= 0.16.0, < 0.18.0)
19
19
  cucumber (>= 8.0, < 11.0)
20
- rspec-expectations (~> 3.4)
20
+ rspec-expectations (>= 3.4, < 5.0)
21
21
  thor (~> 1.0)
22
22
  ast (2.4.3)
23
- async (2.32.0)
23
+ async (2.35.2)
24
24
  console (~> 1.29)
25
25
  fiber-annotation
26
26
  io-event (~> 1.11)
27
27
  metrics (~> 0.12)
28
28
  traces (~> 0.18)
29
- bigdecimal (3.2.3)
29
+ bigdecimal (4.0.1)
30
30
  builder (3.3.0)
31
31
  colorize (1.1.0)
32
- console (1.34.0)
32
+ console (1.34.2)
33
33
  fiber-annotation
34
34
  fiber-local (~> 1.1)
35
35
  json
36
- contracts (0.17.2)
36
+ contracts (0.17.3)
37
37
  cucumber (9.2.1)
38
38
  builder (~> 3.2)
39
39
  cucumber-ci-environment (> 9, < 11)
@@ -55,22 +55,25 @@ GEM
55
55
  bigdecimal
56
56
  cucumber-gherkin (27.0.0)
57
57
  cucumber-messages (>= 19.1.4, < 23)
58
- cucumber-html-formatter (21.14.0)
58
+ cucumber-html-formatter (21.15.1)
59
59
  cucumber-messages (> 19, < 28)
60
60
  cucumber-messages (22.0.0)
61
61
  cucumber-tag-expressions (6.1.2)
62
62
  diff-lcs (1.6.2)
63
- ffi (1.17.2)
64
- ffi (1.17.2-arm64-darwin)
63
+ ffi (1.17.3)
64
+ ffi (1.17.3-arm64-darwin)
65
+ ffi (1.17.3-x64-mingw-ucrt)
66
+ ffi (1.17.3-x86_64-darwin)
67
+ ffi (1.17.3-x86_64-linux-gnu)
65
68
  fiber-annotation (0.2.0)
66
69
  fiber-local (1.1.0)
67
70
  fiber-storage
68
71
  fiber-storage (1.0.1)
69
72
  hana (1.3.7)
70
- io-endpoint (0.15.2)
71
- io-event (1.14.0)
72
- io-stream (0.10.0)
73
- json (2.14.1)
73
+ io-endpoint (0.16.0)
74
+ io-event (1.14.2)
75
+ io-stream (0.11.1)
76
+ json (2.18.0)
74
77
  json_schemer (2.4.0)
75
78
  bigdecimal
76
79
  hana (~> 1.3)
@@ -85,31 +88,31 @@ GEM
85
88
  multi_test (1.1.0)
86
89
  ostruct (0.6.3)
87
90
  parallel (1.27.0)
88
- parser (3.3.9.0)
91
+ parser (3.3.10.0)
89
92
  ast (~> 2.4.1)
90
93
  racc
91
- prism (1.5.1)
94
+ prism (1.8.0)
92
95
  racc (1.8.1)
93
96
  rainbow (3.1.1)
94
- rake (13.3.0)
95
- regexp_parser (2.11.2)
96
- rsmp_schema (0.8.9)
97
+ rake (13.3.1)
98
+ regexp_parser (2.11.3)
99
+ rsmp_schema (0.9.1)
97
100
  json_schemer (~> 2.4.0)
98
101
  thor (~> 1.4.0)
99
- rspec (3.13.1)
102
+ rspec (3.13.2)
100
103
  rspec-core (~> 3.13.0)
101
104
  rspec-expectations (~> 3.13.0)
102
105
  rspec-mocks (~> 3.13.0)
103
- rspec-core (3.13.5)
106
+ rspec-core (3.13.6)
104
107
  rspec-support (~> 3.13.0)
105
108
  rspec-expectations (3.13.5)
106
109
  diff-lcs (>= 1.2.0, < 2.0)
107
110
  rspec-support (~> 3.13.0)
108
- rspec-mocks (3.13.5)
111
+ rspec-mocks (3.13.7)
109
112
  diff-lcs (>= 1.2.0, < 2.0)
110
113
  rspec-support (~> 3.13.0)
111
- rspec-support (3.13.5)
112
- rubocop (1.81.0)
114
+ rspec-support (3.13.6)
115
+ rubocop (1.82.1)
113
116
  json (~> 2.3)
114
117
  language_server-protocol (~> 3.17.0.2)
115
118
  lint_roller (~> 1.1.0)
@@ -117,15 +120,18 @@ GEM
117
120
  parser (>= 3.3.0.2)
118
121
  rainbow (>= 2.2.2, < 4.0)
119
122
  regexp_parser (>= 2.9.3, < 3.0)
120
- rubocop-ast (>= 1.47.1, < 2.0)
123
+ rubocop-ast (>= 1.48.0, < 2.0)
121
124
  ruby-progressbar (~> 1.7)
122
125
  unicode-display_width (>= 2.4.0, < 4.0)
123
- rubocop-ast (1.47.1)
126
+ rubocop-ast (1.49.0)
124
127
  parser (>= 3.3.7.2)
125
- prism (~> 1.4)
126
- rubocop-rspec (3.7.0)
128
+ prism (~> 1.7)
129
+ rubocop-rake (0.7.1)
127
130
  lint_roller (~> 1.1)
128
- rubocop (~> 1.72, >= 1.72.1)
131
+ rubocop (>= 1.72.1)
132
+ rubocop-rspec (3.9.0)
133
+ lint_roller (~> 1.1)
134
+ rubocop (~> 1.81)
129
135
  ruby-progressbar (1.13.0)
130
136
  simpleidn (0.2.3)
131
137
  sys-uname (1.4.1)
@@ -136,31 +142,27 @@ GEM
136
142
  traces (0.18.2)
137
143
  unicode-display_width (3.2.0)
138
144
  unicode-emoji (~> 4.1)
139
- unicode-emoji (4.1.0)
145
+ unicode-emoji (4.2.0)
140
146
 
141
147
  PLATFORMS
142
- arm64-darwin-22
143
148
  arm64-darwin-23
144
149
  arm64-darwin-24
145
150
  x64-mingw-ucrt
146
- x64-mingw32
147
- x86_64-darwin-19
148
- x86_64-darwin-20
149
- x86_64-darwin-21
150
151
  x86_64-darwin-22
151
152
  x86_64-linux
152
153
 
153
154
  DEPENDENCIES
154
155
  aruba (~> 2.3)
155
- bundler (~> 2.6)
156
+ bundler (~> 4.0)
156
157
  cucumber (~> 9.2)
157
158
  rake (~> 13.2)
158
159
  rsmp!
159
160
  rspec (~> 3.13)
160
161
  rspec-expectations (~> 3.13)
161
162
  rubocop (~> 1.65)
163
+ rubocop-rake
162
164
  rubocop-rspec
163
165
  timecop (~> 0.9)
164
166
 
165
167
  BUNDLED WITH
166
- 2.6.3
168
+ 4.0.3
data/README.md CHANGED
@@ -31,6 +31,9 @@ Be default, a site will try to connect to a single supervisor on localhost 127.0
31
31
 
32
32
  You can pass options to control ip adresseses, ports, logging and other behaviour:
33
33
 
34
+ Configuration files can be loaded from YAML using the CLI or the options classes. These are validated
35
+ against JSON schemas and will raise errors with details on what is wrong.
36
+
34
37
  ```ruby
35
38
  require 'rsmp'
36
39
  settings = {
@@ -45,8 +48,6 @@ settings = {
45
48
  RSMP::Site.new(site_settings:settings)
46
49
  ```
47
50
 
48
- See lib/rsmp/site.rb and lib/rsmp/supervisor.rb for a list of settings and their default values.
49
-
50
51
  ### Concurrency
51
52
  The [async](https://github.com/socketry/async) and [async-io](https://github.com/socketry/async-io) gems are used to handle concurrency. Everything happens in a single thread, but fibers are used to switch between tasks whenever an IO operation blocks.
52
53
 
@@ -162,7 +163,7 @@ Use the ```tlc``` site type to run an emulation of a traffic light controller. T
162
163
  ### CLI help and options.
163
164
  Use ```--help <command>``` to get a list of available options.
164
165
 
165
- Use ```--config <path>``` to point to a .yaml config file, controlling things like IP adresses, ports, and log output. Examples of config files can be found the folder ```config/```.
166
+ Use ```--config <path>``` or ```--options <path>``` to point to a .yaml config file, controlling things like IP adresses, ports, and log output. Examples of config files can be found the folder ```config/```.
166
167
 
167
168
  ## Tests
168
169
  ### RSpec
@@ -0,0 +1,76 @@
1
+ # Configuration
2
+
3
+ ## Overview
4
+ RSMP uses option classes to handle configuration for sites and supervisors. These classes provide:
5
+
6
+ - File-based configuration via YAML
7
+ - JSON Schema validation with descriptive errors
8
+ - Safe access to nested values using Ruby's `dig`
9
+ - Deep merging of provided values with defaults
10
+
11
+ ## Option classes
12
+
13
+ - `RSMP::Site::Options` for sites
14
+ - `RSMP::Supervisor::Options` for supervisors
15
+ - `RSMP::TLC::TrafficControllerSite::Options` for TLC sites
16
+
17
+ Each class applies defaults and validates the configuration against a JSON Schema located in `lib/rsmp/options/schemas/`.
18
+
19
+ ## Loading a configuration file
20
+
21
+ Use the option classes to load a YAML configuration file:
22
+
23
+ - `RSMP::Site::Options.load_file(path)`
24
+ - `RSMP::Supervisor::Options.load_file(path)`
25
+
26
+ The top-level `log` section is separated into `log_settings`. Other keys are treated as settings for the site or supervisor.
27
+
28
+ ## CLI usage
29
+
30
+ Use the CLI with a config file:
31
+
32
+ - `rsmp site --config path/to/site.yaml`
33
+ - `rsmp supervisor --options path/to/supervisor.yaml`
34
+
35
+ Both `--config` and `--options` are accepted as aliases.
36
+
37
+ ## Example: site YAML
38
+
39
+ ```yaml
40
+ site_id: RN+SI0001
41
+ supervisors:
42
+ - ip: 127.0.0.1
43
+ port: 12111
44
+ sxl: tlc
45
+ sxl_version: "1.2.1"
46
+ components:
47
+ main:
48
+ TC:
49
+ log:
50
+ json: true
51
+ ```
52
+
53
+ ## Example: supervisor YAML
54
+
55
+ ```yaml
56
+ port: 12111
57
+ guest:
58
+ sxl: tlc
59
+ intervals:
60
+ timer: 0.1
61
+ watchdog: 0.1
62
+ log:
63
+ json: true
64
+ ```
65
+
66
+ ## Validation
67
+
68
+ Invalid configurations raise `RSMP::ConfigurationError` with details about the failing path. The CLI prints these errors when loading config files.
69
+
70
+ Errors include the failing JSON pointer and helpful type hints, for example:
71
+
72
+ - `/supervisors: value at \`/supervisors\` is not an array (expected array, got string)`
73
+
74
+ ## Defaults and overrides
75
+
76
+ Configuration values override defaults via deep merge. A notable exception is `components.main`, which replaces the default component list when provided.
data/lib/rsmp/cli.rb CHANGED
@@ -2,6 +2,7 @@ require 'thor'
2
2
  require_relative '../rsmp'
3
3
 
4
4
  module RSMP
5
+ # CLI commands for running RSMP site and supervisor.
5
6
  class CLI < Thor
6
7
  desc 'version', 'Show version'
7
8
  def version
@@ -9,7 +10,7 @@ module RSMP
9
10
  end
10
11
 
11
12
  desc 'site', 'Run RSMP site'
12
- method_option :config, type: :string, aliases: '-c', banner: 'Path to .yaml config file'
13
+ method_option :config, type: :string, aliases: ['-c', '--options'], banner: 'Path to .yaml config file'
13
14
  method_option :id, type: :string, aliases: '-i', banner: 'RSMP site id'
14
15
  method_option :supervisors, type: :string, aliases: '-s',
15
16
  banner: 'ip:port,... list of supervisor to connect to'
@@ -31,7 +32,7 @@ module RSMP
31
32
  end
32
33
 
33
34
  desc 'supervisor', 'Run RSMP supervisor'
34
- method_option :config, type: :string, aliases: '-c', banner: 'Path to .yaml config file'
35
+ method_option :config, type: :string, aliases: ['-c', '--options'], banner: 'Path to .yaml config file'
35
36
  method_option :id, type: :string, aliases: '-i', banner: 'RSMP site id'
36
37
  method_option :ip, type: :string, banner: 'IP address to listen on'
37
38
  method_option :port, type: :string, aliases: '-p', banner: 'Port to listen on'
@@ -62,11 +63,12 @@ module RSMP
62
63
 
63
64
  return [settings, log_settings] unless options[:config]
64
65
 
65
- if File.exist? options[:config]
66
- settings = YAML.load_file options[:config]
67
- log_settings = settings.delete('log') || log_settings
68
- else
69
- puts "Error: Config #{options[:config]} not found"
66
+ begin
67
+ options_object = RSMP::Site::Options.load_file(options[:config])
68
+ settings = options_object.to_h
69
+ log_settings = log_settings.deep_merge(options_object.log_settings)
70
+ rescue RSMP::ConfigurationError => e
71
+ puts "Error: #{e}"
70
72
  exit
71
73
  end
72
74
 
@@ -134,11 +136,12 @@ module RSMP
134
136
 
135
137
  return [settings, log_settings] unless options[:config]
136
138
 
137
- if File.exist? options[:config]
138
- settings = YAML.load_file options[:config]
139
- log_settings = settings.delete('log') || log_settings
140
- else
141
- puts "Error: Config #{options[:config]} not found"
139
+ begin
140
+ options_object = RSMP::Supervisor::Options.load_file(options[:config])
141
+ settings = options_object.to_h
142
+ log_settings = log_settings.deep_merge(options_object.log_settings)
143
+ rescue RSMP::ConfigurationError => e
144
+ puts "Error: #{e}"
142
145
  exit
143
146
  end
144
147
 
@@ -1,13 +1,13 @@
1
1
  module RSMP
2
2
  # Match a specific alarm
3
3
  class AlarmMatcher < Matcher
4
- def match?(item)
5
- return false if @want['n'] && @want['n'] != item['n']
4
+ def match(item)
5
+ return nil if @want['n'] && @want['n'] != item['n']
6
6
 
7
7
  if @want['v'].is_a? Regexp
8
- return false if item['v'] !~ @want['v']
8
+ return nil if item['v'] !~ @want['v']
9
9
  elsif @want['v']
10
- return false if item['v'] != @want['v']
10
+ return nil if item['v'] != @want['v']
11
11
  end
12
12
  true
13
13
  end
@@ -1,5 +1,6 @@
1
1
  module RSMP
2
2
  class Collector
3
+ # Logging helpers for Collector instances.
3
4
  module Logging
4
5
  def log_start
5
6
  @distributor.log "#{identifier}: Waiting for #{describe_matcher}".strip, level: :collect
@@ -1,7 +1,7 @@
1
1
  module RSMP
2
2
  # Class for matching a command
3
3
  class CommandMatcher < Matcher
4
- def match_code?(item)
4
+ def match_code(item)
5
5
  return nil if @want['cCI'] && @want['cCI'] != item['cCI']
6
6
  return nil if @want['n'] && @want['n'] != item['n']
7
7
 
@@ -19,8 +19,8 @@ module RSMP
19
19
  true
20
20
  end
21
21
 
22
- def match?(item)
23
- code_match = match_code?(item)
22
+ def match(item)
23
+ code_match = match_code(item)
24
24
  return code_match if code_match.nil?
25
25
 
26
26
  match_value?(item)
@@ -9,7 +9,7 @@ module RSMP
9
9
  @message = nil
10
10
  end
11
11
 
12
- # Are we done, i.e. did the last checked item match?
12
+ # Are we done, i.e. did the last checked item match
13
13
  def done?
14
14
  @got != nil
15
15
  end
@@ -17,7 +17,7 @@ module RSMP
17
17
  # Check an item and set @done to true if it matches
18
18
  # Store the item and corresponding message if there's a positive or negative match
19
19
  def perform_match(item, _message, block)
20
- matched = match? item
20
+ matched = match item
21
21
  if !matched.nil? && block
22
22
  status = block.call(nil, item)
23
23
  matched = status if [true, false].include?(status)
@@ -35,6 +35,6 @@ module RSMP
35
35
  @got = nil
36
36
  end
37
37
 
38
- def match?(item); end
38
+ def match(item); end
39
39
  end
40
40
  end
@@ -1,7 +1,7 @@
1
- # Receives items from a Distributor and keeps them in a queue.
2
- # The client can wait for mesages and will get them one by one.
3
-
1
+ # Top-level RSMP namespace.
4
2
  module RSMP
3
+ # Receives items from a Distributor and keeps them in a queue.
4
+ # The client can wait for messages and will get them one by one.
5
5
  class Queue
6
6
  include Receiver
7
7
 
@@ -1,8 +1,6 @@
1
- # Receives items from a Distributor, as long as it's
2
- # installed as a receiver.
3
- # Optionally filter mesage using a Filter.
4
-
5
1
  module RSMP
2
+ # Receives items from a Distributor when included as a receiver.
3
+ # Optionally filter messages using a Filter.
6
4
  module Receiver
7
5
  include Inspect
8
6
 
@@ -1,9 +1,10 @@
1
1
  module RSMP
2
+ # Match a specific status
2
3
  class StatusMatcher < Matcher
3
- def match_code?(item)
4
- return false if @want['sCI'] && @want['sCI'] != item['sCI']
5
- return false if @want['cO'] && @want['cO'] != item['cO']
6
- return false if @want['n'] && @want['n'] != item['n']
4
+ def match_code(item)
5
+ return nil if @want['sCI'] && @want['sCI'] != item['sCI']
6
+ return nil if @want['cO'] && @want['cO'] != item['cO']
7
+ return nil if @want['n'] && @want['n'] != item['n']
7
8
 
8
9
  true
9
10
  end
@@ -19,8 +20,8 @@ module RSMP
19
20
  true
20
21
  end
21
22
 
22
- def match?(item)
23
- return nil unless match_code?(item)
23
+ def match(item)
24
+ return nil unless match_code(item)
24
25
 
25
26
  match_value?(item)
26
27
  end
@@ -3,7 +3,6 @@ module RSMP
3
3
  # The alarm state is for a particular alarm code,
4
4
  # a component typically have an alarm state for each
5
5
  # alarm code that is defined for the component type.
6
-
7
6
  class AlarmState
8
7
  attr_reader :component_id, :code, :acknowledged, :suspended, :active, :timestamp, :category, :priority, :rvs
9
8
 
@@ -24,9 +23,9 @@ module RSMP
24
23
  @component = component
25
24
  @component_id = component.c_id
26
25
  @code = code
27
- @suspended = !!options[:suspended]
28
- @acknowledged = !!options[:acknowledged]
29
- @active = !!options[:active]
26
+ @suspended = options[:suspended] == true
27
+ @acknowledged = options[:acknowledged] == true
28
+ @active = options[:active] == true
30
29
  @timestamp = options[:timestamp]
31
30
  @category = options[:category] || 'D'
32
31
  @priority = options[:priority] || 2
@@ -1,6 +1,5 @@
1
1
  module RSMP
2
2
  # RSMP component base class.
3
-
4
3
  class ComponentBase
5
4
  include Inspect
6
5
 
@@ -1,6 +1,5 @@
1
- # Things shared between sites and site proxies
2
-
3
1
  module RSMP
2
+ # Things shared between sites and site proxies
4
3
  module Components
5
4
  attr_reader :components, :main
6
5
 
@@ -7,6 +7,8 @@ require 'fileutils'
7
7
  module RSMP
8
8
  module Convert
9
9
  module Export
10
+ # Converts SXL (YAML) structures into JSON Schema files.
11
+ # Converts SXL (YAML) structures into JSON Schema files.
10
12
  module JSONSchema
11
13
  JSON_OPTIONS = {
12
14
  array_nl: "\n",
@@ -7,6 +7,7 @@ require 'fileutils'
7
7
  module RSMP
8
8
  module Convert
9
9
  module Import
10
+ # Importer for SXL in YAML format.
10
11
  module YAML
11
12
  def self.read(path)
12
13
  convert ::YAML.load_file(path)
@@ -1,11 +1,9 @@
1
- # Get the current time in UTC, with optional adjustment
2
- # Convertion to string uses the RSMP format 2015-06-08T12:01:39.654Z
3
- # Note that using to_s on a my_clock.to_s will not produce an RSMP formatted timestamp,
4
- # you need to use Clock.to_s my_clock
5
-
6
1
  require 'time'
7
2
 
8
3
  module RSMP
4
+ # Get the current time in UTC, with optional adjustment.
5
+ # Conversion to string uses the RSMP format 2015-06-08T12:01:39.654Z
6
+ # Use `Clock.to_s` to format times in RSMP format.
9
7
  class Clock
10
8
  attr_reader :adjustment
11
9
 
@@ -1,3 +1,4 @@
1
+ # Extensions to Hash providing a `deep_merge` helper.
1
2
  class Hash
2
3
  def deep_merge(other_hash)
3
4
  return self unless other_hash
@@ -8,6 +8,7 @@ module RSMP
8
8
  class MalformedMessage < Error
9
9
  end
10
10
 
11
+ # Raised when schema validation fails.
11
12
  class SchemaError < Error
12
13
  attr_accessor :schemas
13
14
  end
@@ -1,16 +1,15 @@
1
- # Costume inspect, to reduce noise
2
- #
3
- # Instance variables of classes starting with Async or RSMP are shown
4
- # with only their class name and object id, which reduces output,
5
- # especially for deep object structures.
6
- # Additionally, a list of variables to shown in short format can be passed.
7
- #
8
- # The short form is generated by using to_s() insted of inspect()
9
- #
10
- # Array#to_s and Hash#to_s usually show items, but here we show just number
11
- # of items, when the short form is requested.
12
-
13
1
  module RSMP
2
+ # Custom inspect, to reduce noise
3
+ #
4
+ # Instance variables of classes starting with Async or RSMP are shown
5
+ # with only their class name and object id, which reduces output,
6
+ # especially for deep object structures.
7
+ # Additionally, a list of variables to shown in short format can be passed.
8
+ #
9
+ # The short form is generated by using to_s() insted of inspect()
10
+ #
11
+ # Array#to_s and Hash#to_s usually show items, but here we show just number
12
+ # of items, when the short form is requested.
14
13
  module Inspect
15
14
  def inspector *short_items
16
15
  instance_variables.map do |var_name|
@@ -1,7 +1,6 @@
1
- # Archive of log items, which can be messages or info items.
2
- # All items are timestamped, and stored chronologically.
3
-
4
1
  module RSMP
2
+ # Archive of log items, which can be messages or info items.
3
+ # All items are timestamped, and stored chronologically.
5
4
  class Archive
6
5
  include Inspect
7
6