Class: DidYouMean::RequirePathChecker
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/did_you_mean/spell_checkers/require_path_checker.rb |
Constant Summary
-
ENV_SPECIFIC_EXT =
private
# File 'lib/did_you_mean/spell_checkers/require_path_checker.rb', line 14".#{RbConfig::CONFIG["DLEXT"]}"
-
INITIAL_LOAD_PATH =
private
# File 'lib/did_you_mean/spell_checkers/require_path_checker.rb', line 11$LOAD_PATH.dup.freeze
Class Method Summary
- .new(exception) ⇒ RequirePathChecker constructor
- .requireables
Instance Attribute Summary
- #path readonly
Instance Method Summary
Constructor Details
.new(exception) ⇒ RequirePathChecker
# File 'lib/did_you_mean/spell_checkers/require_path_checker.rb', line 25
def initialize(exception) @path = exception.path end
Class Method Details
.requireables
[ GitHub ]# File 'lib/did_you_mean/spell_checkers/require_path_checker.rb', line 19
def self.requireables @requireables ||= INITIAL_LOAD_PATH .flat_map {|path| Dir.glob("**/???*{.rb,#{ENV_SPECIFIC_EXT}}", base: path) } .map {|path| path.chomp!(".rb") || path.chomp!(ENV_SPECIFIC_EXT) } end
Instance Attribute Details
#path (readonly)
[ GitHub ]# File 'lib/did_you_mean/spell_checkers/require_path_checker.rb', line 9
attr_reader :path
Instance Method Details
#corrections
[ GitHub ]# File 'lib/did_you_mean/spell_checkers/require_path_checker.rb', line 29
def corrections @corrections ||= begin threshold = path.size * 2 dictionary = self.class.requireables.reject {|str| str.size >= threshold } spell_checker = path.include?("/") ? TreeSpellChecker : SpellChecker spell_checker.new(dictionary: dictionary).correct(path).uniq end end