kiba-common 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.travis.yml +4 -2
- data/Changes.md +23 -1
- data/README.md +1 -1
- data/kiba-common.gemspec +1 -1
- data/lib/kiba-common/destinations/csv.rb +1 -1
- data/lib/kiba-common/dsl_extensions/show_me.rb +0 -2
- data/lib/kiba-common/sources/csv.rb +1 -1
- data/lib/kiba-common/version.rb +1 -1
- data/test/support/test_hash_configured_object.rb +9 -0
- data/test/support/test_keyword_proxy_source.rb +13 -0
- data/test/test_csv_source.rb +2 -2
- data/test/test_integration.rb +9 -4
- data/test/test_show_me.rb +1 -0
- data/test/test_source_transform_adapter.rb +67 -3
- metadata +12 -8
- data/lib/kiba-common/transforms/source_transform_adapter.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 636c082d2dbe3688c83549cf4f915c0b9463fbeb41aff8694369cd9c663778e0
|
4
|
+
data.tar.gz: aa732416381545e039c227bc99a4cf49592338157f0094fc2083828d492d630a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eac14c3a878f2f4bd70b93dfe33391abaec9cbad3d00917d3dc8d11024a9d7ed5300468145648ba3443d2fe1387ff31a12314d3f1f50debdb2335293a377006d
|
7
|
+
data.tar.gz: 2da4e3f3f2444bcecad2f1bb13b975f3a3551a3c568da1b27729dd7cd98ac6a880587a0284d204440c3b177082771e4a5a122abc6f361fa38869a1f5a2739643
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: thbar
|
data/.travis.yml
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
# see https://www.ruby-lang.org/en/downloads/branches/
|
4
|
-
|
5
|
-
# - ruby-head
|
4
|
+
- ruby-head
|
6
5
|
- 2.7
|
7
6
|
- 2.6
|
8
7
|
- 2.5
|
@@ -13,3 +12,6 @@ rvm:
|
|
13
12
|
- jruby-9.1
|
14
13
|
- jruby-9.2
|
15
14
|
- truffleruby
|
15
|
+
# Freezing the JDK to provide some consistency between CI builds only.
|
16
|
+
jdk:
|
17
|
+
- openjdk8
|
data/Changes.md
CHANGED
@@ -1,6 +1,28 @@
|
|
1
|
-
|
1
|
+
1.1.0
|
2
2
|
----
|
3
3
|
|
4
|
+
- Support for Ruby 2.7+ (affects CSV source and destination)
|
5
|
+
- Breaking: `show_me!` is now compatible with both `awesome_print` and its modern replacement `amazing_print`. You will have to `require` the one you want to use in your code from now on.
|
6
|
+
- Breaking: `SourceTransformAdapter` has been removed due to complexities with Ruby 2.7+ keyword arguments. The suggested replacement is to use `Enumerator` and `EnumerableExploder` like this:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
# before
|
10
|
+
transform SourceTransformAdapter
|
11
|
+
|
12
|
+
# after
|
13
|
+
transform do |klass, args|
|
14
|
+
Enumerator.new do |y|
|
15
|
+
# NOTE: you may have to use double-splat (**) here instead
|
16
|
+
# if you provide keyword arguments, or other variants
|
17
|
+
klass.new(*args).each do |r|
|
18
|
+
y << r
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
transform Kiba::Common::Transforms::EnumerableExploder
|
24
|
+
```
|
25
|
+
|
4
26
|
1.0.0
|
5
27
|
-----
|
6
28
|
|
data/README.md
CHANGED
@@ -277,7 +277,7 @@ logger = Logger.new(xxx)
|
|
277
277
|
|
278
278
|
### Kiba::Common::DSLExtensions::ShowMe
|
279
279
|
|
280
|
-
A way to color-dump rows on the screen, useful during development when you are inspecting the data (requires the `awesome_print` gem).
|
280
|
+
A way to color-dump rows on the screen, useful during development when you are inspecting the data (requires either the `amazing_print` or the `awesome_print` gem).
|
281
281
|
|
282
282
|
Usage:
|
283
283
|
|
data/kiba-common.gemspec
CHANGED
@@ -20,6 +20,6 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency 'kiba', '>= 1.0.0', '< 4'
|
21
21
|
gem.add_development_dependency 'rake'
|
22
22
|
gem.add_development_dependency 'minitest'
|
23
|
-
gem.add_development_dependency '
|
23
|
+
gem.add_development_dependency 'amazing_print'
|
24
24
|
gem.add_development_dependency 'minitest-focus'
|
25
25
|
end
|
data/lib/kiba-common/version.rb
CHANGED
data/test/test_csv_source.rb
CHANGED
@@ -18,10 +18,10 @@ class TestCSVSource < MiniTest::Test
|
|
18
18
|
FileUtils.rm(TEST_FILENAME) if File.exist?(TEST_FILENAME)
|
19
19
|
end
|
20
20
|
|
21
|
-
def run_job(
|
21
|
+
def run_job(args)
|
22
22
|
rows = []
|
23
23
|
job = Kiba.parse do
|
24
|
-
source Kiba::Common::Sources::CSV,
|
24
|
+
source Kiba::Common::Sources::CSV, **args
|
25
25
|
destination TestArrayDestination, rows
|
26
26
|
end
|
27
27
|
Kiba.run(job)
|
data/test/test_integration.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require_relative 'helper'
|
2
2
|
require 'kiba'
|
3
3
|
require_relative 'support/test_array_destination'
|
4
|
-
require 'kiba-common/transforms/source_transform_adapter'
|
5
4
|
require 'kiba-common/sources/csv'
|
6
5
|
require 'kiba-common/destinations/csv'
|
7
6
|
|
@@ -36,9 +35,15 @@ class TestIntegration < Minitest::Test
|
|
36
35
|
]
|
37
36
|
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
transform do |klass, args|
|
39
|
+
Enumerator.new do |y|
|
40
|
+
klass.new(**args).each do |r|
|
41
|
+
y << r
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
transform Kiba::Common::Transforms::EnumerableExploder
|
46
|
+
|
42
47
|
destination TestArrayDestination, rows
|
43
48
|
end
|
44
49
|
Kiba.run(job)
|
data/test/test_show_me.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
require_relative 'helper'
|
2
|
-
|
2
|
+
require_relative 'support/test_keyword_proxy_source'
|
3
|
+
require_relative 'support/test_hash_configured_object'
|
3
4
|
|
5
|
+
# NOTE: the SourceTransformAdapter has been removed,
|
6
|
+
# but I'm keeping these tests, patched to instead use
|
7
|
+
# Enumerator, as a way to verify that the alternative
|
8
|
+
# I provided in the change log still works.
|
4
9
|
class TestSourceTransformAdapter < Minitest::Test
|
5
10
|
include Kiba::Common::Sources
|
6
11
|
include Kiba::DSLExtensions
|
@@ -15,10 +20,69 @@ class TestSourceTransformAdapter < Minitest::Test
|
|
15
20
|
[ Enumerable, (1..10) ],
|
16
21
|
[ Enumerable, (11..20) ]
|
17
22
|
]
|
18
|
-
|
23
|
+
|
24
|
+
transform do |klass, args|
|
25
|
+
Enumerator.new do |y|
|
26
|
+
klass.new(args).each do |r|
|
27
|
+
y << r
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
transform Kiba::Common::Transforms::EnumerableExploder
|
32
|
+
|
19
33
|
destination TestArrayDestination, rows
|
20
34
|
end
|
21
35
|
Kiba.run(job)
|
22
36
|
assert_equal (1..20).to_a, rows
|
23
37
|
end
|
24
|
-
|
38
|
+
|
39
|
+
def test_instantiation_keyword_arguments
|
40
|
+
rows = []
|
41
|
+
job = Kiba.parse do
|
42
|
+
source Enumerable, [
|
43
|
+
# Test against a class that expects explicit keyword arguments
|
44
|
+
[ TestKeywordProxySource, {mandatory: "some value"} ]
|
45
|
+
]
|
46
|
+
|
47
|
+
transform do |klass, args|
|
48
|
+
Enumerator.new do |y|
|
49
|
+
klass.new(**args).each do |r|
|
50
|
+
y << r
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
transform Kiba::Common::Transforms::EnumerableExploder
|
55
|
+
|
56
|
+
destination TestArrayDestination, rows
|
57
|
+
end
|
58
|
+
Kiba.run(job)
|
59
|
+
assert_equal([
|
60
|
+
{mandatory: "some value", optional: nil}
|
61
|
+
], rows)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_hash_configured_object
|
65
|
+
rows = []
|
66
|
+
job = Kiba.parse do
|
67
|
+
source Enumerable, [
|
68
|
+
# Test against a class that takes a single Hash argument
|
69
|
+
[ TestHashConfiguredObject, {mandatory: "some value"} ]
|
70
|
+
]
|
71
|
+
|
72
|
+
transform do |klass, args|
|
73
|
+
Enumerator.new do |y|
|
74
|
+
klass.new(**args).each do |r|
|
75
|
+
y << r
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
transform Kiba::Common::Transforms::EnumerableExploder
|
80
|
+
|
81
|
+
destination TestArrayDestination, rows
|
82
|
+
end
|
83
|
+
Kiba.run(job)
|
84
|
+
assert_equal([
|
85
|
+
{mandatory: "some value"}
|
86
|
+
], rows)
|
87
|
+
end
|
88
|
+
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: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibaut Barrère
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kiba
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: amazing_print
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
@@ -93,6 +93,7 @@ executables: []
|
|
93
93
|
extensions: []
|
94
94
|
extra_rdoc_files: []
|
95
95
|
files:
|
96
|
+
- ".github/FUNDING.yml"
|
96
97
|
- ".gitignore"
|
97
98
|
- ".travis.yml"
|
98
99
|
- Changes.md
|
@@ -108,11 +109,12 @@ files:
|
|
108
109
|
- lib/kiba-common/sources/csv.rb
|
109
110
|
- lib/kiba-common/sources/enumerable.rb
|
110
111
|
- lib/kiba-common/transforms/enumerable_exploder.rb
|
111
|
-
- lib/kiba-common/transforms/source_transform_adapter.rb
|
112
112
|
- lib/kiba-common/version.rb
|
113
113
|
- test/helper.rb
|
114
114
|
- test/support/assert_called.rb
|
115
115
|
- test/support/test_array_destination.rb
|
116
|
+
- test/support/test_hash_configured_object.rb
|
117
|
+
- test/support/test_keyword_proxy_source.rb
|
116
118
|
- test/test_csv_destination.rb
|
117
119
|
- test/test_csv_source.rb
|
118
120
|
- test/test_enumerable_exploder_transform.rb
|
@@ -128,7 +130,7 @@ licenses:
|
|
128
130
|
metadata:
|
129
131
|
source_code_uri: https://github.com/thbar/kiba-common
|
130
132
|
documentation_uri: https://github.com/thbar/kiba-common/blob/master/README.md
|
131
|
-
post_install_message:
|
133
|
+
post_install_message:
|
132
134
|
rdoc_options: []
|
133
135
|
require_paths:
|
134
136
|
- lib
|
@@ -143,14 +145,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
145
|
- !ruby/object:Gem::Version
|
144
146
|
version: '0'
|
145
147
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
147
|
-
signing_key:
|
148
|
+
rubygems_version: 3.1.2
|
149
|
+
signing_key:
|
148
150
|
specification_version: 4
|
149
151
|
summary: Commonly used helpers for Kiba ETL
|
150
152
|
test_files:
|
151
153
|
- test/helper.rb
|
152
154
|
- test/support/assert_called.rb
|
153
155
|
- test/support/test_array_destination.rb
|
156
|
+
- test/support/test_hash_configured_object.rb
|
157
|
+
- test/support/test_keyword_proxy_source.rb
|
154
158
|
- test/test_csv_destination.rb
|
155
159
|
- test/test_csv_source.rb
|
156
160
|
- test/test_enumerable_exploder_transform.rb
|