csv-importer 0.3.2 → 0.4.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
  SHA1:
3
- metadata.gz: 6633b4c3453d25cf7071a1f9cf68f80f82c946cd
4
- data.tar.gz: 252b40c27f5e1569af2dac05c5f0bbafa1170777
3
+ metadata.gz: cfff4468934d3d7fd8e13b81d618bd2691f3fac7
4
+ data.tar.gz: f8980b3710130e74d400c9f649da525da7d46145
5
5
  SHA512:
6
- metadata.gz: 95ce42e97b4deee80fcb36d0ae9db97f1ba292a3a62cccb9a593c9682a6dffb11e202c3aed0f55c2e55ddd2496a89b9087f5c88af516f2e97faa0cc3e50780a0
7
- data.tar.gz: 6da83969a1673e7f96c3356dc86d5462124a5c90e1081005d1a0e6795c0bcf8d3e12afa981d48b8ba4db5b3ce3ecf3e1880cbcd68563ea1ccb7b3af6fabc4118
6
+ metadata.gz: cd7068f3d2a32f40b58234fc0805883891e5212aeed10dab1c42c1b3198475080e18a88107fd095d02cda7002740b05c1d1436ec0a6e034899d9c0b0a12c93dc
7
+ data.tar.gz: aa78cf760944b7db3204e746b480e01a161ab4a834ddb79aae65a4d33d7b41f8b03a34d68e898add41a7b209d033c3613b06f264fdfcbb380d092ce69e89ea7d
@@ -3,4 +3,6 @@ rvm:
3
3
  - 2.3.0
4
4
  addons:
5
5
  code_climate:
6
- repo_token: 0e005c563813539e6d0cdca9a3e95b3c0f1c79f32284f8eaa93b54c57303d427
6
+ repo_token: bcecbf1b229a2ddd666a2c3830f26a0113fd56ae1586d30d2d3fb1af837bf0e4
7
+ after_success:
8
+ - bundle exec codeclimate-test-reporter
@@ -2,6 +2,17 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.4.0] - 2017-08-10
6
+
7
+ ### Added
8
+
9
+ * Rows are now aware of their line number.
10
+
11
+ ```ruby
12
+ import.report.invalid_rows.map { |row| [row.line_number, row.model.email, row.errors] }
13
+ # => [ [2, "INVALID_EMAIL", { "email" => "is invalid" } ] ]
14
+ ```
15
+
5
16
  ## [0.3.2] - 2017-01-06
6
17
 
7
18
  ### Fixed
data/README.md CHANGED
@@ -7,11 +7,11 @@ CSVImporter aims to handle validations, column mapping, import
7
7
  and reporting.
8
8
 
9
9
  [![Build
10
- Status](https://travis-ci.org/BrewhouseTeam/csv-importer.svg)](https://travis-ci.org/BrewhouseTeam/csv-importer)
10
+ Status](https://travis-ci.org/pcreux/csv-importer.svg)](https://travis-ci.org/pcreux/csv-importer)
11
11
  [![Code
12
- Climate](https://codeclimate.com/github/BrewhouseTeam/csv-importer/badges/gpa.svg)](https://codeclimate.com/github/BrewhouseTeam/csv-importer)
12
+ Climate](https://codeclimate.com/github/pcreux/csv-importer/badges/gpa.svg)](https://codeclimate.com/github/pcreux/csv-importer)
13
13
  [![Test
14
- Coverage](https://codeclimate.com/github/BrewhouseTeam/csv-importer/badges/coverage.svg)](https://codeclimate.com/github/BrewhouseTeam/csv-importer/coverage)
14
+ Coverage](https://codeclimate.com/github/pcreux/csv-importer/badges/coverage.svg)](https://codeclimate.com/github/pcreux/csv-importer/coverage)
15
15
  [![Gem
16
16
  Version](https://badge.fury.io/rb/csv-importer.svg)](http://badge.fury.io/rb/csv-importer)
17
17
 
@@ -353,8 +353,8 @@ You can get your hands dirty and fetch the errored rows and the
353
353
  associated error message:
354
354
 
355
355
  ```ruby
356
- import.report.invalid_rows.map { |row| [row.model.email, row.errors] }
357
- # => [ [ "INVALID_EMAIL", { "email" => "is invalid" } ] ]
356
+ import.report.invalid_rows.map { |row| [row.line_number, row.model.email, row.errors] }
357
+ # => [ [2, "INVALID_EMAIL", { "email" => "is invalid" } ] ]
358
358
  ```
359
359
 
360
360
  We do our best to map the errors back to the original column name. So
@@ -415,7 +415,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
415
415
 
416
416
  ## Contributing
417
417
 
418
- 1. Fork it ( https://github.com/BrewhouseTeam/csv-importer/fork )
418
+ 1. Fork it ( https://github.com/pcreux/csv-importer/fork )
419
419
  2. Create your feature branch (`git checkout -b my-new-feature`)
420
420
  3. Commit your changes (`git commit -am 'Add some feature'`)
421
421
  4. Push to the branch (`git push origin my-new-feature`)
@@ -69,8 +69,8 @@ module CSVImporter
69
69
 
70
70
  # Initialize and return the `Row`s for the current CSV file
71
71
  def rows
72
- csv.rows.map do |row_array|
73
- Row.new(header: header, row_array: row_array, model_klass: config.model,
72
+ csv.rows.map.with_index(2) do |row_array, line_number|
73
+ Row.new(header: header, line_number: line_number, row_array: row_array, model_klass: config.model,
74
74
  identifiers: config.identifiers, after_build_blocks: config.after_build_blocks)
75
75
  end
76
76
  end
@@ -7,6 +7,7 @@ module CSVImporter
7
7
  include Virtus.model
8
8
 
9
9
  attribute :header, Header
10
+ attribute :line_number, Integer
10
11
  attribute :row_array, Array[String]
11
12
  attribute :model_klass
12
13
  attribute :identifiers, Array[Symbol]
@@ -1,3 +1,3 @@
1
1
  module CSVImporter
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv-importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philippe Creux
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-06 00:00:00.000000000 Z
11
+ date: 2017-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus