rast 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/examples/quoted.rb +12 -0
- data/lib/rast/parameter_generator.rb +8 -1
- data/lib/rast/rules/rule.rb +2 -0
- data/lib/rast/rules/rule_evaluator.rb +6 -1
- data/rast.gemspec +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7e03f4e3c569cbd461a8387f0990f4c7a48596c87d37cc6e558cf2b89f06398
|
4
|
+
data.tar.gz: f0df9996942ddb36e6f7ef2ab6d40da33261547480151c731dc1648989772bfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1045f74d81616e6e6a5cc984d3460fa4d889a8a8063d33bb801c20ca8abebe03b2f8b73e41fd2aaa97164cf3aae3a861103978a751e69999bee623d747970dd4
|
7
|
+
data.tar.gz: c263c3f383e2113b0551859712ced10966d544be95e8e6e554930ae32b48c61a0030ddaf15cc594bc7bdfde0b0395de554544f31e9aa25f84cc4197c0198a660
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
- 0.11.0 - Raw array as clause to support spaces and operator characters.
|
3
4
|
- 0.10.0 - Optional variables definition for 1 to 1 rules.
|
4
5
|
- 0.9.0 - execute return value is now the expected outcome (removed result method)
|
5
6
|
- 0.8.1.pre - Allow spaces in rules.
|
data/examples/quoted.rb
ADDED
@@ -82,6 +82,8 @@ class ParameterGenerator
|
|
82
82
|
# Detects if rule config has one outcome to one token mapping.
|
83
83
|
def one_to_one(outcome_to_clause)
|
84
84
|
outcome_to_clause.each do |outcome, clause|
|
85
|
+
next if clause.is_a?(Array) && clause.size == 1
|
86
|
+
|
85
87
|
return false if RuleEvaluator.tokenize(clause: clause).size > 1
|
86
88
|
end
|
87
89
|
|
@@ -92,12 +94,17 @@ class ParameterGenerator
|
|
92
94
|
def detect_variables(spec_config)
|
93
95
|
return nil unless one_to_one(spec_config['rules'])
|
94
96
|
|
97
|
+
tokens = spec_config['rules'].values
|
98
|
+
return { vars: tokens.map(&:first) } if tokens.first.is_a?(Array) && tokens.first.size == 1
|
99
|
+
|
95
100
|
{ vars: spec_config['rules'].values }
|
96
101
|
end
|
97
102
|
|
98
103
|
def instantiate_spec(spec_config)
|
99
104
|
|
100
|
-
|
105
|
+
if spec_config['variables'].nil?
|
106
|
+
spec_config['variables'] = detect_variables(spec_config)
|
107
|
+
end
|
101
108
|
|
102
109
|
spec = RastSpec.new(
|
103
110
|
description: spec_config[:description],
|
data/lib/rast/rules/rule.rb
CHANGED
@@ -34,6 +34,8 @@ class Rule
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.sanitize(clause: '')
|
37
|
+
return clause if clause.is_a?(Array)
|
38
|
+
|
37
39
|
cleaner = Rule.remove_spaces(token: clause, separator: '(')
|
38
40
|
cleaner = Rule.remove_spaces(token: cleaner, separator: ')')
|
39
41
|
cleaner = Rule.remove_spaces(token: cleaner, separator: '&')
|
@@ -56,7 +56,12 @@ class RuleEvaluator
|
|
56
56
|
@stack_operations.clear
|
57
57
|
@stack_rpn.clear
|
58
58
|
|
59
|
-
|
59
|
+
if expression.is_a?(Array)
|
60
|
+
tokens = expression
|
61
|
+
else
|
62
|
+
tokens = RuleEvaluator.tokenize(clause: expression)
|
63
|
+
end
|
64
|
+
|
60
65
|
|
61
66
|
# /* loop for handling each token - shunting-yard algorithm */
|
62
67
|
tokens.each { |token| shunt_internal(token: token.strip) }
|
data/rast.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Royce Remulla
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Extends RSpec functionality by using the catch-all-scenario testing (CAST)
|
14
14
|
principle.
|
@@ -18,9 +18,9 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- .gitignore
|
22
|
-
- .rspec
|
23
|
-
- .rubocop.yml
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- ".rubocop.yml"
|
24
24
|
- CHANGELOG.md
|
25
25
|
- Gemfile
|
26
26
|
- Gemfile.lock
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- examples/phone.rb
|
34
34
|
- examples/positive.rb
|
35
35
|
- examples/prime_number.rb
|
36
|
+
- examples/quoted.rb
|
36
37
|
- examples/recruiter.rb
|
37
38
|
- examples/triple.rb
|
38
39
|
- examples/worker.rb
|
@@ -66,16 +67,16 @@ require_paths:
|
|
66
67
|
- lib
|
67
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
68
69
|
requirements:
|
69
|
-
- - ~>
|
70
|
+
- - "~>"
|
70
71
|
- !ruby/object:Gem::Version
|
71
72
|
version: '2.0'
|
72
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
74
|
requirements:
|
74
|
-
- -
|
75
|
+
- - ">="
|
75
76
|
- !ruby/object:Gem::Version
|
76
77
|
version: '0'
|
77
78
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
79
|
+
rubygems_version: 3.1.2
|
79
80
|
signing_key:
|
80
81
|
specification_version: 4
|
81
82
|
summary: RSpec AST - All Scenario Testing
|