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
Class Method Details
.beat_summary ⇒ Object
49 50 51 52 53 54 |
# File 'lib/lexdrill/inspector.rb', line 49 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
33 34 35 |
# File 'lib/lexdrill/inspector.rb', line 33 def self.counter_value Lexdrill::Counter.new(Lexdrill::WordList::COUNTER_PATH).value end |
.rand_summary ⇒ Object
56 57 58 59 60 61 |
# File 'lib/lexdrill/inspector.rb', line 56 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 |
# 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} Format: #{Lexdrill::Format.current} LEXDRILL_PATH: #{ENV.fetch('LEXDRILL_PATH', '(not set)')} REPORT end |
.stats_summary ⇒ Object
37 38 39 40 41 |
# File 'lib/lexdrill/inspector.rb', line 37 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
43 44 45 46 47 |
# File 'lib/lexdrill/inspector.rb', line 43 def self.toggle_summary return "enabled" if Lexdrill::Toggle.enabled? "stopped (#{Lexdrill::Toggle::PATH})" end |
.words_summary ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lexdrill/inspector.rb', line 22 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 |