tallty_import_export 1.0.15 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tallty_import_export/import.rb +6 -0
- data/lib/tallty_import_export/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: 5a10f7b098cd3e2d58f203bda043ac3ab1fb49f0a846c85c84aeed261ecfab16
|
4
|
+
data.tar.gz: 23bfd18fc032beae0ca7274c467cae73d28bed1c45f02037c9293a5e12945eab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a02d6d4643a5b473afab17d86c21791bea8c3c040b06bcb04bfdd7d9f8afe8d40bbed12ca3d514201e44b480c5be6a5e5aa663f4619e196863c16de74f424d0
|
7
|
+
data.tar.gz: fca02d7bf9dd5811938cc7130e7170c004aad4544157dda71793a60e00e994ec02b56cf250819bd2582c4d5d25b1b482550282097facd3514ddbae1fde2521ed
|
@@ -15,6 +15,7 @@ module TalltyImportExport
|
|
15
15
|
# convert: 导入时候,把excel的内容转换成导入时候代码逻辑需要的内容
|
16
16
|
# primary_key: 是否是主键
|
17
17
|
# json: model_payload,代表存储在某一个列中
|
18
|
+
# finder: 执行代码,可以查找到相关的对象
|
18
19
|
|
19
20
|
# xlsx_file 为 file path or file object or TalltyImportExport::Excel.new
|
20
21
|
def import_xlsx xlsx_file, associations, **options
|
@@ -53,6 +54,7 @@ module TalltyImportExport
|
|
53
54
|
options = options.with_indifferent_access
|
54
55
|
@headers = options.delete(:headers) || import_headers
|
55
56
|
@primary_keys = options.delete(:primary_keys) || @headers.map { |header| header[:primary_key] ? header[:key].to_sym : nil }.compact
|
57
|
+
@params = options
|
56
58
|
|
57
59
|
@excel_hash = @headers.reduce({}) do |h, header|
|
58
60
|
h[header[:key].to_sym] = header[:name]
|
@@ -84,6 +86,10 @@ module TalltyImportExport
|
|
84
86
|
if header[:json]
|
85
87
|
h[header[:json]] ||= {}
|
86
88
|
h[header[:json]][k] = val
|
89
|
+
elsif header[:finder]
|
90
|
+
$SAFE = 2
|
91
|
+
eval_string = header[:finder] + '(val)'
|
92
|
+
eval eval_string
|
87
93
|
else
|
88
94
|
h[k.to_sym] = val
|
89
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tallty_import_export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- liyijie
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zip-zip
|