rubies 0.1.1 → 0.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 +4 -4
- data/README.md +3 -1
- data/lib/rubies/game.rb +53 -30
- data/lib/rubies/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3a0597bdd7b87c2fc650ff4ef73ab87bec26a6a
|
4
|
+
data.tar.gz: 85a4a274cfd8e5462869b2d1c1d80410a918eb9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5668251a28c3a1549a4b9e73fcb1f520bf882dd3f7646147ab9a58ecffe0bb9352fed8293e692e6b977dda65de12ab48117da006959994faf84a3cf5d8ab23fc
|
7
|
+
data.tar.gz: 97c184704fe71a3f18faf5b6267aa892ea5b587fc60fcd6ddb0aceea5e2ff124ad9eae93fd3bb833a3c8a6a4e9a70a1a269babf9ea5e2a30792c89d3c0e2781f
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Rubies
|
2
2
|
|
3
|
-
Newcomers to programming would benefit from practicing drills regularly until basic problem solving becomes second nature. This gem is a command line tool that allows users to solve randomly generated small problems.
|
3
|
+
Newcomers to programming would benefit from practicing drills regularly until basic problem solving becomes second nature. This gem is a command line tool that allows users to solve randomly generated small problems.
|
4
|
+
|
5
|
+
It currently supports drills surrounding simple and complex data structures.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
data/lib/rubies/game.rb
CHANGED
@@ -17,33 +17,45 @@ module Rubies
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def display_splash
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
20
|
+
begin
|
21
|
+
puts "\e[H\e[2J"
|
22
|
+
puts "
|
23
|
+
.______ __ __ .______ __ _______ _______.
|
24
|
+
| _ \\ | | | | | _ \\ | | | ____| / |
|
25
|
+
| |_) | | | | | | |_) | | | | |__ | (----`
|
26
|
+
| / | | | | | _ < | | | __| \\ \\
|
27
|
+
| |\\ \\----.| `--' | | |_) | | | | |____.----) |
|
28
|
+
| _| `._____| \\______/ |______/ |__| |_______|_______/
|
29
|
+
|
30
|
+
".colorize(:light_magenta)
|
31
|
+
puts "
|
32
|
+
================================================================
|
33
|
+
LEGEND
|
34
|
+
NEW : get a new data structure
|
35
|
+
EXIT: exit program
|
36
|
+
================================================================
|
37
|
+
".colorize(:light_magenta)
|
38
|
+
puts "Press enter to continue . . . "
|
39
|
+
|
40
|
+
gets.chomp
|
41
|
+
puts "\e[H\e[2J"
|
42
|
+
rescue Interrupt => e
|
43
|
+
@playing = false
|
44
|
+
byebye
|
45
|
+
exit
|
46
|
+
end
|
41
47
|
end
|
42
48
|
|
43
49
|
def continuer
|
44
|
-
|
45
|
-
|
46
|
-
|
50
|
+
begin
|
51
|
+
puts "Press enter to continue . . . "
|
52
|
+
gets.chomp
|
53
|
+
puts "\e[H\e[2J"
|
54
|
+
rescue Interrupt => e
|
55
|
+
@playing = false
|
56
|
+
byebye
|
57
|
+
exit
|
58
|
+
end
|
47
59
|
end
|
48
60
|
|
49
61
|
def scoreboard(num_right, num_wrong)
|
@@ -71,9 +83,14 @@ module Rubies
|
|
71
83
|
end
|
72
84
|
|
73
85
|
def eprinter(error)
|
86
|
+
encoding_options = {
|
87
|
+
:invalid => :replace, # Replace invalid byte sequences
|
88
|
+
:undef => :replace, # Replace anything not defined in ASCII
|
89
|
+
:replace => '', # Use a blank for those replacements
|
90
|
+
}
|
74
91
|
puts
|
75
92
|
puts "Sorry, that code resulted in an error:".colorize(:light_red)
|
76
|
-
puts "#{error}".colorize(:red)
|
93
|
+
puts "#{error}".encode(Encoding.find('ASCII'), encoding_options).colorize(:red)
|
77
94
|
end
|
78
95
|
|
79
96
|
def itswrong(answer)
|
@@ -114,9 +131,15 @@ module Rubies
|
|
114
131
|
end
|
115
132
|
|
116
133
|
def prompt(data_structure, target)
|
117
|
-
|
118
|
-
|
119
|
-
|
134
|
+
begin
|
135
|
+
questioner(data_structure)
|
136
|
+
prompter(target)
|
137
|
+
gets.chomp.gsub("\"", "\'")
|
138
|
+
rescue Interrupt => e
|
139
|
+
@playing = false
|
140
|
+
byebye
|
141
|
+
exit
|
142
|
+
end
|
120
143
|
end
|
121
144
|
|
122
145
|
def check_answer(current, input, target)
|
@@ -144,7 +167,7 @@ module Rubies
|
|
144
167
|
correct = false
|
145
168
|
current, target = generate_data_structure
|
146
169
|
until correct
|
147
|
-
input = prompt(current, target)
|
170
|
+
input = prompt(current, target).rstrip.lstrip
|
148
171
|
if input == "NEW" || input == "new"
|
149
172
|
return
|
150
173
|
elsif input == "EXIT" || input == "exit"
|
@@ -177,4 +200,4 @@ module Rubies
|
|
177
200
|
end
|
178
201
|
end
|
179
202
|
|
180
|
-
end
|
203
|
+
end
|
data/lib/rubies/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vikram Ramakrishnan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faker
|