lexdrill 0.4.0 → 0.6.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 +23 -9
- data/lib/lexdrill/cli.rb +1 -1
- data/lib/lexdrill/config.rb +4 -0
- data/lib/lexdrill/default_words.rb +30 -0
- data/lib/lexdrill/format.rb +5 -4
- data/lib/lexdrill/line_formatter.rb +4 -5
- data/lib/lexdrill/shell_snippet.rb +11 -4
- data/lib/lexdrill/version.rb +1 -1
- data/lib/lexdrill/word_list.rb +13 -2
- data/lib/lexdrill.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5cc865e919348867e13b05201ac159f40f7f7fce166f44d31b98cd92d0db757b
|
|
4
|
+
data.tar.gz: c3a93dc3474fe2cafcddb60d4cd25ee3350e66c4f487c8f99878a9d09e71f01f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df405a270f001707c86ad9e9e0d3104bb822e3eb337c7ab6afb0ad3a320aaf4fece4b1f727ccabfaf09f3fc804903876012f1ef348dd613473aeb962b2a1cbd4
|
|
7
|
+
data.tar.gz: 6849d9d157bd2c634f5687b4ac194bf3d38b2357092d1344ebc38533708723009d52e93a4445988aafe36fcfa3a61b1ec589716588c925f9115fe9d0571f0ae0
|
data/README.md
CHANGED
|
@@ -40,10 +40,20 @@ banana
|
|
|
40
40
|
cherry
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
If you don't create one, `drill next` seeds `~/.drill.txt` with a default
|
|
44
|
+
starter list (a set of NLP presuppositions) the first time it runs, so
|
|
45
|
+
there's always something to drill.
|
|
46
|
+
|
|
43
47
|
Run `drill next` to print the current word and advance to the next one.
|
|
44
|
-
There are two output styles (`drill format simple|full`, `
|
|
48
|
+
There are two output styles (`drill format simple|full`, `simple` is the
|
|
45
49
|
default):
|
|
46
50
|
|
|
51
|
+
**simple** — the drill sign (always blue), a space, then the word (in a
|
|
52
|
+
separately-picked random color), all on one line:
|
|
53
|
+
```
|
|
54
|
+
⟳ apple
|
|
55
|
+
```
|
|
56
|
+
|
|
47
57
|
**full** — `counter/total⟳[loop_start-loop_end]` on one line, the word on
|
|
48
58
|
the next, in a randomly-picked color:
|
|
49
59
|
```
|
|
@@ -52,13 +62,6 @@ apple
|
|
|
52
62
|
```
|
|
53
63
|
(word 1 of 6 total; currently in the loop spanning words 1-3)
|
|
54
64
|
|
|
55
|
-
**simple** — three drill signs (always blue), then the word on its own
|
|
56
|
-
line in a separately-picked random color:
|
|
57
|
-
```
|
|
58
|
-
⟳⟳⟳
|
|
59
|
-
apple
|
|
60
|
-
```
|
|
61
|
-
|
|
62
65
|
### Shell integration (one-time setup)
|
|
63
66
|
|
|
64
67
|
Add one line to your shell's rc file so the current word prints automatically
|
|
@@ -107,6 +110,17 @@ everything looks correctly configured.
|
|
|
107
110
|
hook block above, so it runs first) instead of relying on it only being in
|
|
108
111
|
`~/.zlogin` / `~/.bash_profile`. It's safe to leave it in both places.
|
|
109
112
|
|
|
113
|
+
#### Word only shows once per session, then stops (bash)
|
|
114
|
+
|
|
115
|
+
The bash hook works by appending a `$(drill_precmd)` command substitution to
|
|
116
|
+
`PS1`, which bash re-evaluates on every prompt render — this is deliberate,
|
|
117
|
+
since some environments (notably Google Cloud Shell's `bashrc.google`)
|
|
118
|
+
snapshot and unconditionally overwrite `PROMPT_COMMAND` after your `.bashrc`
|
|
119
|
+
runs, silently dropping anything hooked in that way. If you installed an
|
|
120
|
+
older version of the hook and see the word print exactly once and never
|
|
121
|
+
again, re-run `drill hook bash` and update the line in your `.bashrc` to the
|
|
122
|
+
current snippet.
|
|
123
|
+
|
|
110
124
|
### Rhythm (`beat`)
|
|
111
125
|
|
|
112
126
|
By default `next` just advances one word at a time. You can instead have it
|
|
@@ -147,4 +161,4 @@ There are also named shortcuts for common loop sizes, one word/phrase apart:
|
|
|
147
161
|
| `drill hook zsh\|bash` | Print the shell integration snippet (used above) |
|
|
148
162
|
| `drill beat <2-8> <repetitions>` / `drill beat none` | Set or disable the rhythm |
|
|
149
163
|
| `drill polka\|waltz\|rock\|jazz\|jiga\|balkan\|samba <repetitions>` | Shorthand for a fixed loop size (see table above) |
|
|
150
|
-
| `drill format simple\|full` | Set the output style (`
|
|
164
|
+
| `drill format simple\|full` | Set the output style (`simple` is the default) |
|
data/lib/lexdrill/cli.rb
CHANGED
|
@@ -55,7 +55,7 @@ class Lexdrill::CLI
|
|
|
55
55
|
drill beat none Disable the rhythm
|
|
56
56
|
drill polka|waltz|rock|jazz|jiga|balkan|samba [repetitions]
|
|
57
57
|
Shorthand for a fixed loop size (2 through 8, in order)
|
|
58
|
-
drill format simple|full Set the output style (
|
|
58
|
+
drill format simple|full Set the output style (simple is the default)
|
|
59
59
|
HELP
|
|
60
60
|
0
|
|
61
61
|
end
|
data/lib/lexdrill/config.rb
CHANGED
|
@@ -13,6 +13,10 @@ module Lexdrill::Config
|
|
|
13
13
|
ENV.fetch("LEXDRILL_PATH", nil) || dir_path || Dir.home
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
def self.home_drill_path
|
|
17
|
+
File.join(Dir.home, FILENAME)
|
|
18
|
+
end
|
|
19
|
+
|
|
16
20
|
DRILL_PATH = File.join(base_path, FILENAME)
|
|
17
21
|
COUNTER_PATH = File.join(base_path, COUNTER_FILENAME)
|
|
18
22
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The starter list seeded into ~/.drill.txt on first run, when neither an
|
|
4
|
+
# LEXDRILL_PATH override nor a project-local .drill.txt exists yet.
|
|
5
|
+
module Lexdrill::DefaultWords
|
|
6
|
+
WORDS = [
|
|
7
|
+
"The map is not the territory",
|
|
8
|
+
"Respect for other people's model of the world",
|
|
9
|
+
"Mind and body are parts of the same system",
|
|
10
|
+
"You cannot not communicate",
|
|
11
|
+
"The meaning of your communication is the response you get",
|
|
12
|
+
"People operate out of the best choice available to them",
|
|
13
|
+
"Every behavior has a positive intention",
|
|
14
|
+
"People have all the resources they need to succeed",
|
|
15
|
+
"There is no failure only feedback",
|
|
16
|
+
"If what you are doing isn't working do something else",
|
|
17
|
+
"The person with the most flexibility controls the system",
|
|
18
|
+
"Choice is better than no choice",
|
|
19
|
+
"If one person can do something anyone can learn to do it",
|
|
20
|
+
"Modeling successful performance leads to excellence",
|
|
21
|
+
"All procedures should increase wholeness and choice",
|
|
22
|
+
"Individuals are not their behaviors",
|
|
23
|
+
"Resistance in a listener is a sign of a lack of flexibility in the communicator",
|
|
24
|
+
"We process all information through our five senses",
|
|
25
|
+
"Clean feedback is the breakfast of champions",
|
|
26
|
+
"Possible in the world is possible for me it is only a matter of how"
|
|
27
|
+
].freeze
|
|
28
|
+
|
|
29
|
+
TEXT = "#{WORDS.join("\n")}\n".freeze
|
|
30
|
+
end
|
data/lib/lexdrill/format.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Global display mode for `next`'s output: "
|
|
4
|
-
# "
|
|
3
|
+
# Global display mode for `next`'s output: "simple" (the drill sign + word)
|
|
4
|
+
# or "full" (position + loop info). Lives at ~/.drill.format; defaults to
|
|
5
|
+
# "simple".
|
|
5
6
|
module Lexdrill::Format
|
|
6
7
|
PATH = File.join(Dir.home, ".drill.format")
|
|
7
8
|
SIMPLE = "simple"
|
|
@@ -9,10 +10,10 @@ module Lexdrill::Format
|
|
|
9
10
|
VALID = [SIMPLE, FULL].freeze
|
|
10
11
|
|
|
11
12
|
def self.current
|
|
12
|
-
return
|
|
13
|
+
return SIMPLE unless File.exist?(PATH)
|
|
13
14
|
|
|
14
15
|
value = File.read(PATH).strip
|
|
15
|
-
VALID.include?(value) ? value :
|
|
16
|
+
VALID.include?(value) ? value : SIMPLE
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def self.set(mode)
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Formats a shown word for display. In "simple" mode:
|
|
4
|
-
# blue, then the word
|
|
5
|
-
# In "full" mode (the default):
|
|
3
|
+
# Formats a shown word for display. In "simple" mode: the drill sign (in
|
|
4
|
+
# blue), a space, then the word (in a separately-picked random color), all
|
|
5
|
+
# on one line. In "full" mode (the default):
|
|
6
6
|
# "{counter}/{total}{SEPARATOR}[{loop_start}-{loop_end}]\n{word}" — counter
|
|
7
7
|
# is the word's own 1-based position in the list, re-derived through
|
|
8
8
|
# Lexdrill::Beat so it stays meaningful even when a rhythm repeats steps.
|
|
9
9
|
module Lexdrill::LineFormatter
|
|
10
10
|
SEPARATOR = "⟳"
|
|
11
|
-
SIMPLE_HEADER = SEPARATOR * 3
|
|
12
11
|
|
|
13
12
|
def self.format(word)
|
|
14
13
|
return simple(word) if Lexdrill::Format.simple?
|
|
@@ -17,7 +16,7 @@ module Lexdrill::LineFormatter
|
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
def self.simple(word)
|
|
20
|
-
"#{Lexdrill::Colorizer.paint_blue(
|
|
19
|
+
"#{Lexdrill::Colorizer.paint_blue(SEPARATOR)} #{Lexdrill::Colorizer.paint(word)}"
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
def self.full(word)
|
|
@@ -12,14 +12,21 @@ module Lexdrill::ShellSnippet
|
|
|
12
12
|
fi
|
|
13
13
|
SNIPPET
|
|
14
14
|
|
|
15
|
+
# Hooks via PS1 (re-evaluated on every prompt) rather than PROMPT_COMMAND,
|
|
16
|
+
# since some environments (e.g. Google Cloud Shell's bashrc.google) snapshot
|
|
17
|
+
# and overwrite PROMPT_COMMAND after the fact, silently dropping anything
|
|
18
|
+
# appended to it. Output goes straight to /dev/tty so the word is never
|
|
19
|
+
# captured into the PS1 string itself (which would need readline's `\[..\]`
|
|
20
|
+
# non-printing markers to avoid cursor/line-wrap glitches from the color
|
|
21
|
+
# codes).
|
|
15
22
|
BASH = <<~SNIPPET
|
|
16
23
|
drill_precmd() {
|
|
17
24
|
[ -f "$HOME/.drill.disabled" ] && return
|
|
18
|
-
command drill next 2>/dev/null
|
|
25
|
+
command drill next >/dev/tty 2>/dev/null
|
|
19
26
|
}
|
|
20
|
-
case "
|
|
21
|
-
*
|
|
22
|
-
*)
|
|
27
|
+
case "$PS1" in
|
|
28
|
+
*'$(drill_precmd)'*) ;;
|
|
29
|
+
*) PS1="${PS1}"'$(drill_precmd)' ;;
|
|
23
30
|
esac
|
|
24
31
|
SNIPPET
|
|
25
32
|
|
data/lib/lexdrill/version.rb
CHANGED
data/lib/lexdrill/word_list.rb
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Reads vocabulary words/phrases from a `.drill.txt` file, one per line, and
|
|
4
|
-
# advances a persisted counter to show "the current word" each time.
|
|
4
|
+
# advances a persisted counter to show "the current word" each time. On a
|
|
5
|
+
# fresh install with no project-local or LEXDRILL_PATH-overridden list, seeds
|
|
6
|
+
# ~/.drill.txt with a default starter list instead of coming up empty.
|
|
5
7
|
class Lexdrill::WordList
|
|
6
8
|
PATH = Lexdrill::Config::DRILL_PATH
|
|
7
9
|
COUNTER_PATH = Lexdrill::Config::COUNTER_PATH
|
|
10
|
+
HOME_PATH = Lexdrill::Config.home_drill_path
|
|
8
11
|
|
|
9
12
|
def self.words
|
|
10
|
-
|
|
13
|
+
seed_default_at_home
|
|
14
|
+
@words ||= File.exist?(PATH) && File.readlines(PATH, encoding: "UTF-8").map(&:strip).reject(&:empty?)
|
|
11
15
|
@words ||= []
|
|
12
16
|
end
|
|
13
17
|
|
|
18
|
+
def self.seed_default_at_home
|
|
19
|
+
return if PATH != HOME_PATH || File.exist?(PATH)
|
|
20
|
+
|
|
21
|
+
File.write(PATH, Lexdrill::DefaultWords::TEXT, encoding: "UTF-8")
|
|
22
|
+
end
|
|
23
|
+
private_class_method :seed_default_at_home
|
|
24
|
+
|
|
14
25
|
def self.next
|
|
15
26
|
return nil if words.empty?
|
|
16
27
|
|
data/lib/lexdrill.rb
CHANGED
|
@@ -4,6 +4,7 @@ require_relative "lexdrill/version"
|
|
|
4
4
|
require_relative "lexdrill/config"
|
|
5
5
|
require_relative "lexdrill/counter"
|
|
6
6
|
require_relative "lexdrill/beat"
|
|
7
|
+
require_relative "lexdrill/default_words"
|
|
7
8
|
require_relative "lexdrill/word_list"
|
|
8
9
|
require_relative "lexdrill/toggle"
|
|
9
10
|
require_relative "lexdrill/shell_snippet"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lexdrill
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Siarhei Kisliak
|
|
@@ -30,6 +30,7 @@ files:
|
|
|
30
30
|
- lib/lexdrill/colorizer.rb
|
|
31
31
|
- lib/lexdrill/config.rb
|
|
32
32
|
- lib/lexdrill/counter.rb
|
|
33
|
+
- lib/lexdrill/default_words.rb
|
|
33
34
|
- lib/lexdrill/format.rb
|
|
34
35
|
- lib/lexdrill/inspector.rb
|
|
35
36
|
- lib/lexdrill/line_formatter.rb
|