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 +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +11 -0
- data/Changes.md +5 -0
- data/Gemfile +3 -0
- data/LICENSE +5 -0
- data/README.md +64 -0
- data/Rakefile +7 -0
- data/kiba-common.gemspec +20 -0
- data/lib/kiba-common/dsl_extensions/logger.rb +18 -0
- data/lib/kiba-common/dsl_extensions/show_me.rb +19 -0
- data/lib/kiba-common/version.rb +5 -0
- data/test/helper.rb +5 -0
- data/test/support/assert_called.rb +10 -0
- data/test/support/test_enumerable_source.rb +11 -0
- data/test/test_logger.rb +30 -0
- data/test/test_show_me.rb +19 -0
- metadata +86 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5153e0740d046e6d86b11e47d1cd36263be8a019
|
4
|
+
data.tar.gz: d9b397babdae819a175ec9aac6d01aae9c46ae4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c149dd10f8544df9947954e567c3ded033b888825245ff992bdcff0cbf9a4510f933cf0d281b66dc4e35502cbac075bf2196c52a0633e7c69dad9771f0c06dee
|
7
|
+
data.tar.gz: 72a48a33d211f710dc63edeb5faa1513d22994b91e7948168462ea74692a3e4fee1f3d3b3566e8413561d5ee78e3535af3c88b6a52ec9620015d5bb4b5ed563c
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Changes.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
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
data/kiba-common.gemspec
ADDED
@@ -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
|
data/test/helper.rb
ADDED
data/test/test_logger.rb
ADDED
@@ -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.
|
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-
|
12
|
-
dependencies:
|
13
|
-
|
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
|
-
|
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.
|
112
|
+
rubygems_version: 2.6.14
|
41
113
|
signing_key:
|
42
114
|
specification_version: 4
|
43
|
-
summary:
|
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
|