class ControllerGrabber

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

Public Instance Methods

grab_controllers(file_path) click to toggle source
# 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