kiba-common 0.0.0 → 0.0.1

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: 962942843b5373cf0f377bb776ab580edfcbe501
4
- data.tar.gz: a0edc771a6ea86a13ee6bb8e2860df1aa636aa99
3
+ metadata.gz: 5153e0740d046e6d86b11e47d1cd36263be8a019
4
+ data.tar.gz: d9b397babdae819a175ec9aac6d01aae9c46ae4b
5
5
  SHA512:
6
- metadata.gz: eef3e8b74aa52b60ca3cffac489744bd8d6495ddc73cf45dac2980ead1880ce261fbe294590dec09a31c31104f898268f90a3d170c1515daefe7ecedad12a877
7
- data.tar.gz: 3c5d4ef13b423ef3eab9b1132d07c43ed394b2d7b92a5dd0ae87fced7d52c7a8e09dea20ff878f239d14acf6a3082f1e1a53b853f578ef520b73ac3fe5489d3e
6
+ metadata.gz: c149dd10f8544df9947954e567c3ded033b888825245ff992bdcff0cbf9a4510f933cf0d281b66dc4e35502cbac075bf2196c52a0633e7c69dad9771f0c06dee
7
+ data.tar.gz: 72a48a33d211f710dc63edeb5faa1513d22994b91e7948168462ea74692a3e4fee1f3d3b3566e8413561d5ee78e3535af3c88b6a52ec9620015d5bb4b5ed563c
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+
2
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem update bundler
4
+ rvm:
5
+ - 2.4.0
6
+ - 2.3.4
7
+ - 2.2
8
+ - 2.1
9
+ - 2.0
10
+ - jruby-1.7
11
+ - jruby-9
data/Changes.md ADDED
@@ -0,0 +1,5 @@
1
+ HEAD
2
+ ----
3
+
4
+ - New: Kiba::Common::DSLExtensions::ShowMe (useful to color-print rows during development)
5
+ - New: Kiba::Common::DSLExtensions::Logger (production logging)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) LoGeek SARL
2
+
3
+ Kiba Common is an Open Source project licensed under the terms of
4
+ the LGPLv3 license. Please see <http://www.gnu.org/licenses/lgpl-3.0.html>
5
+ for license text.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ Kiba Common is a companion gem to [Kiba](https://github.com/thbar/kiba) and [Kiba Pro](https://github.com/thbar/kiba/blob/master/Pro-Changes.md) in which I'll share commonly used helpers.
2
+
3
+ Please consider it a work-in-progress for the time being.
4
+
5
+ In particular, review the changes when updating, until a proper release is ready.
6
+
7
+ [![Build Status](https://travis-ci.org/thbar/kiba-common.svg?branch=master)](https://travis-ci.org/thbar/kiba-common)
8
+
9
+ ## Usage
10
+
11
+ **Do not try to use a gem version**. While the name has been [reserved](https://rubygems.org/gems/kiba-common), the gem is not yet published for real. Use git master directly.
12
+
13
+ ## Currently available
14
+
15
+ ### Kiba::Common::DSLExtensions::Logger
16
+
17
+ A simple logging facility.
18
+
19
+ Usage:
20
+
21
+ ```ruby
22
+ require 'kiba-common/dsl_extensions/logger'
23
+ extend Kiba::Common::DSLExtensions::Logger
24
+
25
+ pre_process do
26
+ logger.info "pre_process is running!"
27
+ end
28
+ ```
29
+
30
+ By default the logger will output to `STDOUT`.
31
+
32
+ You can customize that behaviour by setting the logger:
33
+
34
+ ```ruby
35
+ require 'kiba-common/dsl_extensions/logger'
36
+ extend Kiba::Common::DSLExtensions::Logger
37
+
38
+ logger = Logger.new(xxx)
39
+ ```
40
+
41
+ ### Kiba::Common::DSLExtensions::ShowMe
42
+
43
+ A way to color-dump rows on the screen, useful at development time while you are looking at the data (requires the `awesome_print` gem).
44
+
45
+ Usage:
46
+
47
+ ```ruby
48
+ require 'kiba-common/dsl_extensions/show_me'
49
+ extend Kiba::Common::DSLExtensions::ShowMe
50
+
51
+ source MySource
52
+ transform MyTransform
53
+ show_me! # will color-print the row at this step of the pipeline
54
+ ```
55
+
56
+ ## Contributing & Legal
57
+
58
+ (agreement below borrowed from Sidekiq Legal)
59
+
60
+ By submitting a Pull Request, you disavow any rights or claims to any changes submitted to the Kiba Common project and assign the copyright of those changes to LoGeek SARL.
61
+
62
+ If you cannot or do not want to reassign those rights (your employment contract for your employer may not allow this), you should not submit a PR. Open an issue and someone else can do the work.
63
+
64
+ This is a legal way of saying "If you submit a PR to us, that code becomes ours". 99.9% of the time that's what you intend anyways; we hope it doesn't scare you away from contributing.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new(:test) do |t|
4
+ t.pattern = 'test/test_*.rb'
5
+ end
6
+
7
+ task default: :test
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/kiba-common/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Thibaut Barrère']
6
+ gem.email = ['thibaut.barrere@gmail.com']
7
+ gem.description = gem.summary = 'Commonly used helpers for Kiba ETL'
8
+ gem.homepage = 'https://github.com/thbar/kiba-common'
9
+ gem.license = 'LGPL-3.0'
10
+ gem.files = `git ls-files | grep -Ev '^(examples)'`.split("\n")
11
+ gem.test_files = `git ls-files -- test/*`.split("\n")
12
+ gem.name = 'kiba-common'
13
+ gem.require_paths = ['lib']
14
+ gem.version = Kiba::Common::VERSION
15
+
16
+ gem.add_dependency 'kiba', '~> 1.0.0'
17
+ gem.add_development_dependency 'rake'
18
+ gem.add_development_dependency 'minitest'
19
+ gem.add_development_dependency 'awesome_print'
20
+ end
@@ -0,0 +1,18 @@
1
+ require 'logger'
2
+
3
+ module Kiba
4
+ module Common
5
+ module DSLExtensions
6
+ # Logging facility for Kiba
7
+ module Logger
8
+ def logger=(logger_instance)
9
+ @logger = logger_instance
10
+ end
11
+
12
+ def logger
13
+ @logger ||= self.logger = ::Logger.new(STDOUT)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ require 'awesome_print'
2
+
3
+ module Kiba
4
+ module Common
5
+ module DSLExtensions
6
+ # Color print your row.
7
+ module ShowMe
8
+ def show_me!
9
+ transform do |row|
10
+ # NOTE: invoking Kernel.ap for testing since
11
+ # ap itself is harder to mock (Kiba Context)
12
+ Kernel.ap(row)
13
+ row
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Kiba
2
+ module Common
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+
4
+ require_relative 'support/test_enumerable_source'
5
+ require_relative 'support/assert_called'
@@ -0,0 +1,10 @@
1
+ module AssertCalled
2
+ def assert_called(klass, method, args, return_value = nil)
3
+ mock = MiniTest::Mock.new
4
+ mock.expect(:call, return_value, args)
5
+ klass.stub(method, mock) do
6
+ yield
7
+ end
8
+ mock.verify
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ class TestEnumerableSource
2
+ def initialize(enumerable)
3
+ @enumerable = enumerable
4
+ end
5
+
6
+ def each
7
+ @enumerable.each do |row|
8
+ yield row
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'helper'
2
+ require 'kiba'
3
+ require 'kiba-common/dsl_extensions/logger'
4
+
5
+ class TestLogger < Minitest::Test
6
+ def test_default_logger
7
+ actual_logger = nil
8
+ Kiba.parse do
9
+ extend Kiba::Common::DSLExtensions::Logger
10
+ actual_logger = logger
11
+ end
12
+ assert actual_logger.is_a?(Logger)
13
+ end
14
+
15
+ def test_set_logger
16
+ buffer = StringIO.new
17
+
18
+ job = Kiba.parse do
19
+ extend Kiba::Common::DSLExtensions::Logger
20
+ logger = Logger.new(buffer)
21
+
22
+ pre_process do
23
+ logger.info 'Logging from pre_process'
24
+ end
25
+ end
26
+ Kiba.run(job)
27
+
28
+ assert_includes buffer.string, 'Logging from pre_process'
29
+ end
30
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'helper'
2
+ require 'kiba'
3
+ require 'kiba-common/dsl_extensions/show_me'
4
+
5
+ class TestShowMe < Minitest::Test
6
+ include AssertCalled
7
+
8
+ def test_show_me
9
+ job = Kiba.parse do
10
+ extend Kiba::Common::DSLExtensions::ShowMe
11
+ source TestEnumerableSource, ['row']
12
+ show_me!
13
+ end
14
+
15
+ assert_called(Kernel, :ap, ['row']) do
16
+ Kiba.run(job)
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,23 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kiba-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibaut Barrère
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Reserved spot for upcoming Kiba Common releases
11
+ date: 2017-12-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kiba
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Commonly used helpers for Kiba ETL
14
70
  email:
15
71
  - thibaut.barrere@gmail.com
16
72
  executables: []
17
73
  extensions: []
18
74
  extra_rdoc_files: []
19
- files: []
20
- homepage: http://thbar.github.io/kiba-common/
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Changes.md
79
+ - Gemfile
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - kiba-common.gemspec
84
+ - lib/kiba-common/dsl_extensions/logger.rb
85
+ - lib/kiba-common/dsl_extensions/show_me.rb
86
+ - lib/kiba-common/version.rb
87
+ - test/helper.rb
88
+ - test/support/assert_called.rb
89
+ - test/support/test_enumerable_source.rb
90
+ - test/test_logger.rb
91
+ - test/test_show_me.rb
92
+ homepage: https://github.com/thbar/kiba-common
21
93
  licenses:
22
94
  - LGPL-3.0
23
95
  metadata: {}
@@ -37,8 +109,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
37
109
  version: '0'
38
110
  requirements: []
39
111
  rubyforge_project:
40
- rubygems_version: 2.6.10
112
+ rubygems_version: 2.6.14
41
113
  signing_key:
42
114
  specification_version: 4
43
- summary: Reserved spot for upcoming Kiba Common releases
44
- test_files: []
115
+ summary: Commonly used helpers for Kiba ETL
116
+ test_files:
117
+ - test/helper.rb
118
+ - test/support/assert_called.rb
119
+ - test/support/test_enumerable_source.rb
120
+ - test/test_logger.rb
121
+ - test/test_show_me.rb