Class: DevContext::Matcher
- Inherits:
-
Object
- Object
- DevContext::Matcher
- Defined in:
- lib/dev_context/matcher.rb
Instance Method Summary collapse
-
#initialize(config:) ⇒ Matcher
constructor
A new instance of Matcher.
- #resolve(query) ⇒ Object
Constructor Details
#initialize(config:) ⇒ Matcher
Returns a new instance of Matcher.
5 6 7 |
# File 'lib/dev_context/matcher.rb', line 5 def initialize(config:) @config = config end |
Instance Method Details
#resolve(query) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dev_context/matcher.rb', line 9 def resolve(query) return nil if query.to_s.strip.empty? normalized = config.normalize_name(query) exact = config.contexts[normalized] return exact if exact absolute_query = File.(query) path_match = config.contexts.values.find { |ctx| ctx["repo_path"] == absolute_query } return path_match if path_match fuzzy_match(normalized) end |