Spec-Zone.ru › Ruby 3.4

класс DidYouMean::RequirePathChecker

Родитель:
Объект

Константы

ENV_SPECIFIC_EXT
INITIAL_LOAD_PATH

Атрибуты

path [R]

Публичные методы класса

new (exception)
Исходный код
# File lib/did_you_mean/spell_checkers/require_path_checker.rb, line 25
def initialize(exception)
  @path = exception.path
end
requireables ()
Исходный код
# 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

Публичные методы экземпляра

corrections ()
Исходный код
# 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

Ruby Core © 1993–2024 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API