flextures 4.2.8 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +14 -11
- data/flextures.gemspec +1 -0
- data/lib/flextures/flextures_loader.rb +8 -14
- data/lib/flextures/version.rb +1 -1
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd48603044fc6a0a8f6ff646aece2804e0df83414adbe259febd21fb0f929776
|
4
|
+
data.tar.gz: 611df504022d691e7b2e09c0c5291e6ca843862e648d292f117879ded165aff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39e81189895c1a872b33db9c5670e61f64bd2f8f26f534b49252e5b96abaf29f08ef18c69d8979427f667084a92ad12252d1cd3781ad2f75b9b53113223a1642
|
7
|
+
data.tar.gz: adcbad6bedf954ad1ada25dcaa4a57bd1f9708c9c97eaab24852729f18e1cfb8e8db0c1c84616ae75343fae24760876dad34b888e75c2ab8fd972b502591f507
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
flextures (4.
|
4
|
+
flextures (4.3.0)
|
5
5
|
activerecord
|
6
6
|
activesupport
|
7
|
+
smarter_csv
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
|
-
activemodel (5.2.
|
12
|
-
activesupport (= 5.2.
|
13
|
-
activerecord (5.2.
|
14
|
-
activemodel (= 5.2.
|
15
|
-
activesupport (= 5.2.
|
12
|
+
activemodel (5.2.3)
|
13
|
+
activesupport (= 5.2.3)
|
14
|
+
activerecord (5.2.3)
|
15
|
+
activemodel (= 5.2.3)
|
16
|
+
activesupport (= 5.2.3)
|
16
17
|
arel (>= 9.0)
|
17
|
-
activesupport (5.2.
|
18
|
+
activesupport (5.2.3)
|
18
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
20
|
i18n (>= 0.7, < 2)
|
20
21
|
minitest (~> 5.1)
|
21
22
|
tzinfo (~> 1.1)
|
22
23
|
arel (9.0.0)
|
23
|
-
concurrent-ruby (1.
|
24
|
-
i18n (1.0
|
24
|
+
concurrent-ruby (1.1.5)
|
25
|
+
i18n (1.6.0)
|
25
26
|
concurrent-ruby (~> 1.0)
|
26
27
|
minitest (5.4.0)
|
27
28
|
minitest-bang (0.1.1)
|
@@ -35,6 +36,7 @@ GEM
|
|
35
36
|
power_assert
|
36
37
|
power_assert (0.2.2)
|
37
38
|
rake (0.9.2.2)
|
39
|
+
smarter_csv (1.2.6)
|
38
40
|
thread_safe (0.3.6)
|
39
41
|
tzinfo (1.2.5)
|
40
42
|
thread_safe (~> 0.1)
|
@@ -51,9 +53,10 @@ DEPENDENCIES
|
|
51
53
|
minitest-line (= 0.6.2)
|
52
54
|
minitest-power_assert (= 0.0.3)
|
53
55
|
rake
|
56
|
+
smarter_csv
|
54
57
|
|
55
58
|
RUBY VERSION
|
56
|
-
ruby 2.
|
59
|
+
ruby 2.6.0p-1
|
57
60
|
|
58
61
|
BUNDLED WITH
|
59
|
-
1.
|
62
|
+
1.17.2
|
data/flextures.gemspec
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'csv'
|
3
3
|
require 'erb'
|
4
|
+
require 'smarter_csv'
|
4
5
|
|
5
6
|
require 'active_record'
|
6
7
|
|
@@ -240,25 +241,18 @@ module Flextures
|
|
240
241
|
|
241
242
|
def self.load_csv(format, klass, filter, file_name)
|
242
243
|
file = self.load_file(format, file_name)
|
243
|
-
CSV.open(file) do |csv|
|
244
|
-
self.load_csv_row(csv, format, klass, filter, file_name)
|
245
|
-
end
|
246
|
-
file_name
|
247
|
-
end
|
248
|
-
|
249
|
-
def self.load_csv_row(csv, format, klass, filter, file_name)
|
250
244
|
attributes = klass.columns.map(&:name)
|
251
|
-
keys = csv.shift # active record column names
|
252
|
-
|
253
|
-
warning("CSV", attributes, keys) unless format[:silent]
|
254
|
-
|
255
245
|
ActiveRecord::Base.transaction do
|
256
|
-
csv
|
257
|
-
|
246
|
+
csv = SmarterCSV.process(file.path)
|
247
|
+
keys = csv.first.keys.map(&:to_s)
|
248
|
+
warning("CSV", attributes, keys) unless format[:silent]
|
249
|
+
csv.each do |row|
|
250
|
+
h = row.reduce({}){ |h,(k,v)| h[k.to_s]=v; h }
|
258
251
|
o = filter.call(h)
|
259
252
|
o.save(validate: false)
|
260
253
|
end
|
261
254
|
end
|
255
|
+
file_name
|
262
256
|
end
|
263
257
|
|
264
258
|
def self.load_yml(format, klass, filter, file_name)
|
@@ -377,7 +371,7 @@ module Flextures
|
|
377
371
|
translaters = column_hash.reduce({}){ |h,(k,col)| h[k] = col.translater(klass); h }
|
378
372
|
strict_filter = ->(o,h){
|
379
373
|
# if value is not 'nil', value translate suitable form
|
380
|
-
h.each{ |k,v| v.nil? || o[k] = translaters[k]&.call(v) }
|
374
|
+
h.each { |k,v| v.nil? || o[k] = translaters[k]&.call(v) }
|
381
375
|
# call FactoryFilter
|
382
376
|
factory.call(*[o, filename, ext][0, factory.arity]) if factory and !options[:unfilter]
|
383
377
|
o
|
data/lib/flextures/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flextures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- baban
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: smarter_csv
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.7.6
|
140
|
+
rubygems_version: 3.0.3
|
128
141
|
signing_key:
|
129
142
|
specification_version: 4
|
130
143
|
summary: load and dump fixtures.
|