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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f653d17ff9010ff236b2b77be61db1f3e42f6e2dd4708d39d20eb20e042b9c41
4
- data.tar.gz: d441ae590b81d1a3eaa713517263d45c50da5d3cf402621774ee8488adcde5b3
3
+ metadata.gz: 636c082d2dbe3688c83549cf4f915c0b9463fbeb41aff8694369cd9c663778e0
4
+ data.tar.gz: aa732416381545e039c227bc99a4cf49592338157f0094fc2083828d492d630a
5
5
  SHA512:
6
- metadata.gz: f96da2fed54240556aafcb2877c8fd1a23c8c062c92d06cfc4ce4219d64f4131955775e64bd1c98985aca39d92b035645d8139edfead76603ea60daeff516836
7
- data.tar.gz: 1fd250ae471dc68cc2d8322434d4d6f75ee661791f1e552604651d808b817b0874ffa788b0c8e70508f61ea90b49626ebe240db6807ac1f4961bf57e95a95719
6
+ metadata.gz: eac14c3a878f2f4bd70b93dfe33391abaec9cbad3d00917d3dc8d11024a9d7ed5300468145648ba3443d2fe1387ff31a12314d3f1f50debdb2335293a377006d
7
+ data.tar.gz: 2da4e3f3f2444bcecad2f1bb13b975f3a3551a3c568da1b27729dd7cd98ac6a880587a0284d204440c3b177082771e4a5a122abc6f361fa38869a1f5a2739643
@@ -0,0 +1 @@
1
+ github: thbar
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  # see https://www.ruby-lang.org/en/downloads/branches/
4
- # NOTE: temporarily disabled due to failures to be investigated - see #26
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
- HEAD
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
 
@@ -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 'awesome_print'
23
+ gem.add_development_dependency 'amazing_print'
24
24
  gem.add_development_dependency 'minitest-focus'
25
25
  end
@@ -13,7 +13,7 @@ module Kiba
13
13
  end
14
14
 
15
15
  def write(row)
16
- @csv ||= ::CSV.open(filename, 'wb', csv_options)
16
+ @csv ||= ::CSV.open(filename, 'wb', **csv_options)
17
17
  @headers ||= row.keys
18
18
  @headers_written ||= (csv << headers ; true)
19
19
  csv << row.fetch_values(*@headers)
@@ -1,5 +1,3 @@
1
- require 'awesome_print'
2
-
3
1
  module Kiba
4
2
  module Common
5
3
  module DSLExtensions
@@ -12,7 +12,7 @@ module Kiba
12
12
  end
13
13
 
14
14
  def each
15
- ::CSV.foreach(filename, csv_options) do |row|
15
+ ::CSV.foreach(filename, **csv_options) do |row|
16
16
  yield row
17
17
  end
18
18
  end
@@ -1,5 +1,5 @@
1
1
  module Kiba
2
2
  module Common
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -0,0 +1,9 @@
1
+ class TestHashConfiguredObject
2
+ def initialize(config)
3
+ @config = config
4
+ end
5
+
6
+ def each
7
+ yield(@config)
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class TestKeywordProxySource
2
+ def initialize(mandatory:, optional: nil)
3
+ @mandatory = mandatory
4
+ @optional = optional
5
+ end
6
+
7
+ def each
8
+ yield({
9
+ mandatory: @mandatory,
10
+ optional: @optional
11
+ })
12
+ end
13
+ end
@@ -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(*args)
21
+ def run_job(args)
22
22
  rows = []
23
23
  job = Kiba.parse do
24
- source Kiba::Common::Sources::CSV, *args
24
+ source Kiba::Common::Sources::CSV, **args
25
25
  destination TestArrayDestination, rows
26
26
  end
27
27
  Kiba.run(job)
@@ -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
- # instantiate & yield CSV rows for each configuration
40
- transform Kiba::Common::Transforms::SourceTransformAdapter
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)
@@ -1,5 +1,6 @@
1
1
  require_relative 'helper'
2
2
  require 'kiba'
3
+ require 'amazing_print'
3
4
  require 'kiba-common/dsl_extensions/show_me'
4
5
 
5
6
  class TestShowMe < Minitest::Test
@@ -1,6 +1,11 @@
1
1
  require_relative 'helper'
2
- require 'kiba-common/transforms/source_transform_adapter'
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
- transform Kiba::Common::Transforms::SourceTransformAdapter
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
- end
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.0.0
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-01-18 00:00:00.000000000 Z
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: awesome_print
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.0.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
@@ -1,14 +0,0 @@
1
- module Kiba
2
- module Common
3
- module Transforms
4
- class SourceTransformAdapter
5
- def process(args)
6
- args.shift.new(*args).each do |row|
7
- yield(row)
8
- end
9
- nil
10
- end
11
- end
12
- end
13
- end
14
- end