activerecord_csv_importer 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 6d1a505ce5dfd1cb65fed9b65f5cd77e09a8d905
4
- data.tar.gz: 0c04ae7e26d2cc0b96e615d5561ea11aa23e823a
3
+ metadata.gz: 1f2dda1af501f14aedbe3f83187fd5f809da764e
4
+ data.tar.gz: 7efbf3e7a9db826d2d7219ef8b57e68e31807b89
5
5
  SHA512:
6
- metadata.gz: 3c4a4cca5c6a5135f5535cf9399e89d0c18342240bc22ce5936a2bd0d77fb37b853555ed54d5aaecee9392672c8aefce1101ff20392b2c337a3bbabed6489f59
7
- data.tar.gz: a72973e303bb5312d272b3331719238e19e543e1559fe9cd2b9864c6915081693b5fe3833e17eece818bfbd9cd2062fcf25e0d97163d0eca61c60b34020ad527
6
+ metadata.gz: 11fde7090c4d650e99c0423ca5b8896d53184fb38fc9b4601747fb9879cb26449f7c85a0db18b82bb840f72cde469013f3c6ab8560c439bcb7cc95134242d790
7
+ data.tar.gz: fe7af3a43bcddb619102b0069cf385bc3386dffa8e4e7de00c5612afce6275092f0636ad8610493ce858fd053ca43b506ca10090ebaffa9405e96c5e8a8429cb
@@ -15,6 +15,10 @@ module ActiveRecordCSVImporter
15
15
  end
16
16
  end
17
17
 
18
+ def columns_with_definition_names
19
+ columns.select(&:definition).map(&:name)
20
+ end
21
+
18
22
  def column_name_for_model_attribute(attribute)
19
23
  column = columns.find { |c|
20
24
  c.definition.attribute == attribute if c.definition
@@ -42,10 +46,6 @@ module ActiveRecordCSVImporter
42
46
  (column_definitions - columns.map(&:definition)).map(&:name).map(&:to_s)
43
47
  end
44
48
 
45
- def column_definition_names
46
- column_definitions.map(&:name).map(&:to_s)
47
- end
48
-
49
49
  private
50
50
 
51
51
  def find_column_definition(name)
@@ -53,5 +53,9 @@ module ActiveRecordCSVImporter
53
53
  column_definition.match?(name)
54
54
  }
55
55
  end
56
+
57
+ def column_definition_names
58
+ column_definitions.map(&:name).map(&:to_s)
59
+ end
56
60
  end
57
61
  end
@@ -38,7 +38,7 @@ module ActiveRecordCSVImporter
38
38
  end
39
39
 
40
40
  def import_rows(set)
41
- config.model.import(header.column_definition_names.dup, set, config.on_duplicate_key)
41
+ config.model.import(header.columns_with_definition_names.dup, set, config.on_duplicate_key)
42
42
  end
43
43
 
44
44
  def add_to_report(response, set)
@@ -50,7 +50,7 @@ module ActiveRecordCSVImporter
50
50
  end
51
51
 
52
52
  def columns_for(model)
53
- model.attributes.values_at(*header.column_definition_names)
53
+ model.attributes.values_at(*header.columns_with_definition_names)
54
54
  end
55
55
 
56
56
  # Error from the model mapped back to the CSV header if we can
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordCSVImporter
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_csv_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zulfiqar Ali