Class: Spellr::Config
- Inherits:
-
Object
- Object
- Spellr::Config
- Defined in:
- lib/spellr/config.rb
Instance Attribute Summary collapse
-
#config_file ⇒ Object
Returns the value of attribute config_file.
-
#quiet ⇒ Object
(also: #quiet?)
Returns the value of attribute quiet.
- #reporter ⇒ Object
Instance Method Summary collapse
- #all_wordlist_paths ⇒ Object
- #clear_cache ⇒ Object
- #color ⇒ Object
- #ignored ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #languages ⇒ Object
- #languages_for(file) ⇒ Object
- #only ⇒ Object
- #word_minimum_length ⇒ Object
- #wordlists ⇒ Object
- #wordlists_for(file) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
12 13 14 15 |
# File 'lib/spellr/config.rb', line 12 def initialize @config_file = ::File.join(Dir.pwd, '.spellr.yml') load_config end |
Instance Attribute Details
#config_file ⇒ Object
Returns the value of attribute config_file.
8 9 10 |
# File 'lib/spellr/config.rb', line 8 def config_file @config_file end |
#quiet ⇒ Object Also known as: quiet?
Returns the value of attribute quiet.
9 10 11 |
# File 'lib/spellr/config.rb', line 9 def quiet @quiet end |
#reporter ⇒ Object
68 69 70 |
# File 'lib/spellr/config.rb', line 68 def reporter @reporter ||= default_reporter end |
Instance Method Details
#all_wordlist_paths ⇒ Object
54 55 56 |
# File 'lib/spellr/config.rb', line 54 def all_wordlist_paths languages.values.flat_map(&:all_wordlist_paths) end |
#clear_cache ⇒ Object
33 34 35 36 |
# File 'lib/spellr/config.rb', line 33 def clear_cache remove_instance_variable(:@wordlists) if defined?(@wordlists) remove_instance_variable(:@languages) if defined?(@languages) end |
#color ⇒ Object
29 30 31 |
# File 'lib/spellr/config.rb', line 29 def color @config[:color] end |
#ignored ⇒ Object
25 26 27 |
# File 'lib/spellr/config.rb', line 25 def ignored @config[:ignore] end |
#languages ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/spellr/config.rb', line 38 def languages require_relative 'language' @languages ||= @config[:languages].map do |key, args| [key, Spellr::Language.new(key, args)] end.to_h end |
#languages_for(file) ⇒ Object
46 47 48 |
# File 'lib/spellr/config.rb', line 46 def languages_for(file) languages.values.select { |l| l.matches?(file) } end |
#only ⇒ Object
21 22 23 |
# File 'lib/spellr/config.rb', line 21 def only @config[:only] || [] end |
#word_minimum_length ⇒ Object
17 18 19 |
# File 'lib/spellr/config.rb', line 17 def word_minimum_length @config[:word_minimum_length] end |
#wordlists ⇒ Object
50 51 52 |
# File 'lib/spellr/config.rb', line 50 def wordlists @wordlists ||= languages.values.flat_map(&:wordlists) end |
#wordlists_for(file) ⇒ Object
58 59 60 |
# File 'lib/spellr/config.rb', line 58 def wordlists_for(file) languages_for(file).flat_map(&:wordlists) end |