Module: Lexdrill::Inspector
- Defined in:
- lib/lexdrill/inspector.rb
Overview
Builds a human-readable snapshot of lexdrill's current config/state, for
drill inspect — which files are active, how many words, the counter
value, and whether drilling is currently stopped.
Class Method Summary collapse
- .beat_summary ⇒ Object
- .counter_value ⇒ Object
- .rand_summary ⇒ Object
- .report ⇒ Object
- .stats_summary ⇒ Object
- .toggle_summary ⇒ Object
- .words_summary ⇒ Object
- .workbook_summary ⇒ Object
Class Method Details
.beat_summary ⇒ Object
59 60 61 62 63 64 |
# File 'lib/lexdrill/inspector.rb', line 59 def self.beat_summary return "random (ignores rhythm/counter)" if Lexdrill::Beat.rand? return "not set (plain word-by-word)" unless Lexdrill::Beat.configured? "loop #{Lexdrill::Beat.loop_size}, repeat #{Lexdrill::Beat.repetitions}" end |
.counter_value ⇒ Object
43 44 45 |
# File 'lib/lexdrill/inspector.rb', line 43 def self.counter_value Lexdrill::Counter.new(Lexdrill::WordList::COUNTER_PATH).value end |
.rand_summary ⇒ Object
66 67 68 69 70 71 |
# File 'lib/lexdrill/inspector.rb', line 66 def self.rand_summary denominator = Lexdrill::Rand.value return "every time (default)" if denominator == 1 "approximately 1-in-#{denominator}" end |
.report ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lexdrill/inspector.rb', line 7 def self.report <<~REPORT drill #{Lexdrill::VERSION} Words file: #{Lexdrill::WordList::PATH} (#{words_summary}) Counter file: #{Lexdrill::WordList::COUNTER_PATH} (value: #{counter_value}) Stats file: #{Lexdrill::Stats::PATH} (#{stats_summary}) Toggle: #{toggle_summary} Beat: #{beat_summary} Rand: #{rand_summary} Color: #{Lexdrill::Color.current} Auth mode: #{Lexdrill::AuthMode.current || 'not configured'} Workbook: #{workbook_summary} Sheet: #{Lexdrill::Workbooks.current_sheet || 'not selected'} Config dir: #{Lexdrill::Config::DIR} REPORT end |
.stats_summary ⇒ Object
47 48 49 50 51 |
# File 'lib/lexdrill/inspector.rb', line 47 def self.stats_summary return "no data yet" unless File.exist?(Lexdrill::Stats::PATH) "#{Lexdrill::Stats.counts.size} item(s) tracked" end |
.toggle_summary ⇒ Object
53 54 55 56 57 |
# File 'lib/lexdrill/inspector.rb', line 53 def self.toggle_summary return "enabled" if Lexdrill::Toggle.enabled? "stopped (#{Lexdrill::Toggle::PATH})" end |
.words_summary ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/lexdrill/inspector.rb', line 32 def self.words_summary return "missing" unless File.exist?(Lexdrill::WordList::PATH) words = Lexdrill::WordList.words total = words.size graduated = words.count { |word| Lexdrill::Stats.graduated?(word) } return "#{total} word(s)" if graduated.zero? "#{total} word(s), #{graduated} graduated" end |
.workbook_summary ⇒ Object
25 26 27 28 29 30 |
# File 'lib/lexdrill/inspector.rb', line 25 def self.workbook_summary name = Lexdrill::Workbooks.current_name return "not selected" unless name "#{name} (#{Lexdrill::Workbooks.current_url})" end |