tallty_import_export 1.0.12 → 1.0.17

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: 63f572a45e25db9ed6c9750619aa2d07be0c63898d754ddd419fc3b9f54a479a
4
- data.tar.gz: 71e22aec7b4d6e444e87c35d2844779bdb3bf44afe4eb760c140c7a7c52ef832
3
+ metadata.gz: 2136c7b712f1edf45c672eaa6b488263ea0df3be0aa96f8f004afd15899a0872
4
+ data.tar.gz: 42c9ec7fce94b70c6a63bfaec4934dbf622d2e09fdace4309c3b37a276eb9f92
5
5
  SHA512:
6
- metadata.gz: 4b8180e95abd821119324ca582c8748f8cf89f089e7098e64ede6040bf1c1eafc8c408d00f8a17c76286cf7ea4b079ddc93d98c3ae9f05c77147e71a315eac1e
7
- data.tar.gz: 818c4b2d0b3a96cc47bf5f8b79422029d0e03e3df607e6d5d598cf194458ffcd0c19842dda59738495cc94efa3f3e2cde7472e2eae9ce89336024de52756d9fd
6
+ metadata.gz: 18a517b979b812ca2d3ecbcacff2d0014e2471c34fbc39f97779db59574e56cf0a5543007d35cd59175786f5c264920482b7f1bcea6e15338da297a2bfc77c63
7
+ data.tar.gz: c5e8e51074abe0729d18187678110fd641efffa835d1cbcb030ddb60d3c78186a5a1e9258cd5549507ae584b8f021f16dde65ebeea22823119df684e2fb557ba
@@ -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
@@ -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,11 @@ 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_val = eval eval_string
93
+ h[k.to_sym] = eval_val
87
94
  else
88
95
  h[k.to_sym] = val
89
96
  end
@@ -1,3 +1,3 @@
1
1
  module TalltyImportExport
2
- VERSION = "1.0.12"
2
+ VERSION = "1.0.17"
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.12
4
+ version: 1.0.17
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-14 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