petl 0.0.1 → 0.1.0

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: c4aef860e78445984a2fa4c4c32216a699abd257
4
- data.tar.gz: 8fb4ea2f027fa88819d368c1cfe5e4c9d3a63458
3
+ metadata.gz: e81cfd5789c4763371eee08ef0b186011fdd7c94
4
+ data.tar.gz: b481436d739a7ec66cb07155edd2af5f0f2780fe
5
5
  SHA512:
6
- metadata.gz: 19567edbfd6e82b3cd1bb7626317820fdc91611b23021837f28d2b5a4bcd64486287cca1c225a98768126d6b2ca500d5064660258e163c0fc5b7f17b1e720c0b
7
- data.tar.gz: 70019a5f685728ce2651df6929ecf01eb3058096fb40d20102a772e6e959e0f6c9627b2de126b9ced1c00303a9b84f958f4f1385de43259901d99706317faf8b
6
+ metadata.gz: c9fe850cdf3e295e59c56030edaff1576c54f97b44f5dd333b68568fb99eb8c3e8a25511d73da905f98f7d4f9d71a89b91397f3fb9f135e5b6d135a201134afa
7
+ data.tar.gz: 03113c404ffa6a6a9226572db0974116ea96d14b0babd170ea2657b71ed699a8c25d23c558e43053f3624c257582aa1f2ea8a270897ee0abbb767a631ef38309
data/README.md CHANGED
@@ -27,7 +27,7 @@ Or install it yourself as:
27
27
  require 'petl'
28
28
 
29
29
  module ETL::Example
30
- extend Petl::ETL
30
+ extend Petl
31
31
  extend self
32
32
 
33
33
  def extract
@@ -1,2 +1,71 @@
1
1
  require "petl/version"
2
- require "petl/etl"
2
+
3
+ module Petl
4
+ def perform logger = Rails.logger
5
+ if batch
6
+ batch_perform logger
7
+ else
8
+ not_batch_perform logger
9
+ end
10
+ end
11
+
12
+ def extract
13
+ raise NotImplementedError.new "#{self}#extract not implemented."
14
+ end
15
+
16
+ def transform
17
+ raise NotImplementedError.new "#{self}#transform not implemented."
18
+ end
19
+
20
+ def load
21
+ raise NotImplementedError.new "#{self}#load not implemented."
22
+ end
23
+
24
+ def source_count
25
+ raise NotImplementedError.new "#{self}#source_count not implemented."
26
+ end
27
+
28
+ def destination_count
29
+ raise NotImplementedError.new "#{self}#destination_count not implemented."
30
+ end
31
+
32
+ def verify logger = Rails.logger
33
+ if source_count != destination_count
34
+ logger.error "#{self}: counts don't match"
35
+ end
36
+
37
+ logger.info "#{self}: source count #{source_count}"
38
+ logger.info "#{self}: destination count #{destination_count}"
39
+ end
40
+
41
+ def batch
42
+ false
43
+ end
44
+
45
+ private
46
+
47
+ def not_batch_perform logger = Rails.logger
48
+ with_profiling logger do
49
+ load(transform(extract))
50
+ verify logger
51
+ end
52
+ end
53
+
54
+ def batch_perform logger = Rails.logger
55
+ with_profiling logger do
56
+ extract do |batch|
57
+ load(transform batch)
58
+ end
59
+ verify logger
60
+ end
61
+ end
62
+
63
+ def with_profiling logger, &block
64
+ start_time = Time.now
65
+ logger.info "#{self} starting at #{start_time}"
66
+
67
+ yield block
68
+
69
+ logger.info "#{self} finished at #{Time.now}. Took #{(Time.now - start_time).round} seconds"
70
+ end
71
+ end
@@ -1,3 +1,3 @@
1
1
  module Petl
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Petl::ETL" do
3
+ describe "Petl" do
4
4
 
5
5
  module TestETL
6
- extend Petl::ETL
6
+ extend Petl
7
7
  extend self
8
8
 
9
9
  def source_count
@@ -66,7 +66,7 @@ describe "Petl::ETL" do
66
66
 
67
67
  context "with batching" do
68
68
  module BatchETL
69
- extend Petl::ETL
69
+ extend Petl
70
70
  extend self
71
71
 
72
72
  def batch
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Tamoykin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-10 00:00:00.000000000 Z
12
+ date: 2013-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -69,10 +69,9 @@ files:
69
69
  - README.md
70
70
  - Rakefile
71
71
  - lib/petl.rb
72
- - lib/petl/etl.rb
73
72
  - lib/petl/version.rb
74
73
  - petl.gemspec
75
- - spec/lib/petl/etl_spec.rb
74
+ - spec/lib/petl_spec.rb
76
75
  - spec/spec_helper.rb
77
76
  homepage: ''
78
77
  licenses:
@@ -99,5 +98,5 @@ signing_key:
99
98
  specification_version: 4
100
99
  summary: Pretty good ETL framework
101
100
  test_files:
102
- - spec/lib/petl/etl_spec.rb
101
+ - spec/lib/petl_spec.rb
103
102
  - spec/spec_helper.rb
@@ -1,71 +0,0 @@
1
- module Petl
2
- module ETL
3
- def perform logger = Rails.logger
4
- if batch
5
- batch_perform logger
6
- else
7
- not_batch_perform logger
8
- end
9
- end
10
-
11
- def extract
12
- raise NotImplementedError.new "#{self}#extract not implemented."
13
- end
14
-
15
- def transform
16
- raise NotImplementedError.new "#{self}#transform not implemented."
17
- end
18
-
19
- def load
20
- raise NotImplementedError.new "#{self}#load not implemented."
21
- end
22
-
23
- def source_count
24
- raise NotImplementedError.new "#{self}#source_count not implemented."
25
- end
26
-
27
- def destination_count
28
- raise NotImplementedError.new "#{self}#destination_count not implemented."
29
- end
30
-
31
- def verify logger = Rails.logger
32
- if source_count != destination_count
33
- logger.error "#{self}: counts don't match"
34
- end
35
-
36
- logger.info "#{self}: source count #{source_count}"
37
- logger.info "#{self}: destination count #{destination_count}"
38
- end
39
-
40
- def batch
41
- false
42
- end
43
-
44
- private
45
-
46
- def not_batch_perform logger = Rails.logger
47
- with_profiling logger do
48
- load(transform(extract))
49
- verify logger
50
- end
51
- end
52
-
53
- def batch_perform logger = Rails.logger
54
- with_profiling logger do
55
- extract do |batch|
56
- load(transform batch)
57
- end
58
- verify logger
59
- end
60
- end
61
-
62
- def with_profiling logger, &block
63
- start_time = Time.now
64
- logger.info "#{self} starting at #{start_time}"
65
-
66
- yield block
67
-
68
- logger.info "#{self} finished at #{Time.now}. Took #{(Time.now - start_time).round} seconds"
69
- end
70
- end
71
- end