Class: Crabfarm::Live::ReducerRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/crabfarm/live/reducer_runner.rb

Defined Under Namespace

Classes: DisplayFileDecorator, Dsl

Instance Method Summary collapse

Constructor Details

#initialize(_manager, _target) ⇒ ReducerRunner

Returns a new instance of ReducerRunner.



8
9
10
11
12
13
# File 'lib/crabfarm/live/reducer_runner.rb', line 8

def initialize(_manager, _target)
  @manager = _manager
  @target = _target
  @rspec = true
  @params = {}
end

Instance Method Details

#clear_paramsObject



29
30
31
32
# File 'lib/crabfarm/live/reducer_runner.rb', line 29

def clear_params
  @params = {}
  @rspec = false
end

#dslObject



15
16
17
# File 'lib/crabfarm/live/reducer_runner.rb', line 15

def dsl
  @dsl ||= Dsl.new self
end

#executeObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/crabfarm/live/reducer_runner.rb', line 38

def execute
  strategy = if @rspec
    ReducerRunnerRSpec.new @manager, @target
  else
    ReducerRunnerDirect.new @manager, snapshot, @target, @params
  end

  begin
    Factories::SnapshotReducer.with_decorator decorator do
      strategy.execute
    end

    @manager.show_file decorator.last_path unless decorator.last_path.nil?
    strategy.show_results
  rescue Crabfarm::LiveInterrupted
    Utils::Console.info "Execution interrupted"
  end
end

#use_params(_params = {}) ⇒ Object



24
25
26
27
# File 'lib/crabfarm/live/reducer_runner.rb', line 24

def use_params(_params={})
  @params = @params.merge _params
  @rspec = false
end

#use_rspecObject



34
35
36
# File 'lib/crabfarm/live/reducer_runner.rb', line 34

def use_rspec
  @rspec = true
end

#use_snapshot(_snapshot) ⇒ Object



19
20
21
22
# File 'lib/crabfarm/live/reducer_runner.rb', line 19

def use_snapshot(_snapshot)
  @snapshot = _snapshot
  @rspec = false
end