formula: add fuzzy_search method
This commit is contained in:
parent
4f33c2cbb4
commit
7aacda1754
@ -583,14 +583,11 @@ then
|
|||||||
|
|
||||||
# Don't allow non-developers to customise Ruby warnings.
|
# Don't allow non-developers to customise Ruby warnings.
|
||||||
unset HOMEBREW_RUBY_WARNINGS
|
unset HOMEBREW_RUBY_WARNINGS
|
||||||
|
|
||||||
# Disable Ruby options we don't need.
|
|
||||||
RUBY_DISABLE_OPTIONS="--disable=did_you_mean,rubyopt"
|
|
||||||
else
|
|
||||||
# Don't disable did_you_mean for developers as it's useful.
|
|
||||||
RUBY_DISABLE_OPTIONS="--disable=rubyopt"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Disable Ruby options we don't need.
|
||||||
|
RUBY_DISABLE_OPTIONS="--disable=rubyopt"
|
||||||
|
|
||||||
if [[ -z "${HOMEBREW_RUBY_WARNINGS}" ]]
|
if [[ -z "${HOMEBREW_RUBY_WARNINGS}" ]]
|
||||||
then
|
then
|
||||||
export HOMEBREW_RUBY_WARNINGS="-W1"
|
export HOMEBREW_RUBY_WARNINGS="-W1"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cache_store"
|
require "cache_store"
|
||||||
|
require "did_you_mean"
|
||||||
require "formula_support"
|
require "formula_support"
|
||||||
require "lock_file"
|
require "lock_file"
|
||||||
require "formula_pin"
|
require "formula_pin"
|
||||||
@ -1671,6 +1672,13 @@ class Formula
|
|||||||
CoreTap.instance.alias_reverse_table
|
CoreTap.instance.alias_reverse_table
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns a list of approximately matching formula names, but not the complete match
|
||||||
|
# @private
|
||||||
|
def self.fuzzy_search(name)
|
||||||
|
@spell_checker ||= DidYouMean::SpellChecker.new(dictionary: Set.new(names + full_names).to_a)
|
||||||
|
@spell_checker.correct(name)
|
||||||
|
end
|
||||||
|
|
||||||
def self.[](name)
|
def self.[](name)
|
||||||
Formulary.factory(name)
|
Formulary.factory(name)
|
||||||
end
|
end
|
||||||
|
@ -127,6 +127,7 @@ class Tap
|
|||||||
@style_exceptions = nil
|
@style_exceptions = nil
|
||||||
@pypi_formula_mappings = nil
|
@pypi_formula_mappings = nil
|
||||||
@config = nil
|
@config = nil
|
||||||
|
@spell_checker = nil
|
||||||
remove_instance_variable(:@private) if instance_variable_defined?(:@private)
|
remove_instance_variable(:@private) if instance_variable_defined?(:@private)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user