Class: Crabfarm::Live::ReducerRunnerDirect
- Inherits:
-
Object
- Object
- Crabfarm::Live::ReducerRunnerDirect
- Defined in:
- lib/crabfarm/live/reducer_runner_direct.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(_manager, _snapshot, _target, _params) ⇒ ReducerRunnerDirect
constructor
A new instance of ReducerRunnerDirect.
- #show_results ⇒ Object
Constructor Details
#initialize(_manager, _snapshot, _target, _params) ⇒ ReducerRunnerDirect
8 9 10 11 12 13 |
# 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 |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 20 21 22 23 |
# 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 ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/crabfarm/live/reducer_runner_direct.rb', line 25 def show_results @manager.inject_web_tools @manager.show_dialog( :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 |