reevoo-pipeline 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d0e568fda1e586d6383aa4fc88cd1972af801064
4
+ data.tar.gz: 58dfeeefdd784898b0f1ef9abec90c4c54f212f6
5
+ SHA512:
6
+ metadata.gz: 25da6c929200fb6478c559b607974caf0481725b1de09a73565ecd7979c13f2c827c370322a9094d4fd31a59216ac88af358b3a86af4f48db2e4e467a137fe7d
7
+ data.tar.gz: 58814d5916fd28b46b4bdce14bcbc581384c875674daeaeb67d2446b8f1821d18a94d5d2249ac7b4af0f9e8610de42985b8c0f24f98c177683e618b070d1d970
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ AllCops:
2
+ Exclude:
3
+ - spec/**/*
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ - 2.0.0
5
+ notifications:
6
+ hipchat:
7
+ rooms:
8
+ secure: TsK/bMZTm/izur4uaaJ0A8vJiY7929vyV2YgmyEMghlc8SxSdARKCubsbarTpc3kBMKexBPds4ve6BeRuC7iofRwKiRVJEqn7XFsOUXfeTiL+OS/f2Q5ydXQkrPpw6ELW84dSA/nrmhezVE7zMZoAy9jPourIAeBTxRynuYy9rw=
data/CHANGELOG.md ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pipeline.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Philip Stevens
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Reevoo Pipeline
2
+
3
+ An agnostic extractor, transformer, and loader library
4
+
5
+ [![Build Status](https://travis-ci.org/reevoo/pipeline.svg?branch=master)](https://travis-ci.org/reevoo/pipeline)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'pipeline'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install reevoo-pipeline
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( https://github.com/[my-github-username]/pipeline/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ desc 'Run an IRB session with Pipeline pre-loaded'
2
+ task :console do
3
+ exec 'irb -I lib -r pipeline'
4
+ end
5
+
6
+ unless %w(production staging integration).include?(ENV['PIPELINE_ENV'])
7
+ require 'rspec/core/rake_task'
8
+ desc 'Run the test suite'
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
11
+ require 'rubocop/rake_task'
12
+ desc 'Run RuboCop on the lib directory'
13
+ RuboCop::RakeTask.new(:rubocop)
14
+
15
+ task default: [:spec, :rubocop]
16
+ end
data/lib/pipeline.rb ADDED
@@ -0,0 +1,40 @@
1
+ # Pipeline is a library that provides a common interface for implementing
2
+ # pipeline (ETL) behaviour. You can register extractors that may use
3
+ # transformations before pushing into specified loaders.
4
+ module Pipeline
5
+ autoload :Extractor, 'pipeline/extractor'
6
+ autoload :Transformer, 'pipeline/transformer'
7
+ autoload :Loader, 'pipeline/loader'
8
+ autoload :Config, 'pipeline/config'
9
+ autoload :Logging, 'pipeline/logging'
10
+ autoload :Version, 'pipeline/version'
11
+
12
+ module_function
13
+ def register_extractor(extractor)
14
+ extractors << extractor
15
+ end
16
+
17
+ def extractors
18
+ @extractors ||= []
19
+ end
20
+
21
+ def register_transformer(transformer)
22
+ transformers << transformer
23
+ end
24
+
25
+ def transformers
26
+ @transformers ||= []
27
+ end
28
+
29
+ def register_loader(loader)
30
+ loaders << loader
31
+ end
32
+
33
+ def loaders
34
+ @loaders ||= []
35
+ end
36
+
37
+ def logger
38
+ Pipeline::Logging.logger
39
+ end
40
+ end
@@ -0,0 +1,50 @@
1
+ # Based on: https://github.com/gocardless/hutch/blob/master/lib/hutch/config.rb
2
+ require 'logger'
3
+
4
+ module Pipeline
5
+ class UnknownAttributeError < StandardError; end
6
+
7
+ # This defines configuration for the pipeline.
8
+ module Config
9
+ def self.initialize(params = {})
10
+ @config = { log_level: Logger::INFO }.merge(params)
11
+ end
12
+
13
+ def self.get(attr)
14
+ check_attr(attr)
15
+ user_config[attr]
16
+ end
17
+
18
+ def self.set(attr, value)
19
+ check_attr(attr)
20
+ user_config[attr] = value
21
+ end
22
+
23
+ class << self
24
+ alias_method :[], :get
25
+ alias_method :[]=, :set
26
+ end
27
+
28
+ def self.check_attr(attr)
29
+ unless user_config.key?(attr)
30
+ fail UnknownAttributeError, "#{attr} is not a valid config attribute"
31
+ end
32
+ end
33
+
34
+ def self.user_config
35
+ initialize unless @config
36
+ @config
37
+ end
38
+
39
+ def self.method_missing(method, *args, &block)
40
+ attr = method.to_s.sub(/=$/, '').to_sym
41
+ return super unless user_config.key?(attr)
42
+
43
+ if method =~ /=$/
44
+ set(attr, args.first)
45
+ else
46
+ get(attr)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,14 @@
1
+ module Pipeline
2
+ # Include this module in a class to register it as an extractor.
3
+ module Extractor
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ Pipeline.register_extractor(base)
7
+ end
8
+
9
+ # Class methods that you should use to construct your own extractor.
10
+ module ClassMethods
11
+ attr_writer :connection, :command, :transformations
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module Pipeline
2
+ # Include this module in a class to register it as an loader.
3
+ module Loader
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ Pipeline.register_loader(base)
7
+ end
8
+
9
+ # Class methods that you should use to construct your own loader.
10
+ module ClassMethods
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,38 @@
1
+
2
+ # Based on: https://github.com/gocardless/hutch/blob/master/lib/hutch/logging.rb
3
+ require 'logger'
4
+ require 'time'
5
+
6
+ module Pipeline
7
+ # Provides a customized logging module.
8
+ module Logging
9
+ # Pipeline logging format
10
+ class PipelineFormatter < Logger::Formatter
11
+ def call(severity, time, _, message)
12
+ "#{time.utc.iso8601} #{Process.pid} #{severity} -- #{message}\n"
13
+ end
14
+ end
15
+
16
+ def self.setup_logger(target = $stdout)
17
+ require 'pipeline/config'
18
+ @logger = Logger.new(target)
19
+ @logger.level = Pipeline::Config.log_level
20
+ @logger.formatter = PipelineFormatter.new
21
+ @logger
22
+ end
23
+
24
+ def self.logger
25
+ @logger || setup_logger
26
+ end
27
+
28
+ # rubocop:disable Style/TrivialAccessors
29
+ def self.logger=(logger)
30
+ @logger = logger
31
+ end
32
+ # rubocop:enable Style/TrivialAccessors
33
+
34
+ def logger
35
+ Pipeline::Logging.logger
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ module Pipeline
2
+ # Include this module in a class to register it as an transformer.
3
+ module Transformer
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ Pipeline.register_transformer(base)
7
+ end
8
+
9
+ # Class methods that you should use to construct your own transformer.
10
+ module ClassMethods
11
+ def position(value)
12
+ value = value.to_i
13
+ @position = value if value > 0
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ # Semantic Versioning (http://semver.org/)
2
+ module Pipeline
3
+ VERSION = '0.0.2'
4
+ end
data/pipeline.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pipeline/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'reevoo-pipeline'
8
+ spec.version = Pipeline::VERSION
9
+ spec.authors = ['Reevoo Developers']
10
+ spec.email = ['developers@reevoo.com']
11
+ spec.homepage = 'http://reevoo.github.io/projects/pipeline'
12
+ spec.license = 'MIT'
13
+ spec.summary = 'An agnostic extractor, transformer, and loader library'
14
+ spec.description = <<-DESCRIPTION
15
+ Provides a common interface for creating all three parts to the ETL flow.
16
+ DESCRIPTION
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep('bin') { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep('spec')
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.6'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+
26
+ # For tests
27
+ spec.add_development_dependency 'pry', '~> 0.10'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'simplecov', '~> 0.9'
30
+ spec.add_development_dependency 'rubocop', '~> 0.25'
31
+ end
File without changes
@@ -0,0 +1,26 @@
1
+ describe Pipeline::Extractor do
2
+ around(:each) do |example|
3
+ isolate_constants do
4
+ example.run
5
+ end
6
+ end
7
+
8
+ let(:simple_extractor) do
9
+ unless defined? SimpleExtractor
10
+ class SimpleExtractor
11
+ include Pipeline::Extractor
12
+ end
13
+ end
14
+ SimpleExtractor
15
+ end
16
+
17
+ describe 'module inclusion' do
18
+ it 'registers the class as a extractor' do
19
+ expect(Pipeline).to receive(:register_extractor) do |klass|
20
+ expect(klass).to eq(simple_extractor)
21
+ end
22
+
23
+ simple_extractor
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ describe Pipeline::Loader do
2
+ around(:each) do |example|
3
+ isolate_constants do
4
+ example.run
5
+ end
6
+ end
7
+
8
+ let(:simple_loader) do
9
+ unless defined? SimpleLoader
10
+ class SimpleLoader
11
+ include Pipeline::Loader
12
+ end
13
+ end
14
+ SimpleLoader
15
+ end
16
+
17
+ describe 'module inclusion' do
18
+ it 'registers the class as a loader' do
19
+ expect(Pipeline).to receive(:register_loader) do |klass|
20
+ expect(klass).to eq(simple_loader)
21
+ end
22
+
23
+ simple_loader
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ describe Pipeline::Logging do
2
+ let(:dummy_object) do
3
+ class DummyObject
4
+ include Pipeline::Logging
5
+ end
6
+ end
7
+
8
+ describe '#logger' do
9
+ context 'with the default logger' do
10
+ subject { Pipeline::Logging.logger }
11
+
12
+ specify do
13
+ is_expected.to be_instance_of(Logger)
14
+ end
15
+ end
16
+
17
+ context 'with a custom logger' do
18
+ let(:dummy_logger) { double('Dummy logger', warn: true, info: true) }
19
+ after { Pipeline::Logging.setup_logger }
20
+
21
+ it 'users the custom logger' do
22
+ Pipeline::Logging.logger = dummy_logger
23
+ expect(Pipeline::Logging.logger).to eq(dummy_logger)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ describe Pipeline::Transformer do
2
+ around(:each) do |example|
3
+ isolate_constants do
4
+ example.run
5
+ end
6
+ end
7
+
8
+ let(:simple_transformer) do
9
+ unless defined? SimpleTransformer
10
+ class SimpleTransformer
11
+ include Pipeline::Transformer
12
+ end
13
+ end
14
+ SimpleTransformer
15
+ end
16
+
17
+ describe 'module inclusion' do
18
+ it 'registers the class as a transformer' do
19
+ simple_transformer
20
+ expect(Pipeline.transformers.count).to eq(1)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ require 'simplecov'
2
+ SimpleCov.start { add_filter '/spec/' }
3
+
4
+ require 'pry'
5
+ require 'pipeline'
6
+ require 'logger'
7
+
8
+ Dir['./spec/support/**/*.rb'].each { |f| require f }
9
+ RSpec.configure do |config|
10
+ config.before(:all) { Pipeline::Config.log_level = Logger::FATAL }
11
+ config.raise_errors_for_deprecations!
12
+ end
@@ -0,0 +1,3 @@
1
+ def deep_copy(obj)
2
+ Marshal.load(Marshal.dump(obj))
3
+ end
@@ -0,0 +1,10 @@
1
+ # Constants (classes, etc) defined within a block passed to this method
2
+ # will be removed from the global namespace after the block as run.
3
+ def isolate_constants
4
+ existing_constants = Object.constants
5
+ yield
6
+ ensure
7
+ (Object.constants - existing_constants).each do |constant|
8
+ Object.send(:remove_const, constant)
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reevoo-pipeline
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Reevoo Developers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.25'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.25'
97
+ description: |
98
+ Provides a common interface for creating all three parts to the ETL flow.
99
+ email:
100
+ - developers@reevoo.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".rubocop.yml"
108
+ - ".travis.yml"
109
+ - CHANGELOG.md
110
+ - Gemfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - lib/pipeline.rb
115
+ - lib/pipeline/config.rb
116
+ - lib/pipeline/extractor.rb
117
+ - lib/pipeline/loader.rb
118
+ - lib/pipeline/logging.rb
119
+ - lib/pipeline/transformer.rb
120
+ - lib/pipeline/version.rb
121
+ - pipeline.gemspec
122
+ - spec/pipeline/config_spec.rb
123
+ - spec/pipeline/extractor_spec.rb
124
+ - spec/pipeline/loader_spec.rb
125
+ - spec/pipeline/logger_spec.rb
126
+ - spec/pipeline/transformer_spec.rb
127
+ - spec/spec_helper.rb
128
+ - spec/support/deep_copy.rb
129
+ - spec/support/isolate_constants.rb
130
+ homepage: http://reevoo.github.io/projects/pipeline
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.4.1
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: An agnostic extractor, transformer, and loader library
154
+ test_files: []
155
+ has_rdoc: