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

Class Method Details

.counter_valueObject



24
25
26
# File 'lib/lexdrill/inspector.rb', line 24

def self.counter_value
  Lexdrill::Counter.new(Lexdrill::WordList::COUNTER_PATH).value
end

.reportObject



7
8
9
10
11
12
13
14
15
16
# 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})
    Toggle:        #{toggle_summary}
    LEXDRILL_PATH: #{ENV.fetch('LEXDRILL_PATH', '(not set)')}
  REPORT
end

.toggle_summaryObject



28
29
30
31
32
# File 'lib/lexdrill/inspector.rb', line 28

def self.toggle_summary
  return "enabled" if Lexdrill::Toggle.enabled?

  "stopped (#{Lexdrill::Toggle::PATH})"
end

.words_summaryObject



18
19
20
21
22
# File 'lib/lexdrill/inspector.rb', line 18

def self.words_summary
  return "missing" unless File.exist?(Lexdrill::WordList::PATH)

  "#{Lexdrill::WordList.words.size} word(s)"
end