summaryrefslogtreecommitdiff
path: root/lib/did_you_mean/spell_checkers/require_path_checker.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-05-12 16:22:41 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-05-12 16:27:25 +0900
commitee518cf077b856fddea7dfae5d85f3c3117dd616 (patch)
treea78f4d1bbb8745ff3c8e39d28900b7446c858669 /lib/did_you_mean/spell_checkers/require_path_checker.rb
parent317fdd6df2fce0fa5538690c6f6547585b494f2e (diff)
Revert "Sync did_you_mean"
This reverts commit 946dadd3f479198e87873a863d15c7660a8e2b56, which broke `TestGemRequire` and others.
Diffstat (limited to 'lib/did_you_mean/spell_checkers/require_path_checker.rb')
-rw-r--r--lib/did_you_mean/spell_checkers/require_path_checker.rb33
1 files changed, 0 insertions, 33 deletions
diff --git a/lib/did_you_mean/spell_checkers/require_path_checker.rb b/lib/did_you_mean/spell_checkers/require_path_checker.rb
deleted file mode 100644
index 10239947dd..0000000000
--- a/lib/did_you_mean/spell_checkers/require_path_checker.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen-string-literal: true
-
-require_relative "../spell_checker"
-require_relative "../tree_spell_checker"
-
-module DidYouMean
- class RequirePathChecker
- attr_reader :path
-
- INITIAL_LOAD_PATH = $LOAD_PATH.dup.freeze
- ENV_SPECIFIC_EXT = ".#{RbConfig::CONFIG["DLEXT"]}"
-
- private_constant :INITIAL_LOAD_PATH, :ENV_SPECIFIC_EXT
-
- 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
-
- def initialize(exception)
- @path = exception.path
- end
-
- def corrections
- 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)
- end
- end
-end