activerecord_csv_importer 0.1.2 → 0.1.3

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: 1f2dda1af501f14aedbe3f83187fd5f809da764e
4
- data.tar.gz: 7efbf3e7a9db826d2d7219ef8b57e68e31807b89
3
+ metadata.gz: 44eb851d750d0fbaa869e101d8e8ea82cff78155
4
+ data.tar.gz: 930a65e74c117c66c03780f9580e3a8544887cd9
5
5
  SHA512:
6
- metadata.gz: 11fde7090c4d650e99c0423ca5b8896d53184fb38fc9b4601747fb9879cb26449f7c85a0db18b82bb840f72cde469013f3c6ab8560c439bcb7cc95134242d790
7
- data.tar.gz: fe7af3a43bcddb619102b0069cf385bc3386dffa8e4e7de00c5612afce6275092f0636ad8610493ce858fd053ca43b506ca10090ebaffa9405e96c5e8a8429cb
6
+ metadata.gz: 7704ec50b0940aadd89bb55b971df9eee9fc68d08cd022a414d095a0741e1b7b2c46e86bf2e61b5602e536fc41f60dd3de7ca63d6452b20aaa48b0f4fa30049a
7
+ data.tar.gz: 7c5363eddd44dc8b86807af76592434719bbd2d6c275787a745431760f24eedb9fbf4fc12974e45cb0d4444bdb62b88250547ff51c7951cae76ae3777dc49808
data/README.md CHANGED
@@ -1,11 +1,8 @@
1
1
  # ActiveRecordCSVImporter
2
2
 
3
- Using bulk inserts, the goal for ActiveRecordCSVImporter is to speed up the processing of large CSV filed
3
+ ActiveRecordCSVImporter is a modified version CSVImporter, which uses activerecord-import to speed up processing.
4
4
 
5
- ## Differences from CSVImporter
6
-
7
- The key difference with ActiveRecordCSVImporter is the removal of callback support, since that is incompatible with bulk inserts.
8
- Additional config options are available instead to deal with batching and duplicate index support.
5
+ The key difference with CSVImporter is the removal of callback support, since that is incompatible with bulk inserts. Additional config options are available instead to deal with batching and index conflicts.
9
6
 
10
7
  It is compatible with ActiveRecord and any Databases supported by activerecord-import.
11
8
 
@@ -323,6 +320,10 @@ You can handle exotic encodings with the `encoding` option.
323
320
  ImportUserCSV.new(content: "メール,氏名".encode('SJIS'), encoding: 'SJIS:UTF-8')
324
321
  ```
325
322
 
323
+ ## TODO
324
+ - Add ability to configure activerecord-import validate: Bool option.
325
+ - Allow setting a default attribute on columns.
326
+
326
327
  ## Development
327
328
 
328
329
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -331,7 +332,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
331
332
 
332
333
  ## Contributing
333
334
 
334
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/activerecord_csv_importer.
335
+ Bug reports and pull requests are welcome on GitHub at https://github.com/desheikh/activerecord_csv_importer.
335
336
 
336
337
  ## License
337
338
 
@@ -15,10 +15,16 @@ module ActiveRecordCSVImporter
15
15
  end
16
16
  end
17
17
 
18
+ # original csv column names
18
19
  def columns_with_definition_names
19
20
  columns.select(&:definition).map(&:name)
20
21
  end
21
22
 
23
+ # mapped column names
24
+ def column_definition_names
25
+ column_definitions.map(&:name).map(&:to_s)
26
+ end
27
+
22
28
  def column_name_for_model_attribute(attribute)
23
29
  column = columns.find { |c|
24
30
  c.definition.attribute == attribute if c.definition
@@ -53,9 +59,5 @@ module ActiveRecordCSVImporter
53
59
  column_definition.match?(name)
54
60
  }
55
61
  end
56
-
57
- def column_definition_names
58
- column_definitions.map(&:name).map(&:to_s)
59
- end
60
62
  end
61
63
  end
@@ -33,7 +33,7 @@ module ActiveRecordCSVImporter
33
33
  if column_definition.to && column_definition.to.is_a?(Proc)
34
34
  column_definition.to.call(csv_value)
35
35
  else
36
- column_definition.attribute
36
+ csv_value
37
37
  end
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordCSVImporter
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_csv_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zulfiqar Ali
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-12 00:00:00.000000000 Z
11
+ date: 2016-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus