tallty_import_export 1.0.11 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
|
@@ -40,11 +40,13 @@ module TalltyImportExport
|
|
40
40
|
if @group_by.present?
|
41
41
|
if records.is_a?(Array)
|
42
42
|
records.group_by { |record| record.send(@group_by)}.each do |key, group_records|
|
43
|
+
next unless key.present?
|
43
44
|
@group_key = key
|
44
45
|
export_workbook workbook, group_records
|
45
46
|
end
|
46
47
|
else
|
47
48
|
records.group(@group_by).count.keys.each do |key|
|
49
|
+
next unless key.present?
|
48
50
|
@group_key = key
|
49
51
|
export_workbook workbook, records.ransack("#{@group_where}" => key).result
|
50
52
|
end
|
@@ -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
|
@@ -51,8 +52,9 @@ module TalltyImportExport
|
|
51
52
|
|
52
53
|
def process_options options
|
53
54
|
options = options.with_indifferent_access
|
54
|
-
@headers = options.delete(:headers)
|
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
|
@@ -149,8 +149,6 @@ files:
|
|
149
149
|
- lib/tallty_import_export/import.rb
|
150
150
|
- lib/tallty_import_export/importable.rb
|
151
151
|
- lib/tallty_import_export/version.rb
|
152
|
-
- tallty_import_export-1.0.3.gem
|
153
|
-
- tallty_import_export-1.0.5.gem
|
154
152
|
- tallty_import_export.gemspec
|
155
153
|
homepage: https://git.tallty.com/open-source/tallty_import_export
|
156
154
|
licenses:
|
Binary file
|
Binary file
|