Class: RailsCodeHealth::RailsAnalyzer
- Inherits:
-
Object
- Object
- RailsCodeHealth::RailsAnalyzer
- Includes:
- ASTHelpers
- Defined in:
- lib/rails_code_health/rails_analyzer.rb
Constant Summary
Constants included from ASTHelpers
ASTHelpers::SCOPE_BOUNDARY_TYPES, ASTHelpers::VISIBILITY_MODIFIERS
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(file_path, file_type) ⇒ RailsAnalyzer
constructor
A new instance of RailsAnalyzer.
Methods included from ASTHelpers
#class_body_sends, #defs_by_visibility, #erb_ruby_fragments, #find_nodes, #find_nodes_in_scope
Constructor Details
#initialize(file_path, file_type) ⇒ RailsAnalyzer
Returns a new instance of RailsAnalyzer.
5 6 7 8 9 10 11 12 |
# File 'lib/rails_code_health/rails_analyzer.rb', line 5 def initialize(file_path, file_type) @file_path = file_path @file_type = file_type @source = File.read(file_path) @ast = Parser::CurrentRuby.parse(@source) if file_path.extname == '.rb' rescue Parser::SyntaxError @ast = nil end |
Instance Method Details
#analyze ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rails_code_health/rails_analyzer.rb', line 14 def analyze case @file_type when :controller analyze_controller when :model analyze_model when :view analyze_view when :helper analyze_helper when :migration analyze_migration when :service analyze_service when :interactor analyze_interactor when :serializer analyze_serializer else {} end end |