csv-importer 0.3.1 → 0.3.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: 9fb2af22af454df8a5d98c1d4fb2b8045c75c39b
4
- data.tar.gz: 0ea722d76a33fc31fe3cea489d95e480b63b188c
3
+ metadata.gz: 6633b4c3453d25cf7071a1f9cf68f80f82c946cd
4
+ data.tar.gz: 252b40c27f5e1569af2dac05c5f0bbafa1170777
5
5
  SHA512:
6
- metadata.gz: 7afd22eabb1c1d6e9aa04aac774f0063e8682e5a58a1c5d3fe339084f47fa8f432c82f80e4f78b5cb37bedc6d82ae4f6d9ddac8c044209510c40053182d45d37
7
- data.tar.gz: d52f0d10d2b8916e2f049c69301539fc42e09ef3610955cb1eed8ebf8e398080eab4a7b654d6cf0a19dd51447ea23dc2268ec01c2b209adcc16a0f580b8d55a5
6
+ metadata.gz: 95ce42e97b4deee80fcb36d0ae9db97f1ba292a3a62cccb9a593c9682a6dffb11e202c3aed0f55c2e55ddd2496a89b9087f5c88af516f2e97faa0cc3e50780a0
7
+ data.tar.gz: 6da83969a1673e7f96c3356dc86d5462124a5c90e1081005d1a0e6795c0bcf8d3e12afa981d48b8ba4db5b3ce3ecf3e1880cbcd68563ea1ccb7b3af6fabc4118
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.3.2] - 2017-01-06
6
+
7
+ ### Fixed
8
+
9
+ * `after_build` block is only called once ([#47][] by [@fxgallego][] and [#52][]
10
+ [@pnomolos][])
11
+ * `after_build` and `after_save` blocks don't leak between runtime
12
+ definitions ([#47][] by [@fxgallego][] and [#52][] [@pnomolos][])
13
+
5
14
  ## [0.3.1] - 2016-05-09
6
15
 
7
16
  ### Added
@@ -105,5 +114,9 @@ report object instead of raising an exception.
105
114
  <!--- The following link definition list is generated by PimpMyChangelog --->
106
115
  [#26]: https://github.com/BrewhouseTeam/csv-importer/issues/26
107
116
  [#38]: https://github.com/BrewhouseTeam/csv-importer/issues/38
117
+ [#47]: https://github.com/BrewhouseTeam/csv-importer/issues/47
118
+ [#52]: https://github.com/BrewhouseTeam/csv-importer/issues/52
108
119
  [@egg-chicken]: https://github.com/egg-chicken
109
- [@shvetsovdm]: https://github.com/shvetsovdm
120
+ [@pnomolos]: https://github.com/pnomolos
121
+ [@fxgallego]: https://github.com/fxgallego
122
+ [@shvetsovdm]: https://github.com/shvetsovdm
data/README.md CHANGED
@@ -228,7 +228,7 @@ You can also define a composite identifier:
228
228
 
229
229
  By default, we skip invalid records and report errors back to the user.
230
230
  There are times where you want your import to be an all or nothing. The
231
- `on_error` option is here for you.
231
+ `when_invalid` option is here for you.
232
232
 
233
233
  ```ruby
234
234
  class ImportUserCSV
@@ -238,7 +238,7 @@ class ImportUserCSV
238
238
 
239
239
  column :email, to: ->(email) { email.downcase }
240
240
 
241
- on_error :abort
241
+ when_invalid :abort
242
242
  end
243
243
 
244
244
  import = ImportUserCSV.new(content: "email\nbob@example.com\nINVALID_EMAIL")
@@ -332,7 +332,7 @@ end
332
332
  ### Validate the header
333
333
 
334
334
  On a web application, as soon as a CSV file is uploaded, you can check
335
- if it has the required columns. This is handy to fail early an provide
335
+ if it has the required columns. This is handy to fail early and provide
336
336
  the user with a meaningful error message right away.
337
337
 
338
338
  ```ruby
@@ -10,6 +10,14 @@ module CSVImporter
10
10
  attribute :after_build_blocks, Array[Proc], default: []
11
11
  attribute :after_save_blocks, Array[Proc], default: []
12
12
 
13
+ def initialize_copy(orig)
14
+ super
15
+ self.column_definitions = orig.column_definitions.dup
16
+ self.identifiers = orig.identifiers.dup
17
+ self.after_save_blocks = orig.after_save_blocks.dup
18
+ self.after_build_blocks = orig.after_build_blocks.dup
19
+ end
20
+
13
21
  def after_build(block)
14
22
  self.after_build_blocks << block
15
23
  end
@@ -19,6 +19,9 @@ module CSVImporter
19
19
  model = find_or_build_model
20
20
 
21
21
  set_attributes(model)
22
+
23
+ after_build_blocks.each { |block| instance_exec(model, &block) }
24
+ model
22
25
  end
23
26
  end
24
27
 
@@ -43,8 +46,6 @@ module CSVImporter
43
46
  set_attribute(model, column_definition, value)
44
47
  end
45
48
 
46
- after_build_blocks.each { |block| instance_exec(model, &block) }
47
-
48
49
  model
49
50
  end
50
51
 
@@ -1,3 +1,3 @@
1
1
  module CSVImporter
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philippe Creux
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2017-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus