Class: Tryouts::FileProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/tryouts/file_processor.rb

Constant Summary collapse

PARSER_TYPES =

Supported parser types for validation and documentation

[:enhanced, :prism].freeze

Instance Method Summary collapse

Constructor Details

#initialize(file:, options:, output_manager:, translator:, global_tally:) ⇒ FileProcessor

Returns a new instance of FileProcessor.



13
14
15
16
17
18
19
# File 'lib/tryouts/file_processor.rb', line 13

def initialize(file:, options:, output_manager:, translator:, global_tally:)
  @file           = file
  @options        = options
  @output_manager = output_manager
  @translator     = translator
  @global_tally   = global_tally
end

Instance Method Details

#processObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tryouts/file_processor.rb', line 21

def process
  testrun = create_parser(@file, @options).parse

  # Report total test count (before filtering for display)
  # Line spec filtering affects output only, not execution
  @global_tally[:aggregator].increment_total_files
  @output_manager.file_parsed(@file, testrun.total_tests)
  @output_manager.parser_warnings(@file, warnings: testrun.warnings)

  if @options[:inspect]
    handle_inspect_mode(testrun)
  elsif @options[:generate_only]
    handle_generate_only_mode(testrun)
  else
    execute_tests(testrun)
  end
rescue TryoutSyntaxError => ex
  handle_syntax_error(ex)
rescue StandardError, SystemStackError, LoadError, SecurityError, NoMemoryError => ex
  handle_general_error(ex)
end