Class: Keela::Strategy
- Inherits:
-
Object
- Object
- Keela::Strategy
- Defined in:
- lib/keela/strategy.rb
Overview
Base class for detection strategies.
Subclasses define how to find definitions and detect usage for different types of code (methods, scopes, etc.)
Direct Known Subclasses
Instance Method Summary collapse
-
#definition_file_pattern ⇒ Object
Regex pattern to match files that may contain definitions (e.g., /app/models/ for scopes).
-
#extract_definition(line) ⇒ Object
Extract a definition name from a line of code, or nil if no definition found.
-
#name ⇒ Object
Human-readable name for this strategy (e.g., "methods", "scopes").
-
#skip_comments? ⇒ Boolean
Whether to skip lines that start with # (comments).
-
#usage_regex(name) ⇒ Object
Build a regex to detect usage of the given definition name.
Instance Method Details
#definition_file_pattern ⇒ Object
Regex pattern to match files that may contain definitions (e.g., /app/models/ for scopes)
17 18 19 |
# File 'lib/keela/strategy.rb', line 17 def definition_file_pattern raise NotImplementedError, "#{self.class} must implement #definition_file_pattern" end |
#extract_definition(line) ⇒ Object
Extract a definition name from a line of code, or nil if no definition found
22 23 24 |
# File 'lib/keela/strategy.rb', line 22 def extract_definition(line) raise NotImplementedError, "#{self.class} must implement #extract_definition" end |
#name ⇒ Object
Human-readable name for this strategy (e.g., "methods", "scopes")
11 12 13 |
# File 'lib/keela/strategy.rb', line 11 def name raise NotImplementedError, "#{self.class} must implement #name" end |
#skip_comments? ⇒ Boolean
Whether to skip lines that start with # (comments)
32 33 34 |
# File 'lib/keela/strategy.rb', line 32 def skip_comments? false end |
#usage_regex(name) ⇒ Object
Build a regex to detect usage of the given definition name
27 28 29 |
# File 'lib/keela/strategy.rb', line 27 def usage_regex(name) raise NotImplementedError, "#{self.class} must implement #usage_regex" end |