lib/simple_tasks_ruby/main.rb
# Main entry point in application - executes other implemented operations
Main entry point in application - executes other implemented operations
Main entry point in application - executes other implemented operations
def execute
      begin
        file_lines = read_lines_from_file
        tasks = get_tasks(file_lines)
        delayed_tasks = find_delayed_tasks(tasks)
        @writer.write_success("Printing delayed tasks:")
        @tasks_printer.print(delayed_tasks)
        @writer.write_message("\nPrinting summary of tasks")
        tasks_summary_engine = TasksSummaryEngine.new(tasks)
        tasks_summary_engine.calculate()
        @writer.write_message("Total number of tasks is: " + tasks_summary_engine.total.to_s)
        @writer.write_message(tasks_summary_engine.tasks_count_by_status)
        @file_writer_service.save("delayed_tasks.out", delayed_tasks)        
      rescue => e 
        @writer.write_error("Error occured during application execution: #{e.to_s}\n")
        @writer.write_error(e.backtrace) 
      ensure
        end_execution
      end
    end
def execute begin file_lines = read_lines_from_file tasks = get_tasks ( file_lines ) delayed_tasks = find_delayed_tasks ( tasks ) @writer . write_success ( "Printing delayed tasks:" ) @tasks_printer . print ( delayed_tasks ) @writer . write_message ( "\nPrinting summary of tasks" ) tasks_summary_engine = TasksSummaryEngine . new ( tasks ) tasks_summary_engine . calculate ( ) @writer . write_message ( "Total number of tasks is: " + tasks_summary_engine . total . to_s ) @writer . write_message ( tasks_summary_engine . tasks_count_by_status ) @file_writer_service . save ( "delayed_tasks.out" , delayed_tasks ) rescue => e @writer . write_error ( "Error occured during application execution: #{e.to_s}\n" ) @writer . write_error ( e . backtrace ) ensure end_execution end end
Main entry point in application - executes other implemented operations
Main entry point in application - executes other implemented operations
# print_file_content file_lines # Debug information - write this to file if needed # Rescues StandardError