statelint 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/data/StateMachine.j2119 +1 -0
- data/lib/statelint/state_node.rb +26 -1
- data/statelint.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 41e064cf4197390ad04be13fbfca74f93380c42214bd51fa84091d75b3c58307
|
4
|
+
data.tar.gz: f683ebc3ad1587dea7fe2393a37c810474bc160520fe632c9d8a778604920941
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53cf3ef609f46f3a806cd2a8177b4ee07273dd6065dddc7539c2ca51d3232f0a7859cad1916bb7e59c216eb558788bf3fbb7caa968c9f1477913a7ceb54afd41
|
7
|
+
data.tar.gz: 9b3afeba573dc8fcef3f26fddf932f497661da6141e24e0774aaca9925a9b91529cd951933ffb86dbbfec2fcfce67265ee46a4dc936b4128b4a35f491d8b8bce
|
data/data/StateMachine.j2119
CHANGED
@@ -14,6 +14,7 @@ A State whose "Type" field's value is "Wait" is a "Wait State".
|
|
14
14
|
A State whose "Type" field's value is "Parallel" is a "Parallel State".
|
15
15
|
A State MAY have a string field named "Comment".
|
16
16
|
Each of a Pass State, a Task State, a Wait State, and a Parallel State MAY have a boolean field named "End".
|
17
|
+
Each of a Pass State, a Task State, and a Parallel State MAY have a field named "Parameters".
|
17
18
|
A State whose "End" field's value is true is a "Terminal State".
|
18
19
|
Each of a Succeed State and a Fail State is a "Terminal State".
|
19
20
|
A State which is not a Terminal State or a Choice State MUST have a string field named "Next".
|
data/lib/statelint/state_node.rb
CHANGED
@@ -12,6 +12,8 @@
|
|
12
12
|
# permissions and limitations under the License.
|
13
13
|
#!/usr/bin/env ruby
|
14
14
|
|
15
|
+
require 'j2119'
|
16
|
+
|
15
17
|
module StateMachineLint
|
16
18
|
|
17
19
|
# Semantic validation that can't be expressed in a J2119 schema
|
@@ -52,7 +54,13 @@ module StateMachineLint
|
|
52
54
|
@current_states_incoming << []
|
53
55
|
end
|
54
56
|
|
55
|
-
node['States']
|
57
|
+
states = node['States']
|
58
|
+
states.keys.each do |name|
|
59
|
+
child = states[name]
|
60
|
+
if child.is_a?(Hash) && child.key?('Parameters')
|
61
|
+
probe_parameters(child, path + '.' + name, problems)
|
62
|
+
end
|
63
|
+
|
56
64
|
if @all_state_names[name]
|
57
65
|
problems <<
|
58
66
|
"State \"#{name}\", defined at #{path}.States, " +
|
@@ -113,6 +121,23 @@ module StateMachineLint
|
|
113
121
|
end
|
114
122
|
end
|
115
123
|
|
124
|
+
# Search through Parameters for object nodes and check field semantics
|
125
|
+
def probe_parameters(node, path, problems)
|
126
|
+
if node.is_a?(Hash)
|
127
|
+
node.each do |name, val|
|
128
|
+
if name.end_with? '.$'
|
129
|
+
if (!val.is_a?(String)) || (!J2119::JSONPathChecker.is_path?(val))
|
130
|
+
problems << "Field \"#{name}\" of Parameters at \"#{path}\" is not a JSONPath"
|
131
|
+
end
|
132
|
+
else
|
133
|
+
probe_parameters(val, "#{path}.#{name}", problems)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
elsif node.is_a?(Array)
|
137
|
+
node.size.times {|i| probe_parameters(node[i], "#{path}[#{i}]", problems) }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
116
141
|
def check_for_terminal(node, path, problems)
|
117
142
|
if node['States'] && node['States'].is_a?(Hash)
|
118
143
|
terminal_found = false
|
data/statelint.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statelint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Bray
|
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
64
|
rubyforge_project:
|
65
|
-
rubygems_version: 2.
|
65
|
+
rubygems_version: 2.7.7
|
66
66
|
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: State Machine JSON validator
|