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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a75378e192af6d720815d27a1b385493f7476ae0a87da7808c826f4ee5183dc2
4
- data.tar.gz: 44099ec4adb8d0820979588663dba46112c119a1367ce5509a5db8331ffa09cd
3
+ metadata.gz: 642ebf5d812f1629111a1343aa879bf7c0a490effa0a57c04700bcb50a53e942
4
+ data.tar.gz: 0f543c7941eaa9623721ce41fb04b85d667d04d854f394e4dc4aef9a9a4c1f0c
5
5
  SHA512:
6
- metadata.gz: 89dabc85a4c1286ad265c1d0ac1d31253bb9866cea69f4710511e0518a7c7daf18a7d2dc9fc0cdbc930efbcae7a0d12bfb0440fa75ced61e5c643ae3287e31c0
7
- data.tar.gz: ffada70d2420ca88dfe82d7fe4ab799c9ccd546a524fef132484e42ee3103a464b429b7b454e4b8dae09508cec7b2d575df2b1209a1f16fbfa3b25a8d32a3cc7
6
+ metadata.gz: 4da481328d52e7c1aacf090243e1b71b9efb73a7c44775455662706fe7b46040d238b384347a912a0ad423a27c72e65f1c84d677e1be091c431704d6405e4ea8
7
+ data.tar.gz: b8aca5f3067e7358858358f414fa4df3d8d506a4fde789ae3dbcd388da56e45ec1ede5c9560dbf4f29a1c9fb7479ed3b9f4739b98d1718638b12cd41dc0d4a9c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2022-04-07
4
+
5
+ - Now, you can see the questions you answered incorrectly with typing `bundle exec rake install`.
6
+
3
7
  ## [0.1.0] - 2022-04-07
4
8
 
5
9
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- teihitsu_training_cli (0.1.2)
4
+ teihitsu_training_cli (0.2.0)
5
5
  thor (~> 1.2, >= 1.2.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
- # TeihitsuTrainingCli
1
+ # Teihitsu Training CLI
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/teihitsu_training_cli.svg)](https://badge.fury.io/rb/teihitsu_training_cli)
3
4
  [![Ruby](https://github.com/yudukikun5120/teihitsu_training_cli/actions/workflows/main.yml/badge.svg)](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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TeihitsuTrainingCli
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -10,16 +10,23 @@ require "thor"
10
10
  class Trng < Thor
11
11
  package_name "Teihitsu Training CLI"
12
12
 
13
- default_command :onyomi
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(item)
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 "✅\n別答:#{alt_answers&.join}" unless alt_answers&.empty?
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("result.txt", "a") do |io|
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
- desc "onyomi", "The questions will be taken from the onyomi section"
64
- def onyomi
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
- start = options[:start] ? (options[:start].to_i - 1) : 0
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
- items = CSV.read("problems/onyomi.csv")[start..]
91
+ desc "result", "Show the questions you answered incorrectly."
92
+ def result
93
+ file_path = File.expand_path("result.txt", __dir__)
70
94
 
71
- items.each do |i|
72
- item = Item.new(i)
73
- item.quiz
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.1.2
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-06 00:00:00.000000000 Z
11
+ date: 2022-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor