setl 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/setl/delegates.rb +3 -3
- data/lib/setl/errors.rb +12 -4
- data/lib/setl/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f3d6b06ee035e305c6660c622adb68c6f999f35
|
4
|
+
data.tar.gz: 04f4849498a359f103bdd3acc4c250494ecb3d79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9178342903fc24767010999bc5c7af5263f6d6903c51282290eb38878e3bb90b09d6e9b67366abb51c8883835c212e1229d228542b60783e5db41acb6034bb31
|
7
|
+
data.tar.gz: 191947e920130b88494d100bc30eabb7903e34614b14de88854dc747b414d9fb3ed8043ff8318d799100b6bbd59a17832592d8fc3ecf6c8e2cbc987a23ec7a4c
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ transform = lambda do |d|
|
|
36
36
|
d
|
37
37
|
end
|
38
38
|
|
39
|
-
Setl::ETL.new(source, destination).process
|
39
|
+
Setl::ETL.new(source, destination, transform).process
|
40
40
|
#=> {id: 1, name: 'FOO'}
|
41
41
|
#=> {id: 2, name: 'BAR'}
|
42
42
|
```
|
@@ -48,7 +48,7 @@ See the examples folder for some more extensive, and realistic, implementations.
|
|
48
48
|
By default Setl will ignore errors and move on to the next "row" of data. This is configurable with by setting `stop_on_errors` to true:
|
49
49
|
|
50
50
|
```ruby
|
51
|
-
Setl::ETL.new(source, destination, stop_on_errors: true).process
|
51
|
+
Setl::ETL.new(source, destination, transform, stop_on_errors: true).process
|
52
52
|
```
|
53
53
|
|
54
54
|
If you want to handle errors on your own and perhaps do some sort of logging then simply provide an `error_handler`.
|
@@ -56,7 +56,7 @@ If you want to handle errors on your own and perhaps do some sort of logging the
|
|
56
56
|
```ruby
|
57
57
|
error_handler = proc { |row, exception| logger.error "Something failed on #{row.inspect} with #{exception.inspect}" }
|
58
58
|
|
59
|
-
Setl::ETL.new(source, destination, error_handler: error_handler).process
|
59
|
+
Setl::ETL.new(source, destination, transform, error_handler: error_handler).process
|
60
60
|
```
|
61
61
|
|
62
62
|
If you provide an error handler, then `stop_on_errors` is ignored. You're responsible for handling your own errors. The error handler is simply an object that responds to `call` and accepts the failing row of data and the exception that was raised. You can retrieve the original exception by looking at `exception.cause`.
|
data/lib/setl/delegates.rb
CHANGED
@@ -20,7 +20,7 @@ module Setl
|
|
20
20
|
if e.is_a? ETLError
|
21
21
|
raise e
|
22
22
|
else
|
23
|
-
error_handler.(SourceError.new("Failed to read from source"))
|
23
|
+
error_handler.(SourceError.new("Failed to read from source", e))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -29,7 +29,7 @@ module Setl
|
|
29
29
|
def call(row, &block)
|
30
30
|
item.call(row, &block)
|
31
31
|
rescue StandardError => e
|
32
|
-
error_handler.(ProcessingError.new(row, "Failed to process #{row}"))
|
32
|
+
error_handler.(ProcessingError.new(row, "Failed to process #{row}", e))
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -37,7 +37,7 @@ module Setl
|
|
37
37
|
def call(row, &block)
|
38
38
|
item.call(row, &block)
|
39
39
|
rescue StandardError => e
|
40
|
-
error_handler.(DestinationError.new(row, "Failed to send #{row}"))
|
40
|
+
error_handler.(DestinationError.new(row, "Failed to send #{row}", e))
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
data/lib/setl/errors.rb
CHANGED
@@ -3,23 +3,31 @@ module Setl
|
|
3
3
|
end
|
4
4
|
|
5
5
|
class ProcessingError < ETLError
|
6
|
-
def initialize(row, message=nil)
|
6
|
+
def initialize(row, message=nil, cause=$!)
|
7
7
|
super message
|
8
8
|
@row = row
|
9
|
+
@cause = cause
|
9
10
|
end
|
10
11
|
|
11
|
-
attr_reader :row
|
12
|
+
attr_reader :row, :cause
|
12
13
|
end
|
13
14
|
|
14
15
|
class SourceError < ETLError
|
16
|
+
def initialize(message=nil, cause=$!)
|
17
|
+
super(message)
|
18
|
+
@cause = cause
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :cause
|
15
22
|
end
|
16
23
|
|
17
24
|
class DestinationError < ETLError
|
18
|
-
def initialize(row, message=nil)
|
25
|
+
def initialize(row, message=nil, cause=$!)
|
19
26
|
super message
|
20
27
|
@row = row
|
28
|
+
@cause = cause
|
21
29
|
end
|
22
30
|
|
23
|
-
attr_reader :row
|
31
|
+
attr_reader :row, :cause
|
24
32
|
end
|
25
33
|
end
|
data/lib/setl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: setl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonard Garvey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.4.5
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: Simple Extract Transform & Load - setl
|
@@ -108,4 +108,3 @@ test_files:
|
|
108
108
|
- spec/error_handling_spec.rb
|
109
109
|
- spec/etl_spec.rb
|
110
110
|
- spec/spec_helper.rb
|
111
|
-
has_rdoc:
|