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 +4 -4
- data/lib/planter/seeder.rb +3 -18
- data/lib/planter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9eab293e0cec74131351f8e1ff29919165da5e7eeb9cea2d305802f8cf5e1c8f
|
4
|
+
data.tar.gz: 6e06237482fb476e3a664fead3bfd64d15013f5570316964360161c9e05a25a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d28919333f86c7e0d6be6e4a12a4dea558ec0d734ccb63457931af6c8070f71ff76a90c370d2e26a8500106dbb81585ca9685b829c2cf220cd770be229e274d
|
7
|
+
data.tar.gz: a40e5e9ae771224e486c8263d2194fc5de1256b6d6a0d9d880ef44aea01294160fbbe1f139b74a375f4adb3e6372e155700968de0d862918ad0662ce3a2fc80c
|
data/lib/planter/seeder.rb
CHANGED
@@ -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:
|
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
|
-
|
337
|
-
|
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
|
data/lib/planter/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|