Class: DeltaTest::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/delta_test/generator.rb

Direct Known Subclasses

GeneratorSingleton

Instance Method Summary collapse

Instance Method Details

#hook_on_exitObject

Hook teardown! on exit



85
86
87
# File 'lib/delta_test/generator.rb', line 85

def hook_on_exit
  at_exit { teardown! }
end

#setup!Object

Setup table



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/delta_test/generator.rb', line 19

def setup!
  return unless DeltaTest.active?

  return if @_setup
  @_setup = true

  DeltaTest.log('--- setup!')

  @table = DependenciesTable.new

  @current_spec_file = nil
end

#start!(spec_file) ⇒ Object

Start profiler for the spec file



37
38
39
40
41
42
43
44
45
# File 'lib/delta_test/generator.rb', line 37

def start!(spec_file)
  return unless DeltaTest.active?

  DeltaTest.log('--- start!(%s)' % spec_file)

  @current_spec_file = Utils.regulate_filepath(spec_file, DeltaTest.config.base_path).to_s

  Profiler.start!
end

#stop!Object

Stop profiler and update table



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/delta_test/generator.rb', line 50

def stop!
  return unless DeltaTest.active?

  Profiler.stop!

  DeltaTest.log('--- stop!')

  spec_file = @current_spec_file
  @current_spec_file = nil

  if spec_file
    Profiler.last_result.each do |file|
      @table.add(spec_file, file)
    end
  end

  DeltaTest::Profiler.clean!
end

#teardown!Object

Save table to the file



72
73
74
75
76
77
78
79
80
# File 'lib/delta_test/generator.rb', line 72

def teardown!
  return unless @_setup
  return if @_teardown
  @_teardown = true

  DeltaTest.log('--- teardown!')
  Profiler.clean!
  @table.dump(DeltaTest.config.tmp_table_file)
end