Class: Spellr::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/spellr.rb,
lib/spellr/config.rb
Defined Under Namespace
Classes: Invalid, NotFound
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
19
20
21
|
# File 'lib/spellr/config.rb', line 19
def initialize
@config = ConfigLoader.new
end
|
Instance Attribute Details
#checker ⇒ Object
70
71
72
73
74
|
# File 'lib/spellr/config.rb', line 70
def checker
return dry_run_checker if dry_run?
@checker ||= default_checker
end
|
#config_file ⇒ Object
Returns the value of attribute config_file.
15
16
17
|
# File 'lib/spellr/config.rb', line 15
def config_file
@config_file
end
|
#dry_run ⇒ Object
Also known as:
dry_run?
Returns the value of attribute dry_run.
16
17
18
|
# File 'lib/spellr/config.rb', line 16
def dry_run
@dry_run
end
|
#reporter ⇒ Object
66
67
68
|
# File 'lib/spellr/config.rb', line 66
def reporter
@reporter ||= default_reporter
end
|
Instance Method Details
#excludes ⇒ Object
39
40
41
|
# File 'lib/spellr/config.rb', line 39
def excludes
@excludes ||= @config[:excludes] || []
end
|
#includes ⇒ Object
35
36
37
|
# File 'lib/spellr/config.rb', line 35
def includes
@includes ||= @config[:includes] || []
end
|
#key_heuristic_weight ⇒ Object
27
28
29
|
# File 'lib/spellr/config.rb', line 27
def key_heuristic_weight
@key_heuristic_weight ||= @config[:key_heuristic_weight]
end
|
#key_minimum_length ⇒ Object
31
32
33
|
# File 'lib/spellr/config.rb', line 31
def key_minimum_length
@key_minimum_length ||= @config[:key_minimum_length]
end
|
#languages ⇒ Object
43
44
45
46
47
|
# File 'lib/spellr/config.rb', line 43
def languages
@languages ||= @config[:languages].map do |key, args|
Spellr::Language.new(key, **args)
end
end
|
#languages_for(file) ⇒ Object
49
50
51
|
# File 'lib/spellr/config.rb', line 49
def languages_for(file)
languages.select { |l| l.matches?(file) }
end
|
#output ⇒ Object
62
63
64
|
# File 'lib/spellr/config.rb', line 62
def output
@output ||= Spellr::Output.new
end
|
#reset! ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
80
81
82
83
84
85
86
87
88
|
# File 'lib/spellr/config.rb', line 80
def reset! @config = ConfigLoader.new
remove_instance_variable(:@languages) if defined?(@languages)
remove_instance_variable(:@excludes) if defined?(@excludes)
remove_instance_variable(:@includes) if defined?(@includes)
remove_instance_variable(:@word_minimum_length) if defined?(@word_minimum_length)
remove_instance_variable(:@key_heuristic_weight) if defined?(@key_heuristic_weight)
remove_instance_variable(:@key_minimum_length) if defined?(@key_minimum_length)
end
|
#word_minimum_length ⇒ Object
23
24
25
|
# File 'lib/spellr/config.rb', line 23
def word_minimum_length
@word_minimum_length ||= @config[:word_minimum_length]
end
|
#wordlists_for(file) ⇒ Object
53
54
55
|
# File 'lib/spellr/config.rb', line 53
def wordlists_for(file)
languages_for(file).flat_map(&:wordlists)
end
|