Class: Keela::Strategies::Methods
- Inherits:
-
Keela::Strategy
- Object
- Keela::Strategy
- Keela::Strategies::Methods
- Defined in:
- lib/keela/strategies/methods.rb
Instance Method Summary collapse
- #definition_file_pattern ⇒ Object
- #extract_definition(line) ⇒ Object
- #name ⇒ Object
- #skip_comments? ⇒ Boolean
- #usage_regex(name) ⇒ Object
Instance Method Details
#definition_file_pattern ⇒ Object
10 11 12 |
# File 'lib/keela/strategies/methods.rb', line 10 def definition_file_pattern %r{app/helpers|app/models} end |
#extract_definition(line) ⇒ Object
14 15 16 17 18 |
# File 'lib/keela/strategies/methods.rb', line 14 def extract_definition(line) return nil unless line =~ /def ([^(;\s]+)/ Regexp.last_match(1).chomp end |
#name ⇒ Object
6 7 8 |
# File 'lib/keela/strategies/methods.rb', line 6 def name "methods" end |
#skip_comments? ⇒ Boolean
30 31 32 |
# File 'lib/keela/strategies/methods.rb', line 30 def skip_comments? false end |
#usage_regex(name) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/keela/strategies/methods.rb', line 20 def usage_regex(name) if name.end_with?("=") # Setter method: match assignment usage /(?<!def )#{Regexp.quote(name.sub(/^self\./, "").chomp("="))}\W=*/ else # Regular method: match calls /(?<!def )#{Regexp.quote(name.sub(/^self\./, ""))}\W/ end end |