csv_step_importer 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3aa61b5ab38dce9b4ea17cee5a306a76702df0b189e1842edd560d52b5a854a
4
- data.tar.gz: e2ab71292cd4e37a9da15fe8d15938b772fff870021bf0b5701b7534640a45bb
3
+ metadata.gz: 1484a1f6f6d4e4f648f638b1e776c68ec751affb4c32b4dfd24646bed201225a
4
+ data.tar.gz: 5bdc70909dea9026009fe67f18342ef73279304953a5e6f8bf6aa54a69b69220
5
5
  SHA512:
6
- metadata.gz: dc52902f40a39972214be2dc78930d7f5dea6dd981b57d95c5f06f40a572e2d915348e0ecd8561254623b87a35322b9ff127469d1aded4edde7cdea8a2a70bac
7
- data.tar.gz: f6d3e0216b9b462db1022eec1e791fc1ccae1220fcac33ab816518c3588ee574f527f642b114e4d034e924aa350872d98e07aa6dc3f4c87073d9db4c1ad9d575
6
+ metadata.gz: 1808886963ddc7cd94acfc653bff353ef3d3f5ed7343d4fd6bb6de4ce683320b2322d08c5ab1fc6405f74868c7d6a456f6a8977d23ed89da5733ab374345f77e
7
+ data.tar.gz: 8ce96e5fc900d9d7cbee56563dd14851237defb6c582d3642dce838f806fd1ad60e031ca73b0accf1cebdd87ad10be28859874300f05635b9cc4787a0f0284c9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- csv_step_importer (0.15.0)
4
+ csv_step_importer (0.15.1)
5
5
  activemodel
6
6
  activerecord-import
7
7
  activesupport
@@ -29,6 +29,10 @@ module CSVStepImporter
29
29
  end
30
30
  end
31
31
 
32
+ def ancestors
33
+ @ancestors ||= [parent] + (parent ? parent.ancestors : [])
34
+ end
35
+
32
36
  def persisted?
33
37
  false
34
38
  end
@@ -43,12 +43,8 @@ module CSVStepImporter
43
43
  send key
44
44
  elsif attributes.include? key
45
45
  attributes[key]
46
- elsif row.respond_to?(key)
47
- row.send key
48
- elsif row.attributes.include? key
49
- row.attributes[key]
50
46
  else
51
- nil
47
+ row.send key
52
48
  end
53
49
  end
54
50
 
@@ -14,7 +14,7 @@ module CSVStepImporter
14
14
  #########################################################
15
15
 
16
16
  set :columns, -> { raise "please extend and implement" } # example: [:email, :updated_at, :created_at]
17
- set :composite_key_columns, nil # specify to an array of columns in order filter duplicates from daos
17
+ set :composite_key_columns, nil # specify an array of columns in order filter duplicates from daos after build
18
18
  set :dao_class, CSVStepImporter::Model::DAO
19
19
 
20
20
  #########################################################
@@ -20,7 +20,7 @@ module CSVStepImporter
20
20
  self.children = children
21
21
  end
22
22
 
23
- def build_env env
23
+ def build_env(env)
24
24
  Struct.new(*env.keys).new(*env.values).freeze
25
25
  end
26
26
 
@@ -36,8 +36,12 @@ module CSVStepImporter
36
36
  ignore_invalid_rows ? valid? : true
37
37
  end
38
38
 
39
- def method_missing(sym,*)
40
- attributes.fetch(sym){attributes.fetch(sym.to_s){super}}
39
+ def headers
40
+ ancestors.find { |ancestor|ancestor.respond_to?(:headers) }&.headers
41
+ end
42
+
43
+ def method_missing(sym, *)
44
+ attributes.fetch(sym) { attributes.fetch(sym.to_s) { headers&.include?(sym) ? nil : super } }
41
45
  end
42
46
  end
43
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CSVStepImporter
4
- VERSION = "0.15.0"
4
+ VERSION = "0.15.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_step_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian-Manuel Butzke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-19 00:00:00.000000000 Z
11
+ date: 2018-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler