kiba-common 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes.md +8 -0
- data/README.md +9 -7
- data/lib/kiba-common/dsl_extensions/show_me.rb +3 -3
- data/lib/kiba-common/version.rb +1 -1
- data/test/test_show_me.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76aa97f6f777aa6e96f05a088346cdca52426732a0f033b8dcfd2856d78770b8
|
4
|
+
data.tar.gz: 820fddae1f7b853075e927a5fc878a0cbbf3cbda31ad61e2b06b7a446fe8531e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5c036121f7955527bd983afcd37ca71547d99d5b6e48f3ef88351a082b9e7729ae118f8251896c6474410ad8a8674da96140f7ea47f04dabe024aca15e64eea
|
7
|
+
data.tar.gz: 0fcec0f0342151ce1a408292b80e41852ae0094aa20887ae23abdebdee73a6604cfa3086cc980bfc6d368667460765cb28a7d6e1b11464e147545ca6ee7e6764
|
data/Changes.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
HEAD
|
2
2
|
----
|
3
3
|
|
4
|
+
0.8.0
|
5
|
+
-----
|
6
|
+
|
7
|
+
- Bugfix: `show_me!` used with a block should not modify the processed row.
|
8
|
+
|
9
|
+
0.7.0
|
10
|
+
-----
|
11
|
+
|
4
12
|
- New: Kiba::Common::Transforms::SourceTransformAdapter let you transform rows into parameters for source instantiation.
|
5
13
|
|
6
14
|
0.6.0
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ But since Kiba v2 introduction of `StreamingRunner`, it is possible for transfor
|
|
48
48
|
|
49
49
|
Leveraging that possibility, you can use a `SourceTransformAdapter` to dynamically instantiate the source for each of your input rows.
|
50
50
|
|
51
|
-
This allows to mix-and-match components in a much more versatile & powerful way.
|
51
|
+
This allows you to mix-and-match components in a much more versatile & powerful way.
|
52
52
|
|
53
53
|
Requirements: Kiba v2 with `StreamingRunner` enabled.
|
54
54
|
|
@@ -85,7 +85,7 @@ require 'kiba-common/transforms/enumerable_exploder'
|
|
85
85
|
transform Kiba::Common::Transforms::EnumerableExploder
|
86
86
|
```
|
87
87
|
|
88
|
-
|
88
|
+
This can help if you are reading XML/JSON documents from a source and each input document contains multiple rows that you want to extract.
|
89
89
|
|
90
90
|
```ruby
|
91
91
|
source Kiba::Common::Sources::Enumerable, -> { Dir["input/*.xml"] }
|
@@ -104,7 +104,7 @@ Similarly, if you have a CSV document as your input:
|
|
104
104
|
| ------------- | ------------- |
|
105
105
|
| 00001 | John:Mary:Sally |
|
106
106
|
|
107
|
-
and you want to reformat it to
|
107
|
+
and you want to reformat it to the following:
|
108
108
|
|
109
109
|
| po_number | buyer |
|
110
110
|
|-------------|---------|
|
@@ -135,11 +135,11 @@ A way to dump `Hash` rows as CSV.
|
|
135
135
|
|
136
136
|
All rows are expected to have the exact same set of keys as the first row.
|
137
137
|
|
138
|
-
The headers will be the first row keys
|
138
|
+
The headers will be the first row keys unless you pass an array of keys via `headers`.
|
139
139
|
|
140
|
-
All keys are mandatory (although they can have a nil value).
|
140
|
+
All keys are mandatory (although they can have a `nil` value).
|
141
141
|
|
142
|
-
Use the `csv_options` keyword to control the output format like
|
142
|
+
Use the `csv_options` keyword to control the output format like when using [Ruby CSV class](http://ruby-doc.org/stdlib-2.4.0/libdoc/csv/rdoc/CSV.html#method-c-new).
|
143
143
|
|
144
144
|
Usage:
|
145
145
|
|
@@ -189,7 +189,7 @@ logger = Logger.new(xxx)
|
|
189
189
|
|
190
190
|
### Kiba::Common::DSLExtensions::ShowMe
|
191
191
|
|
192
|
-
A way to color-dump rows on the screen, useful
|
192
|
+
A way to color-dump rows on the screen, useful during development when you are inspecting the data (requires the `awesome_print` gem).
|
193
193
|
|
194
194
|
Usage:
|
195
195
|
|
@@ -212,6 +212,8 @@ show_me! { |r| r.except(:some_noisy_field) }
|
|
212
212
|
|
213
213
|
## Contributing & Legal
|
214
214
|
|
215
|
+
See [LICENSE](LICENSE) for license.
|
216
|
+
|
215
217
|
(agreement below borrowed from Sidekiq Legal)
|
216
218
|
|
217
219
|
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.
|
@@ -6,12 +6,12 @@ module Kiba
|
|
6
6
|
# Color print your row.
|
7
7
|
module ShowMe
|
8
8
|
def show_me!(&pre_process)
|
9
|
-
transform do |
|
10
|
-
row = pre_process ? pre_process.call(
|
9
|
+
transform do |original_row|
|
10
|
+
row = pre_process ? pre_process.call(original_row) : original_row
|
11
11
|
# NOTE: invoking Kernel.ap for testing since
|
12
12
|
# ap itself is harder to mock (Kiba Context)
|
13
13
|
Kernel.ap(row)
|
14
|
-
|
14
|
+
original_row
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/kiba-common/version.rb
CHANGED
data/test/test_show_me.rb
CHANGED
@@ -18,14 +18,18 @@ class TestShowMe < Minitest::Test
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_show_me_pre_process
|
21
|
+
output = []
|
21
22
|
job = Kiba.parse do
|
22
23
|
extend Kiba::Common::DSLExtensions::ShowMe
|
23
24
|
source Kiba::Common::Sources::Enumerable, [{this: "OK", not_this: "KO"}]
|
24
25
|
show_me! { |r| r.fetch(:this) }
|
26
|
+
destination TestArrayDestination, output
|
25
27
|
end
|
26
28
|
|
27
29
|
assert_called(Kernel, :ap, ['OK']) do
|
28
30
|
Kiba.run(job)
|
29
31
|
end
|
32
|
+
|
33
|
+
assert_equal [{this: "OK", not_this: "KO"}], output
|
30
34
|
end
|
31
35
|
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.
|
4
|
+
version: 0.8.0
|
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: 2018-02-
|
11
|
+
date: 2018-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kiba
|