rast 0.11.0 → 0.11.1

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: a7e03f4e3c569cbd461a8387f0990f4c7a48596c87d37cc6e558cf2b89f06398
4
- data.tar.gz: f0df9996942ddb36e6f7ef2ab6d40da33261547480151c731dc1648989772bfd
3
+ metadata.gz: 41552418a05e49304983f930971458922fcf11fde6bccf8dae18e4060d6e9d8b
4
+ data.tar.gz: 0ee2d4c4c2067859512a7a3c21660bee75dad52039d18cf595ea20364b8fc01b
5
5
  SHA512:
6
- metadata.gz: 1045f74d81616e6e6a5cc984d3460fa4d889a8a8063d33bb801c20ca8abebe03b2f8b73e41fd2aaa97164cf3aae3a861103978a751e69999bee623d747970dd4
7
- data.tar.gz: c263c3f383e2113b0551859712ced10966d544be95e8e6e554930ae32b48c61a0030ddaf15cc594bc7bdfde0b0395de554544f31e9aa25f84cc4197c0198a660
6
+ metadata.gz: d0720553986661d0c8a666658d211b2f762a820b48a6882570a6b7c6fbb47d5655c1be3f8662eae3855d388bceb097dc9ddbbffce5e1450af115e2beb91fa811
7
+ data.tar.gz: bfc3fc611a0b45228350b3772112a10bba087ccc5cd939878a7451b970620ee8dfbb1d2d92c453fc0528d09b7ea6acc142294e31713a5dabc1add1b784d2e280
data/CHANGELOG.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Change log
2
2
 
3
+ - 0.11.1 - Add dependency to Factory girl, fixes to examples
3
4
  - 0.11.0 - Raw array as clause to support spaces and operator characters.
4
5
  - 0.10.0 - Optional variables definition for 1 to 1 rules.
5
6
  - 0.9.0 - execute return value is now the expected outcome (removed result method)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Checks bug introduced when converters was combined with token converter.
3
+ # Checks bug introduced when converters are combined with token converter.
4
4
  #
5
5
  # @author Royce Remulla
6
6
  #
@@ -0,0 +1,78 @@
1
+ # Used to determine if cards form quiz type
2
+ # S postfix means Single option, M postfix means Multiple options
3
+ module QuizModule
4
+ RE_SELECTED = /(?<=\([*x]\)\s).*/.freeze
5
+ RE_CHECKED = /(?<=\[[*x]\]\s).*/.freeze
6
+ RE_WRONG_OPT_S = /(?<=\(\)\s).*/.freeze
7
+ RE_WRONG_OPT_M = /(?<=\[\]\s).*/.freeze
8
+
9
+ RE_QUIZ_OPTION_S = Regexp.new(
10
+ "#{RE_WRONG_OPT_S}|#{RE_SELECTED}",
11
+ Regexp::IGNORECASE
12
+ )
13
+
14
+ RE_QUIZ_OPTION_M = Regexp.new(
15
+ "#{RE_WRONG_OPT_M}|#{RE_CHECKED}",
16
+ Regexp::IGNORECASE
17
+ )
18
+
19
+ def quiz?(front = nil, back = nil)
20
+ initialized = [true, false].include? @quiz
21
+ @quiz = quiz_choice?(back) || quiz_fill_blank?(front) unless initialized
22
+ @quiz
23
+ end
24
+
25
+ def quiz_choice?(back = nil)
26
+ initialized = [true, false].include? @choice
27
+ unless initialized
28
+ @choice = quiz_single_choice?(back) || quiz_multi_choice?(back)
29
+ end
30
+
31
+ @choice
32
+ end
33
+
34
+ def quiz_multi_choice?(back)
35
+ if back.is_a?(Array) && back.any?
36
+ back.each { |element| return false unless element[RE_QUIZ_OPTION_M] }
37
+
38
+ # Find at least 1 checked answer
39
+ return false unless back.find do |element|
40
+ true if element[RE_CHECKED]
41
+ end
42
+
43
+ @quiz = true
44
+ @front_only = true
45
+ return true
46
+ end
47
+ false
48
+ end
49
+
50
+ def quiz_single_choice?(back)
51
+ if back.is_a?(Array) && back.any?
52
+ back.each { |element| return false unless element[RE_QUIZ_OPTION_S] }
53
+
54
+ # Find at least 1 selected answer
55
+ selected = back.filter do |element|
56
+ true if element[RE_SELECTED]
57
+ end
58
+ return false unless selected.size == 1
59
+
60
+ @quiz = true
61
+ @front_only = true
62
+ return true
63
+ end
64
+ false
65
+ end
66
+
67
+ def quiz_fill_blank?(front)
68
+ return true if (front.size == 1) && front.first[/_____/]
69
+
70
+ false
71
+ end
72
+
73
+ private
74
+
75
+ def choices_with_header(back)
76
+
77
+ end
78
+ end
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.11.0'
5
+ spec.version = '0.11.1'
6
6
  spec.authors = ['Royce Remulla']
7
7
  spec.email = ['royce.com@gmail.com']
8
8
 
@@ -12,6 +12,8 @@ Gem::Specification.new do |spec|
12
12
  spec.license = 'MIT'
13
13
  spec.required_ruby_version = Gem::Requirement.new('~> 2.0')
14
14
 
15
+ spec.add_runtime_dependency 'factory_girl', '~> 4.7'
16
+
15
17
  # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
16
18
  spec.metadata['homepage_uri'] = spec.homepage
17
19
  spec.metadata['source_code_uri'] = 'https://github.com/roycetech/rast'
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.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Royce Remulla
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2020-05-02 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: factory_girl
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.7'
13
27
  description: Extends RSpec functionality by using the catch-all-scenario testing (CAST)
14
28
  principle.
15
29
  email:
@@ -33,6 +47,7 @@ files:
33
47
  - examples/phone.rb
34
48
  - examples/positive.rb
35
49
  - examples/prime_number.rb
50
+ - examples/quiz_module.rb
36
51
  - examples/quoted.rb
37
52
  - examples/recruiter.rb
38
53
  - examples/triple.rb