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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a69608ef7938b0e490055db9bc3cf5d1924f9e0
4
- data.tar.gz: 66b1a67765d78496ab1791d65a4c5f699d4b178f
3
+ metadata.gz: 9b1728e14e5c1c6a904512d241d340315ea4085a
4
+ data.tar.gz: f33f22366920fbd08bf2a0451a1e5257f279239c
5
5
  SHA512:
6
- metadata.gz: 5ff6e5d5cce17d475f08d5ad2965dc1c22d75343b4d4f04ceee9be83a15e0957a5b75a3de58f6c9c9ed374dfcb3e3a703eacd4be872549bb20a5b5393fd286f7
7
- data.tar.gz: d3123a6e871b3b6ff720ff0fbd271cdbde7b4b14032317c58240a39d4bad09f6cb710a8b0942c800095852a94dd03817627eca39c9991de446386b6ea8231410
6
+ metadata.gz: 0b4629edc8c4623270e7bdf7a65cec66dd04b4ef6e615421c3198228cf3d68e13d2553a6573675ac88d6476ba2fd3fa3e42be4c687407e5aa546305a11fe08e8
7
+ data.tar.gz: d2622daeb250e0022d6a055588a0ef205ad9279c38a346f5a1b9b605c100ec4a7e06c9f06f9d7509f8474ed7fbc53c38b9738b2608e8ccbae50e091dccf717b0
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+
16
+ /examples/products/Gemfile.lock
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  $ gem install setl
22
22
 
23
- ## Usage
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 )
@@ -9,16 +9,18 @@ module Setl
9
9
 
10
10
  def process(transform)
11
11
  source.each do |row|
12
- row_copy = row.dup
12
+ @last_row = row
13
13
 
14
14
  begin
15
- destination.(transform.(row_copy))
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
@@ -1,3 +1,3 @@
1
1
  module Setl
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-19 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler