Class: ControllerGrabber

Inherits:
Object
  • Object
show all
Defined in:
lib/ErbFileAnalyser/Grab_controller_from_erb_file.rb

Overview

Call erb_tags_remover on the input file, then calls ruby_parser to parse the code into ast, calls method_controller_visitor to get all calls to possible controllers and output them in a file

Instance Method Summary collapse

Instance Method Details

#grab_controllers(file_path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ErbFileAnalyser/Grab_controller_from_erb_file.rb', line 13

def grab_controllers(file_path)
  output_value = ""
  file_manager = File_manager.new
  file_text = file_manager.read_file(file_path)
  code = ErbTagsRemover.new.remove_erb_tags(file_text)
  parsed_code = Ruby_parser.new.parse_code(code)
  output_array = Find_controller_calls.new([],"","").find_controllers(parsed_code)
  output_array.each do |output|
    output_value = output_value + "[name: '#{output.name}', receiver: '#{output.receiver}']\n"
  end
  output_value
end