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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6bee89be701a12fd45bd3d6b0de5b505aad1c602
4
- data.tar.gz: 6b6f4208af22128dd92b36c9a81b7def5146e111
2
+ SHA256:
3
+ metadata.gz: 41e064cf4197390ad04be13fbfca74f93380c42214bd51fa84091d75b3c58307
4
+ data.tar.gz: f683ebc3ad1587dea7fe2393a37c810474bc160520fe632c9d8a778604920941
5
5
  SHA512:
6
- metadata.gz: eb442240dd8d5a919fecc74eed803bda47052b4ddad5ad7b1a9a0d6de092dd9625d809a0124801fe09a28d26df95437d1abbe5b344d10ddaa1a485f5de56f400
7
- data.tar.gz: d7bf9684350829a5dae1e5b732bb6268fda45f4921f3626309b3d1cb5ff4342e7b5c27be7dc024a52701065eac9e6cb0ac2bd63c833270738c2df79adfd019ec
6
+ metadata.gz: 53cf3ef609f46f3a806cd2a8177b4ee07273dd6065dddc7539c2ca51d3232f0a7859cad1916bb7e59c216eb558788bf3fbb7caa968c9f1477913a7ceb54afd41
7
+ data.tar.gz: 9b3afeba573dc8fcef3f26fddf932f497661da6141e24e0774aaca9925a9b91529cd951933ffb86dbbfec2fcfce67265ee46a4dc936b4128b4a35f491d8b8bce
@@ -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".
@@ -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'].keys.each do |name|
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'statelint'
3
- s.version = '0.1.4'
3
+ s.version = '0.2.0'
4
4
  s.date = '2016-09-28'
5
5
  s.summary = "State Machine JSON validator"
6
6
  s.description = "Validates a JSON object representing a State Machine"
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.1.4
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.0.14.1
65
+ rubygems_version: 2.7.7
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: State Machine JSON validator