csv_step_importer 0.7.3 → 0.7.4

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: 010566e1eef5979197228e21e4b1767c46b4a01dac5b2c5b2a5ab0ced475728a
4
- data.tar.gz: a471e746cef84c4466b064d73da3d8528d68a285cd579b3f5a51ed9ba81a1ffb
3
+ metadata.gz: 38a5dd24101512b6117a0d8d33020b52ccedbeb816b9b49a64473471b471bd64
4
+ data.tar.gz: 1c2bccce9e7945daba6bd90ac18aa68a77f14b401f8c1af6bc0f8d619d94dca9
5
5
  SHA512:
6
- metadata.gz: e85c978b53a36fc142780d740b20929a5352ab9c76c537e6ce323893425192da56d5ace7c1b01fea93ea5388f0daa160955d2d2b1908afc752273b512e0f7ef3
7
- data.tar.gz: ca0dc39aed81533c2de6323e7b112f83783845846a83eb346db641b8ed65adc76ce9b53bb0ba846638ffcca8c88a41e67f490e91587c4a15c868a3746f5754c3
6
+ metadata.gz: fe1abd4a1c0078c4af1e629e769612c8dce19a718522607e692b3d323ff681cbc83335073e4924d94f2aa6fcdccbe045e638febea102d15625adb742aa65f307
7
+ data.tar.gz: a63422a10246541cfa0537538c625c51c55746bfa1730ad718bd2895f6955e87ef8893de3d90cf687d8eb0d9cc25794bb44cf919d21aa1585add255b97f053f5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- csv_step_importer (0.7.2)
4
+ csv_step_importer (0.7.4)
5
5
  activemodel
6
6
  activerecord-import
7
7
  activesupport
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
- # CSVStepImporter
1
+ # csv_step_importer
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/csv_step_importer`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A library to validate, speed up and organize bulk insertion of complex CSV data, including multi-table data.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ It depends on
6
+
7
+ - [zdennis/activerecord-import](https://github.com/zdennis/activerecord-import)
8
+ - [GitHub - tilo/smarter_csv](https://github.com/tilo/smarter_csv)
6
9
 
7
10
  ## Installation
8
11
 
@@ -22,7 +25,64 @@ Or install it yourself as:
22
25
 
23
26
  ## Usage
24
27
 
25
- TODO: Write usage instructions here
28
+ ### Hello world
29
+
30
+ Create a new rails application:
31
+
32
+ ```shell
33
+ rails new currency_wiki --database=mysql
34
+ cd currency_wiki
35
+ echo "gem 'csv_step_importer'" >> Gemfile
36
+ bundle install
37
+ rails g model currency code:string:uniq name:string
38
+ rails db:create db:migrate
39
+ ```
40
+
41
+ Then edit the model like this:
42
+
43
+ /app/models/currency.rb
44
+
45
+ ```ruby
46
+ class Currency < ApplicationRecord
47
+ class ImportableModel < CSVStepImporter::Model::ImportableModel
48
+ # The model to be updated
49
+ def model_class
50
+ ::Currency
51
+ end
52
+
53
+ def columns
54
+ [:code, :name, :created_at, :updated_at]
55
+ end
56
+
57
+ def on_duplicate_key_update
58
+ [:name, :updated_at]
59
+ end
60
+ end
61
+ end
62
+ ```
63
+
64
+
65
+ Create a test CSV file and upload it
66
+
67
+ ```shell
68
+ rails c
69
+ ```
70
+
71
+ ```ruby
72
+ File.open("currencies.csv", "w") do |file|
73
+ file.write(<<~CSV)
74
+ Name,Code
75
+ Euro,EUR
76
+ United States dollar,USD
77
+ Japanese Yen,JPY
78
+ CSV
79
+ end
80
+
81
+ CSVStepImporter::File.new(path: 'currencies.csv', processor_classes: [Currency::ImportableModel]).save
82
+
83
+ puts Currency.all.to_yaml
84
+ ```
85
+
26
86
 
27
87
  ## Development
28
88
 
@@ -32,7 +92,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
92
 
33
93
  ## Contributing
34
94
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/csv_step_importer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
95
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fruwe/csv_step_importer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
96
 
37
97
  ## License
38
98
 
@@ -40,4 +100,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
100
 
41
101
  ## Code of Conduct
42
102
 
43
- Everyone interacting in the CSVStepImporter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/csv_step_importer/blob/master/CODE_OF_CONDUCT.md).
103
+ Everyone interacting in the CSVStepImporter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fruwe/csv_step_importer/blob/master/CODE_OF_CONDUCT.md).
@@ -19,7 +19,8 @@ module CSVStepImporter
19
19
 
20
20
  # set to nil in order to deactivate
21
21
  def reflector_class
22
- CSVStepImporter::Model::Reflector
22
+ # in order to enable reflections return reflector class: CSVStepImporter::Model::Reflector
23
+ nil
23
24
  end
24
25
 
25
26
  # example: env[:company].company_users
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CSVStepImporter
4
- VERSION = "0.7.3"
4
+ VERSION = "0.7.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_step_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian-Manuel Butzke