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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc7611cc4a2b2011b02cf20cdfb8f9bc44384339
4
- data.tar.gz: 9e2513c2ab74b6727deabc4d59804af0d41d8209
3
+ metadata.gz: b3a0597bdd7b87c2fc650ff4ef73ab87bec26a6a
4
+ data.tar.gz: 85a4a274cfd8e5462869b2d1c1d80410a918eb9e
5
5
  SHA512:
6
- metadata.gz: 520b6a417ef12a64d3831f236937821c305ebda7c5a850453a10544a184f5b521784ac845163beaad5747f48c1800d7c9454aa25abb23ae38c50428a84494e78
7
- data.tar.gz: 46a0bf18cb3e6b69346f3f4b82c00b652777fca2eeb54cb680adc2cade7f48d03b4d032d7aea4e02807e1ed0ac670391c1a26f705a9210aa3c2a8775ff0d79a7
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. It currently supports drills surrounding complex data structures.
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
 
@@ -17,33 +17,45 @@ module Rubies
17
17
  end
18
18
 
19
19
  def display_splash
20
- puts "\e[H\e[2J"
21
- puts "
22
- .______ __ __ .______ __ _______ _______.
23
- | _ \\ | | | | | _ \\ | | | ____| / |
24
- | |_) | | | | | | |_) | | | | |__ | (----`
25
- | / | | | | | _ < | | | __| \\ \\
26
- | |\\ \\----.| `--' | | |_) | | | | |____.----) |
27
- | _| `._____| \\______/ |______/ |__| |_______|_______/
28
-
29
- ".colorize(:light_magenta)
30
- puts "
31
- ================================================================
32
- LEGEND
33
- NEW : get a new data structure
34
- EXIT: exit program
35
- ================================================================
36
- ".colorize(:light_magenta)
37
- puts "Press enter to continue . . . "
38
-
39
- gets.chomp
40
- puts "\e[H\e[2J"
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
- puts "Press enter to continue . . . "
45
- gets.chomp
46
- puts "\e[H\e[2J"
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
- questioner(data_structure)
118
- prompter(target)
119
- gets.chomp.gsub("\"", "\'")
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
@@ -1,3 +1,3 @@
1
1
  module Rubies
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-01-27 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faker