Class: Spellr::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/spellr/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

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_fileObject

Returns the value of attribute config_file.



8
9
10
# File 'lib/spellr/config.rb', line 8

def config_file
  @config_file
end

#quietObject Also known as: quiet?

Returns the value of attribute quiet.



9
10
11
# File 'lib/spellr/config.rb', line 9

def quiet
  @quiet
end

#reporterObject



68
69
70
# File 'lib/spellr/config.rb', line 68

def reporter
  @reporter ||= default_reporter
end

Instance Method Details

#all_wordlist_pathsObject



54
55
56
# File 'lib/spellr/config.rb', line 54

def all_wordlist_paths
  languages.values.flat_map(&:all_wordlist_paths)
end

#clear_cacheObject



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

#colorObject



29
30
31
# File 'lib/spellr/config.rb', line 29

def color
  @config[:color]
end

#ignoredObject



25
26
27
# File 'lib/spellr/config.rb', line 25

def ignored
  @config[:ignore]
end

#languagesObject



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

#onlyObject



21
22
23
# File 'lib/spellr/config.rb', line 21

def only
  @config[:only] || []
end

#word_minimum_lengthObject



17
18
19
# File 'lib/spellr/config.rb', line 17

def word_minimum_length
  @config[:word_minimum_length]
end

#wordlistsObject



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