planter 0.0.10 → 0.0.11

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: 259e8d195e480b9b5f16d67ee729d822f9c67131650997d2c95958f1356d76ab
4
- data.tar.gz: f2722663f8f1628268208dd0e35da17507a62b339e0dc45004ba16c59f0879b5
3
+ metadata.gz: 9eab293e0cec74131351f8e1ff29919165da5e7eeb9cea2d305802f8cf5e1c8f
4
+ data.tar.gz: 6e06237482fb476e3a664fead3bfd64d15013f5570316964360161c9e05a25a4
5
5
  SHA512:
6
- metadata.gz: 3598c5503a8fef0db359b9ba6bcbd29e22ca3566e6f9ec0ebf0daa9a23961a227cad94478178b700d7b696b638fed51ea9bb61c5a71fb7a1874eb0765c6334ec
7
- data.tar.gz: 92d6beec3c0c16fb9dd03d3b26fe6aadf94e28298f058795508c18863e6e41c0f3034c254eb995804d59f211c14bbdc1565848260026b0cf4c2e87f9bd1f7f6e
6
+ metadata.gz: 3d28919333f86c7e0d6be6e4a12a4dea558ec0d734ccb63457931af6c8070f71ff76a90c370d2e26a8500106dbb81585ca9685b829c2cf220cd770be229e274d
7
+ data.tar.gz: a40e5e9ae771224e486c8263d2194fc5de1256b6d6a0d9d880ef44aea01294160fbbe1f139b74a375f4adb3e6372e155700968de0d862918ad0662ce3a2fc80c
@@ -138,7 +138,6 @@ module Planter
138
138
  parent_model: nil,
139
139
  association: nil,
140
140
  csv_name: nil,
141
- erb_trim_mode: nil,
142
141
  unique_columns: nil
143
142
  )
144
143
  if !SEEDING_METHODS.include?(method.intern)
@@ -153,7 +152,6 @@ module Planter
153
152
  @parent_model = parent_model
154
153
  @association = @parent_model && (association || determine_association)
155
154
  @csv_file = determine_csv_filename(csv_name) if @seeding_method == :csv
156
- @erb_trim_mode = erb_trim_mode
157
155
  @unique_columns =
158
156
  case unique_columns
159
157
  when String, Symbol then [unique_columns.intern]
@@ -262,14 +260,6 @@ module Planter
262
260
  @unique_columns ||= self.class.instance_variable_get('@unique_columns')
263
261
  end
264
262
 
265
- ##
266
- # Trim mode for ERB when parsing CSVs.
267
- #
268
- # @return [String, nil]
269
- def erb_trim_mode
270
- @erb_trim_mode ||= self.class.instance_variable_get('@erb_trim_mode')
271
- end
272
-
273
263
  ##
274
264
  # Creates records from the +data+ attribute.
275
265
  def create_records
@@ -319,7 +309,7 @@ module Planter
319
309
  when :csv
320
310
  contents = ::File.read(csv_file)
321
311
  if csv_file.end_with?('.erb')
322
- contents = ERB.new(contents, trim_mode: erb_trim_mode).result(binding)
312
+ contents = ERB.new(contents, trim_mode: '<>').result(binding)
323
313
  end
324
314
 
325
315
  @data ||= ::CSV.parse(
@@ -333,13 +323,8 @@ module Planter
333
323
  end
334
324
 
335
325
  def split_record(rec) # :nodoc:
336
- u = {}
337
- model.constantize.reflect_on_all_associations.map(&:name).each do |a|
338
- u[a] = rec.delete(a) if rec.key?(a)
339
- end
340
- return [u, rec] unless unique_columns
341
-
342
- unique_columns.each { |c, h| h[c] = rec.delete(c) }
326
+ return [rec, {}] unless unique_columns
327
+ u = unique_columns.each_with_object({}) { |c, h| h[c] = rec.delete(c) }
343
328
  [u, rec]
344
329
  end
345
330
  end
@@ -21,7 +21,7 @@ module Planter
21
21
  # Patch version.
22
22
  #
23
23
  # @return [Integer]
24
- PATCH = 10
24
+ PATCH = 11
25
25
 
26
26
  ##
27
27
  # Version as +[MAJOR, MINOR, PATCH]+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: planter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Gray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-27 00:00:00.000000000 Z
11
+ date: 2021-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails