class Crabfarm::Live::ReducerRunnerDirect

Public Class Methods

new(_manager, _snapshot, _target, _params) click to toggle source
# File lib/crabfarm/live/reducer_runner_direct.rb, line 8
def initialize(_manager, _snapshot, _target, _params)
  @manager = _manager
  @snapshot = _snapshot
  @target = _target
  @params = _params
end

Public Instance Methods

execute() click to toggle source
# File lib/crabfarm/live/reducer_runner_direct.rb, line 15
def execute
  raise ArgumentError.new 'Must provide a snapshot to execute reducer' if @snapshot.nil?

  snapshot_path = @target.snapshot_path @snapshot
  raise ArgumentError.new "Snapshot does not exist #{snapshot_path}" unless File.exist? snapshot_path

  @reducer = Factories::SnapshotReducer.build @target, snapshot_path, (@params || {})
  @elapsed = Benchmark.measure { @reducer.run }
end
show_results() click to toggle source
# File lib/crabfarm/live/reducer_runner_direct.rb, line 25
def show_results
  @manager.show_message(
    :neutral,
    'Reducing completed!',
    "The page was parsed in #{@elapsed.real} seconds",
    @reducer.to_json,
    :json
  )

  Utils::Console.json_result @reducer
  Utils::Console.info "Completed in #{@elapsed.real} s"
end