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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06f862bf1ae912a77b1e7a02d76fade118619343de44cbcff2b5f165756ea323
4
- data.tar.gz: db83a7345b10d91e5018604ed08c24287e085930c96b7af66499d6333464f063
3
+ metadata.gz: 5a10f7b098cd3e2d58f203bda043ac3ab1fb49f0a846c85c84aeed261ecfab16
4
+ data.tar.gz: 23bfd18fc032beae0ca7274c467cae73d28bed1c45f02037c9293a5e12945eab
5
5
  SHA512:
6
- metadata.gz: ba25061c42d32c4396cbb88b9aae8ef7296b58a306c47037dd5c53cea9bde0d8df29f7ed373463d7f74596f78e73fecf3005aa02a2b449ab9d60f0313631bc63
7
- data.tar.gz: 240105d66e1c3a009fb8f03b70a19cbb0307c3bbe2e611958e7cd019d332404bae5c75b681488595988996f2bc616aa4e445cc73f6bda6389b4ed55eb81e95ee
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
@@ -1,3 +1,3 @@
1
1
  module TalltyImportExport
2
- VERSION = "1.0.15"
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.15
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-17 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