one44-core 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '099c89845774677bf2058e6566ed7fc7241b7aece8419df65a6e5771f52ce6e8'
4
+ data.tar.gz: b271d368a9aeea59b208d1b3981976d74bc24e93e7b9867aa50dfba322661e1a
5
+ SHA512:
6
+ metadata.gz: 72f42069bf806c2f5cb568c18cd8cb7ee3d2ea8718ff09374f2425d3dfda3a5dae055aad1414e4307d1d9defb876648528d7c41eddfbcf52ec6ff8c3d0b3c2d6
7
+ data.tar.gz: e2a8b2aa3aefb9c3bcc99ffaaa7030db46d546eca1ecc56197f8c89d63206201259a8de9960134b4dfa2241a2aa74949804b3dc19ac30b36437b9f835f3196a1
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'coderay'
6
+ gem 'cucumber', '3.1.2'
7
+ gem 'pry', '0.12.2'
8
+ gem 'rspec', '3.9.0'
9
+ gem 'rspec-wait'
10
+ gem 'rubocop', '0.91.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,80 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ ast (2.4.2)
5
+ backports (3.21.0)
6
+ builder (3.2.4)
7
+ coderay (1.1.3)
8
+ cucumber (3.1.2)
9
+ builder (>= 2.1.2)
10
+ cucumber-core (~> 3.2.0)
11
+ cucumber-expressions (~> 6.0.1)
12
+ cucumber-wire (~> 0.0.1)
13
+ diff-lcs (~> 1.3)
14
+ gherkin (~> 5.1.0)
15
+ multi_json (>= 1.7.5, < 2.0)
16
+ multi_test (>= 0.1.2)
17
+ cucumber-core (3.2.1)
18
+ backports (>= 3.8.0)
19
+ cucumber-tag_expressions (~> 1.1.0)
20
+ gherkin (~> 5.0)
21
+ cucumber-expressions (6.0.1)
22
+ cucumber-tag_expressions (1.1.1)
23
+ cucumber-wire (0.0.1)
24
+ diff-lcs (1.4.4)
25
+ gherkin (5.1.0)
26
+ method_source (0.9.2)
27
+ multi_json (1.15.0)
28
+ multi_test (0.1.2)
29
+ parallel (1.20.1)
30
+ parser (3.0.1.1)
31
+ ast (~> 2.4.1)
32
+ pry (0.12.2)
33
+ coderay (~> 1.1.0)
34
+ method_source (~> 0.9.0)
35
+ rainbow (3.0.0)
36
+ regexp_parser (2.1.1)
37
+ rexml (3.2.5)
38
+ rspec (3.9.0)
39
+ rspec-core (~> 3.9.0)
40
+ rspec-expectations (~> 3.9.0)
41
+ rspec-mocks (~> 3.9.0)
42
+ rspec-core (3.9.3)
43
+ rspec-support (~> 3.9.3)
44
+ rspec-expectations (3.9.4)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.9.0)
47
+ rspec-mocks (3.9.1)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.9.0)
50
+ rspec-support (3.9.4)
51
+ rspec-wait (0.0.9)
52
+ rspec (>= 3, < 4)
53
+ rubocop (0.91.0)
54
+ parallel (~> 1.10)
55
+ parser (>= 2.7.1.1)
56
+ rainbow (>= 2.2.2, < 4.0)
57
+ regexp_parser (>= 1.7)
58
+ rexml
59
+ rubocop-ast (>= 0.4.0, < 1.0)
60
+ ruby-progressbar (~> 1.7)
61
+ unicode-display_width (>= 1.4.0, < 2.0)
62
+ rubocop-ast (0.8.0)
63
+ parser (>= 2.7.1.5)
64
+ ruby-progressbar (1.11.0)
65
+ unicode-display_width (1.7.0)
66
+
67
+ PLATFORMS
68
+ ruby
69
+ x86_64-darwin-20
70
+
71
+ DEPENDENCIES
72
+ coderay
73
+ cucumber (= 3.1.2)
74
+ pry (= 0.12.2)
75
+ rspec (= 3.9.0)
76
+ rspec-wait
77
+ rubocop (= 0.91.0)
78
+
79
+ BUNDLED WITH
80
+ 2.1.4
data/lib/one44-core.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'one44-core/marker'
4
+ require_relative 'one44-core/output'
5
+ require_relative 'one44-core/result'
6
+ require_relative 'one44-core/test'
7
+ require_relative 'one44-core/welcome'
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module One44
4
+ class Marker
5
+ def clean(question)
6
+ question.gsub('x', '*')
7
+ end
8
+
9
+ def mark(question, answer)
10
+ instance_eval(clean(question)) == answer ? 'CORRECT' : 'INCORRECT'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module One44
4
+ class Output
5
+ def messages
6
+ @messages ||= []
7
+ end
8
+
9
+ def print(message)
10
+ messages << message
11
+ end
12
+
13
+ def puts(message)
14
+ print(message)
15
+ print('\n')
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module One44
4
+ class Result
5
+ attr_reader :marks
6
+
7
+ def initialize
8
+ @marks = []
9
+ end
10
+
11
+ def <<(mark)
12
+ @marks << mark
13
+ end
14
+
15
+ def correct
16
+ @marks.map.select { |mark| mark == 'CORRECT' }
17
+ end
18
+
19
+ private
20
+
21
+ def respond_to_missing?(name, include_all: false)
22
+ @marks.respond_to?(name) || super
23
+ end
24
+
25
+ def method_missing(name, *args)
26
+ super unless @marks.respond_to? name
27
+ @marks.send(name, *args)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module One44
4
+ class Test
5
+ attr_reader :marker, :output, :questions
6
+
7
+ def initialize(output)
8
+ @output = output
9
+ @marker = Marker.new
10
+ @results = Result.new
11
+ @welcome = Welcome.new(@output)
12
+ end
13
+
14
+ def start(name, questions)
15
+ @questions = questions
16
+ @welcome.message("Welcome to 144 - #{name}")
17
+ ask_first_question
18
+ end
19
+
20
+ def provide(answer, question = 0)
21
+ @results << @marker.mark(@questions[question], answer)
22
+ @output.print @results.last
23
+ end
24
+
25
+ def result
26
+ @output.print @results.correct.size == @questions.size ? 'PASS' : 'FAIL'
27
+ end
28
+
29
+ private
30
+
31
+ def ask_first_question
32
+ @output.print "#{@questions.first}:"
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module One44
4
+ VERSION = '1.1.2'
5
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module One44
4
+ class Welcome
5
+ def initialize(output)
6
+ @output = output
7
+ end
8
+
9
+ def message(text)
10
+ @output.puts text
11
+ end
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: one44-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Adam Bonsu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-06-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Marks math problems
14
+ email: adam@bonsu.io
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - Gemfile
20
+ - Gemfile.lock
21
+ - lib/one44-core.rb
22
+ - lib/one44-core/marker.rb
23
+ - lib/one44-core/output.rb
24
+ - lib/one44-core/result.rb
25
+ - lib/one44-core/test.rb
26
+ - lib/one44-core/version.rb
27
+ - lib/one44-core/welcome.rb
28
+ homepage: https://github.com/adambonsu/one44-core
29
+ licenses:
30
+ - MIT
31
+ metadata: {}
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.7.0
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubygems_version: 3.1.4
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: You provide the math problems. It marks your answers
51
+ test_files: []