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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: adc034a3bca9cb4f89517b83daf17262d21b0cbc0d9ea3f34d461a3b85813019
4
- data.tar.gz: 122e83c3b55aabace04a15e41d02fca0be55a3d6d37e67ffbbcd1eee38c4ec82
3
+ metadata.gz: a7e03f4e3c569cbd461a8387f0990f4c7a48596c87d37cc6e558cf2b89f06398
4
+ data.tar.gz: f0df9996942ddb36e6f7ef2ab6d40da33261547480151c731dc1648989772bfd
5
5
  SHA512:
6
- metadata.gz: 619c067e5e697a676e699a8432149cd95206c5531307ce8a8a97b9e918a3829b1d228852d8520443e44d50e861f329199e2a3138fe3e4ee1f8f4f5a74ffe782e
7
- data.tar.gz: 20b87b3f08e7813025091d092a49fe6af4bd9066cd7f6cb8eef144d99739c9c46e1301f28918f74ef30366818e585a98c690f3d8b8c5de25539fc1531413ce34
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.
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Quoted
4
+
5
+ def identify_sentence_type(sentence)
6
+ return 'exclamation' if (sentence[/.*!/])
7
+
8
+ return 'question' if (sentence[/.*\?/])
9
+
10
+ 'statement'
11
+ end
12
+ end
@@ -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
- spec_config['variables'] = detect_variables(spec_config) if spec_config['variables'].nil?
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],
@@ -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
- tokens = RuleEvaluator.tokenize(clause: expression)
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'rast'
5
- spec.version = '0.10.0'
5
+ spec.version = '0.11.0'
6
6
  spec.authors = ['Royce Remulla']
7
7
  spec.email = ['royce.com@gmail.com']
8
8
 
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.10.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-01 00:00:00.000000000 Z
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.0.8
79
+ rubygems_version: 3.1.2
79
80
  signing_key:
80
81
  specification_version: 4
81
82
  summary: RSpec AST - All Scenario Testing