abstract_importer 1.7.0 → 1.9.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: beb6af75a939202a48788cb3cbd6513c074ff514f1d8c7d104b32700ffdcfe63
4
- data.tar.gz: 7ce453f1c101cb56a17642d5b0d21414db6cfd7de3221567f5bce75b4850e93f
3
+ metadata.gz: 0c34dc2d6f5558255316b38ea0f37d7090e18081a7d86a0af0d0a9a9370e30b5
4
+ data.tar.gz: ccd295d5ff7fe47394b8629db231ca8933501e9c55bec8af8d303ab7e8e1d384
5
5
  SHA512:
6
- metadata.gz: b17a2f043ce0a0a7fde5e6de5f1bea224d27142c7bfece25a3e890be4bfb0b4110d6413384949a8d3af4eeec19ad688a8e940556a55e65fa6ef9450468332a20
7
- data.tar.gz: 70a4b060155c6f3104f57654340af8dc43816cddbd1a83c49295b647241e326f7e1edc163f7bf673a3d251cf7d02b7734c320cfceae85e3e277705676756f096
6
+ metadata.gz: dbeb628bcc04d3f1572721f7c97de4f0a2ec83c0b06ede1c4f61456318ce3da42fe129eecec6edb376ae4bdc656de25e993291ed6c2375788f1f11dc4cdcfb62
7
+ data.tar.gz: ea4e8446bda13ca443274afb141a0f9c2e965ba010da76cca5dcc3b6a6e480654e109a15d154a3510a94f10f9246adfaf7c65b774f9f7c8ff70f6a0e26c16448
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.3
1
+ 3.0.5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v1.9.0 (2023 Mar 8)
2
+ * Updated to support Ruby version 3.0+
3
+
4
+ ## v1.8.0 (2021 Dec 10)
5
+ * Added `prepare_scope` as another callback that can be used when importing a collection
6
+
1
7
  ## v1.7.0 (2021 Nov 19)
2
8
  * Updated to handle `insert_all` and `upsert_all` to `has_many through:` relations in Rails 6.1+
3
9
 
@@ -2,6 +2,7 @@ module AbstractImporter
2
2
  class ImportOptions
3
3
  CALLBACKS = [ :finder,
4
4
  :rescue,
5
+ :prepare_scope,
5
6
  :before_build,
6
7
  :before_batch,
7
8
  :before_create,
@@ -58,7 +58,10 @@ module AbstractImporter
58
58
  if scope.respond_to?(:proxy_association) && scope.proxy_association.reflection.through_reflection?
59
59
  scope = scope.klass
60
60
  end
61
- result = scope.public_send(@bulk_operation, batch, @insert_options)
61
+
62
+ scope = invoke_callback(:prepare_scope, scope) || scope
63
+
64
+ result = scope.public_send(@bulk_operation, batch, **@insert_options)
62
65
  add_batch_to_id_map(result) if remap_ids?
63
66
  end
64
67
 
@@ -1,3 +1,3 @@
1
1
  module AbstractImporter
2
- VERSION = "1.7.0"
2
+ VERSION = "1.9.0"
3
3
  end
@@ -17,7 +17,7 @@ class InsertStrategyTest < ActiveSupport::TestCase
17
17
  end
18
18
 
19
19
  should "import the records in batches" do
20
- mock.proxy(Student).insert_all(satisfy { |arg| arg.length == 3 }, anything)
20
+ mock.proxy(Student).insert_all(satisfy { |arg| arg.length == 3 }, returning: anything)
21
21
  import!
22
22
  assert_equal [456, 457, 458], account.students.pluck(:legacy_id)
23
23
  end
@@ -17,7 +17,7 @@ class UpsertStrategyTest < ActiveSupport::TestCase
17
17
  end
18
18
 
19
19
  should "import the records in batches" do
20
- mock.proxy(Student).upsert_all(satisfy { |arg| arg.length == 3 }, anything)
20
+ mock.proxy(Student).upsert_all(satisfy { |arg| arg.length == 3 }, unique_by: anything, returning: anything)
21
21
  import!
22
22
  assert_equal [456, 457, 458], account.students.pluck(:legacy_id)
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstract_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Lail
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-19 00:00:00.000000000 Z
11
+ date: 2023-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -206,7 +206,7 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
- description:
209
+ description:
210
210
  email:
211
211
  - bob.lail@cph.org
212
212
  executables: []
@@ -260,7 +260,7 @@ homepage: https://github.com/cph/abstract_importer
260
260
  licenses:
261
261
  - MIT
262
262
  metadata: {}
263
- post_install_message:
263
+ post_install_message:
264
264
  rdoc_options: []
265
265
  require_paths:
266
266
  - lib
@@ -275,8 +275,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
275
  - !ruby/object:Gem::Version
276
276
  version: '0'
277
277
  requirements: []
278
- rubygems_version: 3.0.3
279
- signing_key:
278
+ rubygems_version: 3.2.33
279
+ signing_key:
280
280
  specification_version: 4
281
281
  summary: Provides services for the mass-import of complex relational data
282
282
  test_files: