lexdrill 0.11.0 → 0.13.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/README.md +4 -3
- data/lib/lexdrill/beat.rb +6 -0
- data/lib/lexdrill/cli.rb +39 -6
- data/lib/lexdrill/counter.rb +4 -0
- data/lib/lexdrill/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a20cfbe4b7db3dbc41bec9f5e6bac7954660f81c5396bd39337b620f78038cfd
|
|
4
|
+
data.tar.gz: 6a26fc1605e888f21569d4109f774d85d753e6e17f6e0a40b220d071cda5549c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 664c053ae57b8f89b78364699dc865067e461086145c8be708e84473df83642966751bdec82c42e977f185dba6ca3799ae8aa65faa2ddd4e34f27245054a79ed
|
|
7
|
+
data.tar.gz: 6d3c8d58b6b1b198857287546c215e519b023d051020bd4980ffe1958a7103bdc1d2167811f28aa1db42d8b93233b85923137b5f39e107c4224042c60fdce7c4
|
data/README.md
CHANGED
|
@@ -192,7 +192,8 @@ anything.
|
|
|
192
192
|
| `drill polka\|waltz\|rock\|jazz\|jiga\|balkan\|samba <repetitions>` | Shorthand for a fixed loop size (see table above) |
|
|
193
193
|
| `drill format simple\|full` | Set the output style (`simple` is the default) |
|
|
194
194
|
| `drill add <text>` | Append a new item to the end of the list |
|
|
195
|
-
| `drill list` |
|
|
195
|
+
| `drill list` | Show how many times each item has been shown, numbered |
|
|
196
196
|
| `drill open` | Open the list file in `$EDITOR`/`$VISUAL` (falls back to `vi`) |
|
|
197
|
-
| `drill stats` |
|
|
198
|
-
| `drill rand <n>` |
|
|
197
|
+
| `drill stats` | Print all items as `<count>\t<phrase>` (tab-separated), sorted by show count, highest first |
|
|
198
|
+
| `drill rand <n>` | `drill next` shows a word ~1-in-`n` times (`n=1` is every time, the default) |
|
|
199
|
+
| `drill go <number>` | Jump so the next `drill next` shows item `<number>` (1-based, see `drill list`) — prints nothing itself; refuses a graduated item; has no effect while `drill beat rand` is active, since that mode ignores the counter entirely |
|
data/lib/lexdrill/beat.rb
CHANGED
|
@@ -80,6 +80,12 @@ module Lexdrill::Beat
|
|
|
80
80
|
loop_info(word_count, step).index
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
+
# The inverse of index_for: the earliest step that lands on target_index,
|
|
84
|
+
# for `drill go` to jump the counter straight to a specific word.
|
|
85
|
+
def self.step_for_index(word_count, target_index)
|
|
86
|
+
(0...cycle_length(word_count)).find { |step| index_for(word_count, step) == target_index }
|
|
87
|
+
end
|
|
88
|
+
|
|
83
89
|
# Full detail on where `step` falls: word index, the current loop's word
|
|
84
90
|
# range, which repeat pass it is, and how many total. A single "loop"
|
|
85
91
|
# spanning the whole list (shown once) when no beat is configured.
|
data/lib/lexdrill/cli.rb
CHANGED
|
@@ -16,7 +16,8 @@ class Lexdrill::CLI
|
|
|
16
16
|
run_list: %w[list],
|
|
17
17
|
run_open: %w[open],
|
|
18
18
|
run_stats: %w[stats],
|
|
19
|
-
run_rand: %w[rand]
|
|
19
|
+
run_rand: %w[rand],
|
|
20
|
+
run_go: %w[go]
|
|
20
21
|
}.freeze
|
|
21
22
|
|
|
22
23
|
def self.start(argv = ARGV)
|
|
@@ -63,10 +64,11 @@ class Lexdrill::CLI
|
|
|
63
64
|
Shorthand for a fixed loop size (2 through 8, in order)
|
|
64
65
|
drill format simple|full Set the output style (simple is the default)
|
|
65
66
|
drill add <text> Append a new item to the end of the list
|
|
66
|
-
drill list
|
|
67
|
+
drill list Show how many times each item has been shown
|
|
67
68
|
drill open Open the list file in $EDITOR/$VISUAL (falls back to vi)
|
|
68
|
-
drill stats
|
|
69
|
+
drill stats Print items as <count>\t<phrase>, tab-separated, highest count first
|
|
69
70
|
drill rand <n> drill next shows a word ~1-in-n times (n=1 is every time)
|
|
71
|
+
drill go <number> Jump so the next `next` shows item <number> (1-based, see drill list)
|
|
70
72
|
HELP
|
|
71
73
|
0
|
|
72
74
|
end
|
|
@@ -220,8 +222,7 @@ class Lexdrill::CLI
|
|
|
220
222
|
return print_no_words(Lexdrill::WordList::PATH) if words.empty?
|
|
221
223
|
|
|
222
224
|
counts = Lexdrill::Stats.counts
|
|
223
|
-
|
|
224
|
-
pairs.each { |count, word| puts "#{count}\t#{word}" }
|
|
225
|
+
words.each_with_index { |word, index| puts "#{index + 1}. #{word} (#{counts.fetch(word, 0)})" }
|
|
225
226
|
0
|
|
226
227
|
end
|
|
227
228
|
|
|
@@ -235,7 +236,8 @@ class Lexdrill::CLI
|
|
|
235
236
|
return print_no_words(Lexdrill::WordList::PATH) if words.empty?
|
|
236
237
|
|
|
237
238
|
counts = Lexdrill::Stats.counts
|
|
238
|
-
words.
|
|
239
|
+
pairs = words.map { |word| [counts.fetch(word, 0), word] }.sort_by { |count, _word| -count }
|
|
240
|
+
pairs.each { |count, word| puts "#{count}\t#{word}" }
|
|
239
241
|
0
|
|
240
242
|
end
|
|
241
243
|
|
|
@@ -252,6 +254,37 @@ class Lexdrill::CLI
|
|
|
252
254
|
1
|
|
253
255
|
end
|
|
254
256
|
|
|
257
|
+
def run_go
|
|
258
|
+
words = Lexdrill::WordList.words
|
|
259
|
+
return print_no_words(Lexdrill::WordList::PATH) if words.empty?
|
|
260
|
+
|
|
261
|
+
total = words.size
|
|
262
|
+
number = argv[1].to_s.to_i
|
|
263
|
+
return print_go_usage(total) unless (1..total).cover?(number)
|
|
264
|
+
|
|
265
|
+
target = words[number - 1]
|
|
266
|
+
return print_go_graduated(target) if Lexdrill::Stats.graduated?(target)
|
|
267
|
+
|
|
268
|
+
jump_to(target)
|
|
269
|
+
0
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def jump_to(target)
|
|
273
|
+
active = Lexdrill::WordList.active_words
|
|
274
|
+
step = Lexdrill::Beat.step_for_index(active.size, active.index(target))
|
|
275
|
+
Lexdrill::Counter.new(Lexdrill::WordList::COUNTER_PATH).set(step)
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def print_go_usage(total)
|
|
279
|
+
warn "usage: drill go <number> (1 through #{total}, see drill list)"
|
|
280
|
+
1
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def print_go_graduated(word)
|
|
284
|
+
warn "drill: #{word.inspect} has already graduated and won't be selected by next"
|
|
285
|
+
1
|
|
286
|
+
end
|
|
287
|
+
|
|
255
288
|
def print_unknown_command(command)
|
|
256
289
|
warn "drill: unknown command #{command.inspect}"
|
|
257
290
|
print_help
|
data/lib/lexdrill/counter.rb
CHANGED
data/lib/lexdrill/version.rb
CHANGED