Pickaxe 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pickaxe.rb +1 -1
- data/lib/pickaxe/cli.rb +1 -1
- data/lib/pickaxe/main.rb +16 -5
- data/lib/pickaxe/test.rb +11 -7
- metadata +3 -3
data/lib/pickaxe.rb
CHANGED
data/lib/pickaxe/cli.rb
CHANGED
@@ -34,7 +34,7 @@ END_OF_BANNER
|
|
34
34
|
Pickaxe::Main.options[:full_test] = true
|
35
35
|
end
|
36
36
|
|
37
|
-
opts.on("--repeat-incorrect", "Repeat questions answered incorrectly") do |v|
|
37
|
+
opts.on("-r", "--repeat-incorrect", "Repeat questions answered incorrectly") do |v|
|
38
38
|
Pickaxe::Main.options[:repeat_incorrect] = true
|
39
39
|
end
|
40
40
|
|
data/lib/pickaxe/main.rb
CHANGED
@@ -137,9 +137,9 @@ END_OF_HELP
|
|
137
137
|
@last_answer = @question.check?(@answers[@question])
|
138
138
|
if Main.options[:repeat_incorrect] and not @question.correct?(@answers[@question])
|
139
139
|
@answers.delete(@question)
|
140
|
+
@question.reset!
|
140
141
|
@questions.insert(@current_index + 1 + rand(@questions.length - @current_index), @question)
|
141
142
|
@questions.delete_at(@current_index)
|
142
|
-
@question.reset!
|
143
143
|
else
|
144
144
|
@current_index += 1
|
145
145
|
end
|
@@ -150,13 +150,24 @@ END_OF_HELP
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
|
153
|
+
LETTERS = ('a'..'z').to_a
|
154
|
+
ANSWER_CONVERTION_HASH = LETTERS[0,10].each_with_index.inject({}) do |m, p|
|
154
155
|
m[((p.last + 1) % 10).to_s] = p.first
|
155
156
|
m
|
156
157
|
end
|
157
|
-
|
158
|
-
def convert_answers(line)
|
159
|
-
line.gsub(/\s+/, "").
|
158
|
+
|
159
|
+
def convert_answers(line)
|
160
|
+
line = line.gsub(/\s+/, "").split("").each_with_index.inject("") do |l, pair|
|
161
|
+
l + if pair.first == "["
|
162
|
+
LETTERS[pair.last]
|
163
|
+
elsif pair.first == "]"
|
164
|
+
""
|
165
|
+
else
|
166
|
+
pair.first
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
line = line.downcase.each_char.collect do |c|
|
160
171
|
ANSWER_CONVERTION_HASH[c] || c
|
161
172
|
end.to_a.uniq
|
162
173
|
end
|
data/lib/pickaxe/test.rb
CHANGED
@@ -161,7 +161,7 @@ module Pickaxe
|
|
161
161
|
#
|
162
162
|
# NOTE: Other languages will remain untouched.
|
163
163
|
#
|
164
|
-
@shuffled_answers.reject! { |a| a.content =~ /(\s+|^)
|
164
|
+
@shuffled_answers.reject! { |a| a.content =~ /(\s+|^)(ż|Ż)ad(na|ne|en)(\s+|$)/ui }
|
165
165
|
reindex_answers(@shuffled_answers)
|
166
166
|
# END OF HACK
|
167
167
|
|
@@ -181,21 +181,25 @@ module Pickaxe
|
|
181
181
|
|
182
182
|
def generate_fourth_answer(answers)
|
183
183
|
correct = correct_answers(answers)
|
184
|
-
answers
|
184
|
+
answers << case correct.length
|
185
185
|
when 0 then
|
186
|
-
|
186
|
+
Answer.new(Answer::EMPTY, "d", true)
|
187
187
|
when 1
|
188
|
-
|
189
|
-
fourth =
|
188
|
+
indices = answer_indices(answers)
|
189
|
+
fourth = [[]]
|
190
|
+
fourth.push(*indices.combination(2).to_a)
|
191
|
+
fourth.push(*indices.combination(3).to_a)
|
192
|
+
|
193
|
+
fourth = fourth.shuffle.first
|
190
194
|
fourth = if fourth.empty?
|
191
195
|
Answer::EMPTY
|
192
196
|
else
|
193
197
|
Answer::CORRECT_ARE % fourth.map(&:upcase).join(", ")
|
194
198
|
end
|
195
|
-
|
199
|
+
Answer.new(fourth, "d", false)
|
196
200
|
else
|
197
201
|
answers.each {|a| a.correctness = false }
|
198
|
-
|
202
|
+
Answer.new(Answer::CORRECT_ARE % correct.map(&:upcase).join(", "), "d", true)
|
199
203
|
end
|
200
204
|
end
|
201
205
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Pickaxe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dawid Fatyga
|