Class: RSpecLetAnalyzer::Adapter
- Inherits:
-
Object
- Object
- RSpecLetAnalyzer::Adapter
- Defined in:
- lib/rspec_let_analyzer/adapter.rb
Overview
Base class for parser adapters Each adapter must implement: parse_file, visit_tree
Direct Known Subclasses
RSpecLetAnalyzer::Adapters::ParserAdapter, RSpecLetAnalyzer::Adapters::PrismAdapter
Class Method Summary collapse
Instance Method Summary collapse
-
#parse(_code) ⇒ Object
Parse code string and return an AST.
-
#parse_file(_file_path) ⇒ Object
:nocov: Parse a file and return an AST.
-
#visit_tree(_ast, _visitor) ⇒ void
Visit the AST and collect statistics.
Class Method Details
.create(type) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rspec_let_analyzer/adapter.rb', line 8 def create(type) case type when 'prism', :prism require_relative 'adapters/prism_adapter' Adapters::PrismAdapter.new when 'parser', :parser require_relative 'adapters/parser_adapter' Adapters::ParserAdapter.new else # :nocov: raise ArgumentError, "Unknown parser type: #{type}" # :nocov: end end |
Instance Method Details
#parse(_code) ⇒ Object
Parse code string and return an AST
35 36 37 |
# File 'lib/rspec_let_analyzer/adapter.rb', line 35 def parse(_code) raise NotImplementedError, "#{self.class} must implement #parse" end |
#parse_file(_file_path) ⇒ Object
:nocov: Parse a file and return an AST
28 29 30 |
# File 'lib/rspec_let_analyzer/adapter.rb', line 28 def parse_file(_file_path) raise NotImplementedError, "#{self.class} must implement #parse_file" end |
#visit_tree(_ast, _visitor) ⇒ void
This method returns an undefined value.
Visit the AST and collect statistics
43 44 45 |
# File 'lib/rspec_let_analyzer/adapter.rb', line 43 def visit_tree(_ast, _visitor) raise NotImplementedError, "#{self.class} must implement #visit_tree" end |