Class: Cucover::Recorder

Inherits:
Object
  • Object
show all
Defined in:
lib/cucover/recorder.rb

Instance Method Summary collapse

Constructor Details

#initialize(scenario_or_table_row) ⇒ Recorder

Returns a new instance of Recorder.



3
4
5
6
7
# File 'lib/cucover/recorder.rb', line 3

def initialize(scenario_or_table_row)
  @scenario_or_table_row = scenario_or_table_row
  @analyzer = Rcov::CodeCoverageAnalyzer.new
  @additional_covered_files = []
end

Instance Method Details

#record_file!(source_file) ⇒ Object



9
10
11
12
13
# File 'lib/cucover/recorder.rb', line 9

def record_file!(source_file)
  unless @additional_covered_files.include?(source_file)
    @additional_covered_files << source_file
  end
end

#recordingObject



28
29
30
31
32
33
34
35
# File 'lib/cucover/recorder.rb', line 28

def recording
  Recording.new(
    @scenario_or_table_row.file_colon_line,
    @scenario_or_table_row.exception,
    @additional_covered_files,
    @analyzer,
    @start_time, @end_time)
end

#start!Object



15
16
17
18
# File 'lib/cucover/recorder.rb', line 15

def start!
  @start_time = Time.now
  @analyzer.install_hook
end

#stop!Object



20
21
22
23
24
25
26
# File 'lib/cucover/recorder.rb', line 20

def stop!
  @end_time = Time.now
  @analyzer.remove_hook
  Cucover.logger.info("Finished recording #{@scenario_or_table_row.file_colon_line}.")
  Cucover.logger.debug("Covered files: #{@analyzer.analyzed_files.join(',')}")
  Cucover.logger.debug("Additional Covered files: #{@additional_covered_files.join(',')}")
end