rast 0.6.1.pre → 0.6.2.pre
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/positive.rb +8 -0
- data/lib/rast/rules/rule.rb +7 -7
- data/lib/rast/rules/rule_evaluator.rb +4 -3
- data/rast.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eaf03a698891eb852079e41704e991c2d5e2732376f7966a785e1ca38f8a67f
|
4
|
+
data.tar.gz: 856abb598e0e163878109683e26cc301f3398498b091373a5b26e19f3dacc021
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53b66163427b7fa80ffc986dc27ce26d5c01406fcf5c15362b164dc8d96ee9af49a29c1554555a8a100b7e5a7379ad2c0feebc55ddc4b24d31d52ffd961ec409
|
7
|
+
data.tar.gz: 6026193252d5c2829c68fbeee17932dec81102879edba3feccce0e76fef574ae612116c6a20f06be75216fadfb421874e4da1583d67f89c7a70f2c95245eb856
|
data/CHANGELOG.md
CHANGED
data/lib/rast/rules/rule.rb
CHANGED
@@ -28,11 +28,11 @@ class Rule
|
|
28
28
|
end
|
29
29
|
|
30
30
|
duplicates << outcome
|
31
|
-
clause = remove_spaces(
|
32
|
-
clause = remove_spaces(
|
33
|
-
clause = remove_spaces(
|
34
|
-
clause = remove_spaces(
|
35
|
-
clause = remove_spaces(
|
31
|
+
clause = remove_spaces(token: clause, separator: '\(')
|
32
|
+
clause = remove_spaces(token: clause, separator: '\)')
|
33
|
+
clause = remove_spaces(token: clause, separator: '&')
|
34
|
+
clause = remove_spaces(token: clause, separator: '\|')
|
35
|
+
clause = remove_spaces(token: clause, separator: '!')
|
36
36
|
@outcome_clause_hash[outcome.to_s] = clause.strip
|
37
37
|
end
|
38
38
|
end
|
@@ -47,8 +47,8 @@ class Rule
|
|
47
47
|
# * @param string rule clause.
|
48
48
|
# * @param separator rule clause token.
|
49
49
|
# */
|
50
|
-
def remove_spaces(
|
51
|
-
|
50
|
+
def remove_spaces(token: nil, separator: '')
|
51
|
+
token.to_s.gsub(Regexp.new("\\s*#{separator} \\s*"), separator)
|
52
52
|
end
|
53
53
|
|
54
54
|
# /**
|
@@ -29,6 +29,7 @@ class RuleEvaluator
|
|
29
29
|
DEFAULT_CONVERT_HASH = {
|
30
30
|
Integer => IntConverter.new,
|
31
31
|
Float => FloatConverter.new,
|
32
|
+
Fixnum => FloatConverter.new,
|
32
33
|
TrueClass => BoolConverter.new,
|
33
34
|
FalseClass => BoolConverter.new,
|
34
35
|
String => StrConverter.new
|
@@ -77,7 +78,7 @@ class RuleEvaluator
|
|
77
78
|
if @stack_rpn.empty?
|
78
79
|
true
|
79
80
|
elsif @stack_rpn.size == 1
|
80
|
-
evaluate_one_rpn(scenario: scenario)
|
81
|
+
evaluate_one_rpn(scenario: scenario).to_s
|
81
82
|
else
|
82
83
|
evaluate_multi_rpn(
|
83
84
|
scenario: scenario,
|
@@ -258,11 +259,11 @@ class RuleEvaluator
|
|
258
259
|
def evaluate_one_rpn(scenario: [])
|
259
260
|
single = @stack_rpn.last
|
260
261
|
subscript = extract_subscript(token: single)
|
262
|
+
default_converter = DEFAULT_CONVERT_HASH[scenario.first.class]
|
261
263
|
if subscript > -1
|
262
|
-
default_converter = DEFAULT_CONVERT_HASH[scenario.first.class]
|
263
264
|
scenario[subscript] == default_converter.convert(single[RE_TOKEN_BODY])
|
264
265
|
else
|
265
|
-
scenario.include?
|
266
|
+
scenario.include?(default_converter.convert(single))
|
266
267
|
end
|
267
268
|
end
|
268
269
|
|
data/rast.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Royce Remulla
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- examples/logic_checker.rb
|
32
32
|
- examples/logic_four.rb
|
33
33
|
- examples/phone.rb
|
34
|
+
- examples/positive.rb
|
34
35
|
- examples/prime_number.rb
|
35
36
|
- examples/recruiter.rb
|
36
37
|
- examples/worker.rb
|