Pickaxe 0.6.2 → 0.6.3
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.
- data/lib/pickaxe.rb +1 -1
- data/lib/pickaxe/cli.rb +13 -16
- data/lib/pickaxe/main.rb +5 -4
- data/lib/pickaxe/test.rb +6 -6
- metadata +3 -3
data/lib/pickaxe.rb
CHANGED
data/lib/pickaxe/cli.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
|
3
|
-
options = { :extension => "txt" }
|
4
3
|
parser = OptionParser.new do |opts|
|
5
4
|
opts.banner = <<END_OF_BANNER
|
6
5
|
Usage:
|
@@ -12,43 +11,43 @@ END_OF_BANNER
|
|
12
11
|
opts.separator ""
|
13
12
|
opts.on("-e", "--ext [EXTENSION]", "Use files with given EXTENSION " +
|
14
13
|
"(default 'txt')") do |extension|
|
15
|
-
options[:extension] = extension
|
14
|
+
Pickaxe::Main.options[:extension] = extension
|
16
15
|
end
|
17
16
|
|
18
17
|
opts.on("-s", "--sorted", "Do not shuffle questions") do |v|
|
19
|
-
options[:sorted] = true
|
18
|
+
Pickaxe::Main.options[:sorted] = true
|
20
19
|
end
|
21
20
|
|
22
21
|
opts.on("--sorted-answers", "Do not shuffle answers") do |v|
|
23
|
-
options[:sorted_answers] = true
|
22
|
+
Pickaxe::Main.options[:sorted_answers] = true
|
24
23
|
end
|
25
24
|
|
26
25
|
opts.on("--select [NUMBER]", "Select certain number of questions") do |v|
|
27
|
-
options[:select] = Integer(v)
|
26
|
+
Pickaxe::Main.options[:select] = Integer(v)
|
28
27
|
end
|
29
28
|
|
30
29
|
opts.on("--full-test", "Checks test after all questions are answered") do |v|
|
31
|
-
options[:full_test] = true
|
30
|
+
Pickaxe::Main.options[:full_test] = true
|
32
31
|
end
|
33
32
|
|
34
33
|
opts.on("--repeat-incorrect", "Repeat questions answered incorrectly") do |v|
|
35
|
-
options[:repeat_incorrect] = true
|
34
|
+
Pickaxe::Main.options[:repeat_incorrect] = true
|
36
35
|
end
|
37
36
|
|
38
37
|
opts.on("--strict", "Quit on syntax error in test file") do |v|
|
39
|
-
options[:strict] = true
|
38
|
+
Pickaxe::Main.options[:strict] = true
|
40
39
|
end
|
41
40
|
|
42
41
|
opts.on_tail("--syntax-check", "Check syntax only - do not run test") do
|
43
|
-
options[:syntax_check] = true
|
42
|
+
Pickaxe::Main.options[:syntax_check] = true
|
44
43
|
end
|
45
44
|
|
46
45
|
opts.on("--clear", "Turn on shell clearing before question") do |v|
|
47
|
-
options[:clear] = true
|
46
|
+
Pickaxe::Main.options[:clear] = true
|
48
47
|
end
|
49
48
|
|
50
49
|
opts.on("--no-color", "Turn off colors") do |v|
|
51
|
-
options[:no_colors] = true
|
50
|
+
Pickaxe::Main.options[:no_colors] = true
|
52
51
|
end
|
53
52
|
|
54
53
|
opts.on_tail("--version", "Show version") do
|
@@ -65,8 +64,6 @@ end
|
|
65
64
|
begin
|
66
65
|
parser.parse!
|
67
66
|
|
68
|
-
Pickaxe::Main.options = options
|
69
|
-
|
70
67
|
if Pickaxe::WINDOWS_IT_IS
|
71
68
|
$stderr.puts <<END_OF_MESSAGE
|
72
69
|
! Hi there Windows user.
|
@@ -81,11 +78,11 @@ END_OF_MESSAGE
|
|
81
78
|
|
82
79
|
end
|
83
80
|
|
84
|
-
if options[:full_test] and options[:repeat_incorrect]
|
81
|
+
if Pickaxe::Main.options[:full_test] and Pickaxe::Main.options[:repeat_incorrect]
|
85
82
|
$stderr.puts(("! --full-test disables the --repeat-incorrect option" ).color(:yellow))
|
86
|
-
options[:repeat_incorrect] = false
|
83
|
+
Pickaxe::Main.options[:repeat_incorrect] = false
|
87
84
|
end
|
88
|
-
Pickaxe::Main.new(ARGV
|
85
|
+
Pickaxe::Main.new(ARGV)
|
89
86
|
rescue Pickaxe::PickaxeError, OptionParser::InvalidOption => e
|
90
87
|
$stderr.puts(("! " + e.to_s).color(:red))
|
91
88
|
end
|
data/lib/pickaxe/main.rb
CHANGED
@@ -4,6 +4,7 @@ module Pickaxe
|
|
4
4
|
class TabTermination < PickaxeError; end
|
5
5
|
|
6
6
|
cattr_accessor :options
|
7
|
+
self.options = { :extension => "txt" }
|
7
8
|
|
8
9
|
END_OF_TEST_MESSAGE = <<END_OF_TEST
|
9
10
|
This is the end of this test and You can now jump back to
|
@@ -14,11 +15,11 @@ If You do not know how to jump back type `?' and press [ENTER].
|
|
14
15
|
Hit [ENTER] to rate the test and see Your incorrect answers.
|
15
16
|
END_OF_TEST
|
16
17
|
|
17
|
-
def initialize(paths
|
18
|
+
def initialize(paths)
|
18
19
|
raise NoTests, "no tests to run" if paths.empty?
|
19
20
|
|
20
21
|
@test = Test.new(*paths)
|
21
|
-
return if options[:syntax_check]
|
22
|
+
return if Main.options[:syntax_check]
|
22
23
|
|
23
24
|
@logger = Logger.new(File.open('answers.log',
|
24
25
|
File::WRONLY|File::APPEND|File::CREAT))
|
@@ -86,7 +87,7 @@ END_OF_TEST
|
|
86
87
|
def command(line)
|
87
88
|
@last_answer = nil
|
88
89
|
|
89
|
-
case line
|
90
|
+
case line.strip
|
90
91
|
when /^\s*@\s*(.+)/ then # @ question
|
91
92
|
@current_index = Integer($1) -1
|
92
93
|
true
|
@@ -106,7 +107,7 @@ END_OF_TEST
|
|
106
107
|
else
|
107
108
|
error "You are at last question"
|
108
109
|
end
|
109
|
-
when "
|
110
|
+
when "" then
|
110
111
|
if Main.options[:full_test] and @question.nil?
|
111
112
|
Main.options[:full_test] = false
|
112
113
|
Main.options[:force_show_answers] = true
|
data/lib/pickaxe/test.rb
CHANGED
@@ -63,19 +63,19 @@ module Pickaxe
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
def each(&block)
|
67
|
-
shuffled_questions.each(&block)
|
66
|
+
def each(options = Main.options, &block)
|
67
|
+
shuffled_questions(options).each(&block)
|
68
68
|
end
|
69
69
|
|
70
|
-
def shuffled_questions
|
71
|
-
questions = if
|
70
|
+
def shuffled_questions(options = Main.options)
|
71
|
+
questions = if options[:sorted]
|
72
72
|
@questions
|
73
73
|
else
|
74
74
|
@questions.shuffle
|
75
75
|
end
|
76
76
|
|
77
|
-
@selected = if
|
78
|
-
questions[0...(
|
77
|
+
@selected = if options[:select]
|
78
|
+
questions[0...(options[:select])]
|
79
79
|
else
|
80
80
|
questions
|
81
81
|
end
|
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
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 3
|
10
|
+
version: 0.6.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dawid Fatyga
|