tallty_import_export 1.0.11 → 1.0.16

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: ac670fce1d35526ff3182599152b1731126e8252b34a23ccfebb21e2fd0bdb05
4
- data.tar.gz: c9be74623d6e5530ffeb0908de53f44ed81765d54704ce8e051de099ce4fcfa4
3
+ metadata.gz: 5a10f7b098cd3e2d58f203bda043ac3ab1fb49f0a846c85c84aeed261ecfab16
4
+ data.tar.gz: 23bfd18fc032beae0ca7274c467cae73d28bed1c45f02037c9293a5e12945eab
5
5
  SHA512:
6
- metadata.gz: c4d825be60c8e01fb6f7390d62eafaa530d430ee9ec1f24e6a811e7664c7a565ff3ec28089cebd5ee56bfb889428b524bf71dc515704b5ee429180ed48f90ec4
7
- data.tar.gz: e2bfd76beb5a504f35f041be64e5903aaedb31597c646c113e25024c0f8fd138c3d34d7a778a8707f432520394cd5584a68d891a7de63da4fea15a13f50d85c6
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
@@ -1,3 +1,3 @@
1
1
  module TalltyImportExport
2
- VERSION = "1.0.11"
2
+ VERSION = "1.0.16"
3
3
  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.11
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-07 00:00:00.000000000 Z
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