streamingly 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc109e04512bb35ddda55ac4c5fb3382de3721a0
|
4
|
+
data.tar.gz: db45a7738730ee44d8e81cb8af84d65e84c8a70a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e84efeb36af91513a007fea9649576449a90b210bbc4794933e6f87eae06eb04e6b39115afc8c50bf69e63b116c607e8844d9dc0a1dbc8254f2518d4239a3028
|
7
|
+
data.tar.gz: 282203153fb041b9ca631255b2b6069b28d91050868a9f5dbfebb828e6f5dc2d8350628406695ea5d0663f700cbefa5255106d5fc2448a111c7552cfdc57e3ba
|
data/lib/streamingly/reducer.rb
CHANGED
@@ -20,7 +20,12 @@ module Streamingly
|
|
20
20
|
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
def on_error(error, error_context)
|
24
|
+
raise error unless @error_callback_defined && !@accumulator.nil?
|
25
|
+
@accumulator.on_error(error, error_context)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
24
29
|
|
25
30
|
def flush
|
26
31
|
@accumulator ? (@accumulator.flush || []).compact : []
|
@@ -52,11 +57,6 @@ module Streamingly
|
|
52
57
|
[]
|
53
58
|
end
|
54
59
|
|
55
|
-
def on_error(error, error_context)
|
56
|
-
raise error unless @error_callback_defined && !@accumulator.nil?
|
57
|
-
@accumulator.on_error(error, error_context)
|
58
|
-
end
|
59
|
-
|
60
60
|
def new_accumulator(key)
|
61
61
|
if @accumulator_options
|
62
62
|
@accumulator_class.new(key, @accumulator_options)
|
data/lib/streamingly/version.rb
CHANGED
@@ -41,6 +41,12 @@ describe Streamingly::Reducer do
|
|
41
41
|
let(:accumulator_class) { double(:accumulator_class, :method_defined? => true) }
|
42
42
|
subject { described_class.new(accumulator_class) }
|
43
43
|
|
44
|
+
describe '#on_error' do
|
45
|
+
it 'is exposed as public method' do
|
46
|
+
expect(subject).to respond_to(:on_error)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
44
50
|
describe "#reduce_over" do
|
45
51
|
|
46
52
|
context "given records with the same key" do
|
@@ -1,5 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
class TestErrorHandler
|
4
|
+
def on_error(error, context)
|
5
|
+
nil
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
describe Streamingly::SerDeIterable do
|
4
10
|
let(:iterable) { [1] }
|
5
11
|
let(:error) { StandardError.new('error') }
|
@@ -17,7 +23,7 @@ describe Streamingly::SerDeIterable do
|
|
17
23
|
end
|
18
24
|
|
19
25
|
describe 'given custom error handler' do
|
20
|
-
let(:error_handler) {
|
26
|
+
let(:error_handler) { TestErrorHandler.new }
|
21
27
|
subject { described_class.new(iterable, error_handler) }
|
22
28
|
|
23
29
|
it 'calls on_error method of provided handler' do
|