importeur 0.2.1 → 0.3.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: 991119a8603e5c354fbe1329fff579e00e3a12bd06b2e8e468de8d567498807a
4
- data.tar.gz: cbc7f5cb1fb21071476b1bd975c876c06949810669373ac10d22e4931455e2c0
3
+ metadata.gz: bcad980a9f4b5d2f67784fec871dd170e5b48ce9180255d51c63b68629cdadae
4
+ data.tar.gz: 27ba1d50f9445283412b8b3bdfe1d1815209911d4bd09aaba543fc5fb70bbe79
5
5
  SHA512:
6
- metadata.gz: a0c732eb03484d40225ee8d7ce337e23f051a40996b56b064e7ea2c058fa90320885d39628f4fe5a86e3d404356fce9bc943f231a99fef8e8d4832ef60da0ac3
7
- data.tar.gz: b0d8c47da29dd911a91b40abdca18d30dd152bb2375f34fc98e15702cdf6644f7c296c2458757ac0345d7634ae8b939a3fbf330f0262db14a54e5e18201c9829
6
+ metadata.gz: 62f42cfe882b4c4278edec84a135007977275c9774ae7d24f68bc59b37e0a2d2c215ae6d88a7d74bec2b28bfeb742e71ec9a2a258800fc83352c1a1dbe9ca8c7
7
+ data.tar.gz: c8b77a7abcbe9e0be3745637c0d79ceaea048dbf3db04de7d43aa0c9aa808859453ff8c7ce4af8286e9e8a1127298e62560a0394675789e5881b25f9cfd1bbd9
@@ -0,0 +1 @@
1
+ 2.5.3
data/README.md CHANGED
@@ -64,8 +64,7 @@ It takes as arguments a data source that needs to implement
64
64
 
65
65
  An `ActiveRecordPostgresLoader` exists, that has a few very specific
66
66
  dependencies. As the name suggests, it imports data into a Postgres database
67
- using `ActiveRecord`. Additionally, the model used, needs to use
68
- `acts_as_paranoid`.
67
+ using `ActiveRecord`. Additionally, it supports `acts_as_paranoid` (optional).
69
68
 
70
69
  Example use-cases can be found in the `spec/integration` directory.
71
70
 
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ['lib']
32
32
 
33
33
  spec.add_development_dependency 'activerecord', '<5'
34
+ spec.add_development_dependency 'acts_as_paranoid'
34
35
  spec.add_development_dependency 'appnexusapi'
35
36
  spec.add_development_dependency 'bucket_cake'
36
37
  spec.add_development_dependency 'bundler', '~> 1.15'
@@ -35,15 +35,16 @@ module Importeur
35
35
  def store_record(attrs, records)
36
36
  record = records.fetch(attrs[primary_key], model.new)
37
37
  record.assign_attributes(attrs)
38
- record.deleted_at = nil
38
+ record.deleted_at = nil if paranoid?
39
39
  return unless record.changed?
40
40
  record.imported_at = Time.now
41
41
  record.save!
42
42
  end
43
43
 
44
44
  def records_for_batch(batch_ids)
45
- model
46
- .with_deleted
45
+ relation = model
46
+ relation = relation.with_deleted if paranoid?
47
+ relation
47
48
  .joins(batch_lookup_join_sql('INNER', batch_ids))
48
49
  .index_by(&primary_key)
49
50
  end
@@ -63,5 +64,10 @@ module Importeur
63
64
  ON imported.primary_key = #{model.table_name}.#{primary_key}
64
65
  SQL
65
66
  end
67
+
68
+ def paranoid?
69
+ return @paranoid if defined?(@paranoid)
70
+ @paranoid = model.ancestors.map(&:to_s).include?('ActsAsParanoid::Core')
71
+ end
66
72
  end
67
73
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Importeur
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: importeur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Helge Rausch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-08 00:00:00.000000000 Z
11
+ date: 2019-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "<"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: acts_as_paranoid
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: appnexusapi
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -203,6 +217,7 @@ files:
203
217
  - ".env"
204
218
  - ".gitignore"
205
219
  - ".rspec"
220
+ - ".ruby-version"
206
221
  - ".travis.yml"
207
222
  - CHANGELOG.md
208
223
  - Gemfile