kiba-common 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changes.md +8 -0
- data/README.md +17 -7
- data/lib/kiba-common/dsl_extensions/show_me.rb +2 -1
- data/lib/kiba-common/version.rb +1 -1
- data/test/test_show_me.rb +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9a78f79fe5c727bce8d34e47d627ab90989373a
|
4
|
+
data.tar.gz: 1e5c2928148dbd5a4179f4e28fc4a575d3c0f586
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2073edaeeea322fc85fbf0909c439d53465669b1b0a1de99bff42d73d6673fb3a43f11080da344da3dc00d6cf39f14292adfbe073873762a96a7a890b9b73a2e
|
7
|
+
data.tar.gz: bf8d5816f1d0801a848fa0991e37b219dc0d1601a375aa8cdbf843c835a9ac7481ecbef6dd7f49557c582add51a13e081965eb5f5cc9e5c50e7a487a4ef7a285
|
data/Changes.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
HEAD
|
2
2
|
----
|
3
3
|
|
4
|
+
0.0.2
|
5
|
+
----
|
6
|
+
|
7
|
+
- Update: `show_me!` can be called with a block to pre-process the row before printing.
|
8
|
+
|
9
|
+
0.0.1
|
10
|
+
-----
|
11
|
+
|
4
12
|
- New: Kiba::Common::DSLExtensions::ShowMe (useful to color-print rows during development)
|
5
13
|
- New: Kiba::Common::DSLExtensions::Logger (production logging)
|
data/README.md
CHANGED
@@ -1,16 +1,18 @@
|
|
1
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
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/thbar/kiba-common) [](https://badge.fury.io/rb/kiba-common)
|
4
4
|
|
5
|
-
|
5
|
+
## Usage
|
6
6
|
|
7
|
-
|
7
|
+
Add `kiba-common` to your `Gemfile`:
|
8
8
|
|
9
|
-
|
9
|
+
```ruby
|
10
|
+
gem 'kiba-common'
|
11
|
+
```
|
10
12
|
|
11
|
-
|
13
|
+
Then see below for each module usage & require clause.
|
12
14
|
|
13
|
-
##
|
15
|
+
## Available extensions
|
14
16
|
|
15
17
|
### Kiba::Common::DSLExtensions::Logger
|
16
18
|
|
@@ -53,6 +55,14 @@ transform MyTransform
|
|
53
55
|
show_me! # will color-print the row at this step of the pipeline
|
54
56
|
```
|
55
57
|
|
58
|
+
You can also pre-process the data to only show specific parts of the row:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
require 'active_support/core_ext/hash/except'
|
62
|
+
|
63
|
+
show_me! { |r| r.except(:some_noisy_field) }
|
64
|
+
```
|
65
|
+
|
56
66
|
## Contributing & Legal
|
57
67
|
|
58
68
|
(agreement below borrowed from Sidekiq Legal)
|
@@ -61,4 +71,4 @@ By submitting a Pull Request, you disavow any rights or claims to any changes su
|
|
61
71
|
|
62
72
|
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
73
|
|
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.
|
74
|
+
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.
|
@@ -5,8 +5,9 @@ module Kiba
|
|
5
5
|
module DSLExtensions
|
6
6
|
# Color print your row.
|
7
7
|
module ShowMe
|
8
|
-
def show_me!
|
8
|
+
def show_me!(&pre_process)
|
9
9
|
transform do |row|
|
10
|
+
row = pre_process ? pre_process.call(row) : row
|
10
11
|
# NOTE: invoking Kernel.ap for testing since
|
11
12
|
# ap itself is harder to mock (Kiba Context)
|
12
13
|
Kernel.ap(row)
|
data/lib/kiba-common/version.rb
CHANGED
data/test/test_show_me.rb
CHANGED
@@ -16,4 +16,16 @@ class TestShowMe < Minitest::Test
|
|
16
16
|
Kiba.run(job)
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
def test_show_me_pre_process
|
21
|
+
job = Kiba.parse do
|
22
|
+
extend Kiba::Common::DSLExtensions::ShowMe
|
23
|
+
source TestEnumerableSource, [{this: "OK", not_this: "KO"}]
|
24
|
+
show_me! { |r| r.fetch(:this) }
|
25
|
+
end
|
26
|
+
|
27
|
+
assert_called(Kernel, :ap, ['OK']) do
|
28
|
+
Kiba.run(job)
|
29
|
+
end
|
30
|
+
end
|
19
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2
|
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-
|
11
|
+
date: 2017-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kiba
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.6.
|
112
|
+
rubygems_version: 2.6.13
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Commonly used helpers for Kiba ETL
|