teihitsu_training_cli 0.1.2 → 0.2.0
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/teihitsu_training_cli/version.rb +1 -1
- data/lib/teihitsu_training_cli.rb +52 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 642ebf5d812f1629111a1343aa879bf7c0a490effa0a57c04700bcb50a53e942
|
4
|
+
data.tar.gz: 0f543c7941eaa9623721ce41fb04b85d667d04d854f394e4dc4aef9a9a4c1f0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4da481328d52e7c1aacf090243e1b71b9efb73a7c44775455662706fe7b46040d238b384347a912a0ad423a27c72e65f1c84d677e1be091c431704d6405e4ea8
|
7
|
+
data.tar.gz: b8aca5f3067e7358858358f414fa4df3d8d506a4fde789ae3dbcd388da56e45ec1ede5c9560dbf4f29a1c9fb7479ed3b9f4739b98d1718638b12cd41dc0d4a9c
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Teihitsu Training CLI
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/teihitsu_training_cli)
|
3
4
|
[](https://github.com/yudukikun5120/teihitsu_training_cli/actions/workflows/main.yml)
|
4
5
|
|
5
6
|
Teihitsu Training CLI is a simple quiz application based on CLI. It enables us to solve a huge amount of [Kanji Teihitsu][kanjiteihitsu-homepage] questions in numerical order rather than randomly.
|
@@ -24,7 +25,6 @@ Or install it yourself as:
|
|
24
25
|
|
25
26
|
## Usage
|
26
27
|
|
27
|
-
cd teihitsu-training-cli
|
28
28
|
trng
|
29
29
|
|
30
30
|
### Options
|
@@ -10,16 +10,23 @@ require "thor"
|
|
10
10
|
class Trng < Thor
|
11
11
|
package_name "Teihitsu Training CLI"
|
12
12
|
|
13
|
-
default_command :
|
13
|
+
default_command :question
|
14
14
|
|
15
15
|
method_option :start,
|
16
16
|
aliases: "-s",
|
17
|
-
desc: "Specify the index of the item you want to start"
|
17
|
+
desc: "Specify the index of the item you want to start",
|
18
|
+
type: :numeric,
|
19
|
+
default: 1
|
20
|
+
|
21
|
+
method_option :category,
|
22
|
+
aliases: "-c",
|
23
|
+
desc: "Specify the category of the items",
|
24
|
+
type: :string,
|
25
|
+
default: "onyomi"
|
18
26
|
|
19
27
|
# define the quiz item
|
20
28
|
class Item
|
21
|
-
def initialize(
|
22
|
-
(@index, @question, @_level, @answer, @alt_answer, @note) = item
|
29
|
+
def initialize(_item)
|
23
30
|
@answers = [@answer, @alt_answer].compact
|
24
31
|
end
|
25
32
|
|
@@ -33,7 +40,8 @@ class Trng < Thor
|
|
33
40
|
def test(user_answer)
|
34
41
|
if @answers.include?(user_answer)
|
35
42
|
alt_answers = (@answers - [user_answer]).compact
|
36
|
-
puts "
|
43
|
+
puts "✅"
|
44
|
+
puts "別答:#{alt_answers&.join}" unless alt_answers&.empty?
|
37
45
|
else
|
38
46
|
puts "❌\n正答:"
|
39
47
|
@answers.map { |e| puts e.to_s }
|
@@ -41,8 +49,6 @@ class Trng < Thor
|
|
41
49
|
end
|
42
50
|
end
|
43
51
|
|
44
|
-
private
|
45
|
-
|
46
52
|
def write_result
|
47
53
|
result = <<~"RESULT"
|
48
54
|
[#{@index}] #{@question}
|
@@ -54,23 +60,54 @@ class Trng < Thor
|
|
54
60
|
|
55
61
|
RESULT
|
56
62
|
|
57
|
-
File.open(
|
63
|
+
File.open(
|
64
|
+
File.expand_path("result.txt", __dir__), "a"
|
65
|
+
) do |io|
|
58
66
|
io.write(result)
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
63
|
-
|
64
|
-
|
71
|
+
# define the onyomi item
|
72
|
+
class Onyomi < Item
|
73
|
+
def initialize(item)
|
74
|
+
(@index, @question, @_level, @answer, @alt_answer, @note) = item
|
75
|
+
super
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "question", "The questions will be listed in numerical order."
|
80
|
+
def question
|
65
81
|
puts "©︎ 2022 Teihitsu Training"
|
66
82
|
|
67
|
-
|
83
|
+
items[(options[:start] - 1)..].each do |i|
|
84
|
+
item = Trng.const_get(
|
85
|
+
options[:category].capitalize
|
86
|
+
).new i
|
87
|
+
item.quiz
|
88
|
+
end
|
89
|
+
end
|
68
90
|
|
69
|
-
|
91
|
+
desc "result", "Show the questions you answered incorrectly."
|
92
|
+
def result
|
93
|
+
file_path = File.expand_path("result.txt", __dir__)
|
70
94
|
|
71
|
-
|
72
|
-
|
73
|
-
|
95
|
+
puts "There are no questions you answered incorrectly." if FileTest.empty? file_path
|
96
|
+
|
97
|
+
io = File.open(file_path)
|
98
|
+
|
99
|
+
io.readlines.each do |line|
|
100
|
+
puts line
|
101
|
+
end
|
102
|
+
|
103
|
+
io.close
|
104
|
+
end
|
105
|
+
|
106
|
+
no_commands do
|
107
|
+
def items
|
108
|
+
CSV.read(
|
109
|
+
File.expand_path("problems/#{options[:category]}.csv", __dir__)
|
110
|
+
)
|
74
111
|
end
|
75
112
|
end
|
76
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teihitsu_training_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuzuki Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|