setl 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +25 -1
- data/lib/setl/etl.rb +4 -2
- data/lib/setl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b1728e14e5c1c6a904512d241d340315ea4085a
|
4
|
+
data.tar.gz: f33f22366920fbd08bf2a0451a1e5257f279239c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b4629edc8c4623270e7bdf7a65cec66dd04b4ef6e615421c3198228cf3d68e13d2553a6573675ac88d6476ba2fd3fa3e42be4c687407e5aa546305a11fe08e8
|
7
|
+
data.tar.gz: d2622daeb250e0022d6a055588a0ef205ad9279c38a346f5a1b9b605c100ec4a7e06c9f06f9d7509f8474ed7fbc53c38b9738b2608e8ccbae50e091dccf717b0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install setl
|
22
22
|
|
23
|
-
##
|
23
|
+
## Basics
|
24
24
|
|
25
25
|
1. Define an object that is responsible for sourcing the data. Must respond to `#each` and `yield` to the provided block.
|
26
26
|
2. Define your transformations. These are simple objects that will receive one of the things provided by the source object.
|
@@ -43,6 +43,30 @@ Setl::ETL.new(source, destination).process(transform)
|
|
43
43
|
|
44
44
|
See the examples folder for some more extensive, and realistic, implementations.
|
45
45
|
|
46
|
+
## Error Handling
|
47
|
+
|
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
|
+
|
50
|
+
```ruby
|
51
|
+
Setl::ETL.new(source, destination, stop_on_errors: true).process(transform)
|
52
|
+
```
|
53
|
+
|
54
|
+
If you want to handle errors on your own and perhaps do some sort of logging then simply provide an `error_handler`.
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
error_handler = proc { |row, exception| logger.error "Something failed on #{row.inspect} with #{exception.inspect}" }
|
58
|
+
|
59
|
+
Setl::ETL.new(source, destination, error_handler: error_handler).process(transform)
|
60
|
+
```
|
61
|
+
|
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`.
|
63
|
+
|
64
|
+
## Tips and Todo
|
65
|
+
|
66
|
+
* Mixes well with [Transproc](https://github.com/solnic/transproc).
|
67
|
+
* Check out [Kiba](https://github.com/thbar/kiba) which is a more mature ETL library for Ruby.
|
68
|
+
* Need to investigate how to dispatch rows to a job runner like Sidekiq or SQS.
|
69
|
+
|
46
70
|
## Contributing
|
47
71
|
|
48
72
|
1. Fork it ( https://github.com/[my-github-username]/setl/fork )
|
data/lib/setl/etl.rb
CHANGED
@@ -9,16 +9,18 @@ module Setl
|
|
9
9
|
|
10
10
|
def process(transform)
|
11
11
|
source.each do |row|
|
12
|
-
|
12
|
+
@last_row = row
|
13
13
|
|
14
14
|
begin
|
15
|
-
destination.(transform.(
|
15
|
+
destination.(transform.(row))
|
16
16
|
rescue StandardError => e
|
17
17
|
error_handler.(row, e)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
attr_reader :last_row
|
23
|
+
|
22
24
|
private
|
23
25
|
|
24
26
|
attr_reader :source, :destination, :stop_on_errors, :error_handler
|
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.3
|
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-09-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|