Class: Crabfarm::Live::ReducerRunner

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

Defined Under Namespace

Classes: Dsl

Instance Method Summary collapse

Constructor Details

#initialize(_manager, _target) ⇒ ReducerRunner

Returns a new instance of ReducerRunner.



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

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

Instance Method Details

#clear_paramsObject



43
44
45
46
# File 'lib/crabfarm/live/reducer_runner.rb', line 43

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

#dslObject



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

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

#executeObject



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/crabfarm/live/reducer_runner.rb', line 57

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

  Factories::SnapshotReducer.with_decorator self do
    @manager.block_requests { strategy.execute }
  end

  strategy.show_results
end

#prepare(_class, _path, _params) ⇒ Object

decorator



52
53
54
55
# File 'lib/crabfarm/live/reducer_runner.rb', line 52

def prepare(_class, _path, _params) # decorator
  @manager.primary_driver.get("file://#{_path}")
  nil
end

#snapshotObject



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

def snapshot
  if @snapshot.nil? then snapshot_for(@target) else @snapshot end
end

#use_params(_params = {}) ⇒ Object



38
39
40
41
# File 'lib/crabfarm/live/reducer_runner.rb', line 38

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

#use_rspecObject



48
49
50
# File 'lib/crabfarm/live/reducer_runner.rb', line 48

def use_rspec
  @rspec = true
end

#use_snapshot(_snapshot) ⇒ Object



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

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