tallty_import_export 1.0.22 → 1.0.23

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: e281a3f593eedd9a07fe79f779c95a389d02cc5f5296e799bf7c29d42f31b126
4
- data.tar.gz: 6a7b95014024711b1eeb6136f3eafc55f51f54dcfb10f750dbf34fb73dc74c34
3
+ metadata.gz: 7f43fcc903c964ff3a19c273f812535777d8606ff24627f1e3e465431a8be327
4
+ data.tar.gz: a78bfa23bd82f2eb659218bff7b68c477a83bc6d6a9f9cab5e2a34a7f97009e9
5
5
  SHA512:
6
- metadata.gz: a1f2f542f68b84527e1321bf143525765568470a767bacdf3a9e8d43f14efa435e3b98e53a551b9ad14442fbd38c1175ff04c0c6d930e27aa08eb5e99e0bc122
7
- data.tar.gz: 5fa2f4f7286b75fb5e9d14450c1233bdf95bbdb10433d1dbe66f5cf7effbe4eccb07c7414d74ac30f54642415679a4308f05bcbe7f82161713985bb8d346a5fa
6
+ metadata.gz: 868e1e722f37534dda11149447ec31215004d5150083edea5c577b2f73679983b1c202f10b4f87e81db22f835fb49a980ee56112db074421b8f1a1a289a31214
7
+ data.tar.gz: 18e14d3e9c139aef84df4b9b1d988f49a64114220ba6aee4b9e5028a0e042fd328247fd82bdc7c2125f338b55f05f1db817572f91035e9759354c14d490a64f6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tallty_import_export (0.1.0)
4
+ tallty_import_export (1.0.22)
5
5
  activesupport
6
6
  caxlsx
7
7
  redis
@@ -14,33 +14,35 @@ PATH
14
14
  GEM
15
15
  remote: https://gems.ruby-china.com/
16
16
  specs:
17
- activemodel (6.0.3.4)
18
- activesupport (= 6.0.3.4)
19
- activesupport (6.0.3.4)
17
+ activemodel (6.1.4.1)
18
+ activesupport (= 6.1.4.1)
19
+ activesupport (6.1.4.1)
20
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
- i18n (>= 0.7, < 2)
22
- minitest (~> 5.1)
23
- tzinfo (~> 1.1)
24
- zeitwerk (~> 2.2, >= 2.2.2)
25
- caxlsx (3.0.2)
21
+ i18n (>= 1.6, < 2)
22
+ minitest (>= 5.1)
23
+ tzinfo (~> 2.0)
24
+ zeitwerk (~> 2.3)
25
+ caxlsx (3.1.0)
26
26
  htmlentities (~> 4.3, >= 4.3.4)
27
- mimemagic (~> 0.3)
27
+ marcel (~> 1.0)
28
28
  nokogiri (~> 1.10, >= 1.10.4)
29
29
  rubyzip (>= 1.3.0, < 3)
30
- concurrent-ruby (1.1.7)
30
+ concurrent-ruby (1.1.9)
31
31
  diff-lcs (1.4.4)
32
32
  htmlentities (4.3.4)
33
- i18n (1.8.5)
33
+ i18n (1.8.10)
34
34
  concurrent-ruby (~> 1.0)
35
- mimemagic (0.3.5)
36
- mini_portile2 (2.4.0)
37
- minitest (5.14.2)
38
- nokogiri (1.10.10)
39
- mini_portile2 (~> 2.4.0)
35
+ marcel (1.0.1)
36
+ mini_portile2 (2.6.1)
37
+ minitest (5.14.4)
38
+ nokogiri (1.12.4)
39
+ mini_portile2 (~> 2.6.1)
40
+ racc (~> 1.4)
41
+ racc (1.5.2)
40
42
  rake (12.3.3)
41
- redis (4.2.5)
42
- redis-objects (1.5.0)
43
- redis (~> 4.0)
43
+ redis (4.4.0)
44
+ redis-objects (1.5.1)
45
+ redis (~> 4.2)
44
46
  roo (2.8.3)
45
47
  nokogiri (~> 1)
46
48
  rubyzip (>= 1.3.0, < 3.0.0)
@@ -62,18 +64,17 @@ GEM
62
64
  rspec-support (~> 3.10.0)
63
65
  rspec-support (3.10.0)
64
66
  ruby-ole (1.2.12.2)
65
- rubyzip (2.3.0)
66
- spreadsheet (1.2.6)
67
- ruby-ole (>= 1.0)
68
- tallty_duck_record (1.0.2)
69
- activemodel (~> 6.0.3)
70
- activesupport (~> 6.0.3)
67
+ rubyzip (2.3.2)
68
+ spreadsheet (1.2.9)
69
+ ruby-ole
70
+ tallty_duck_record (1.1.3)
71
+ activemodel (>= 5.0)
72
+ activesupport (>= 5.0)
71
73
  tallty_form (1.0.0)
72
74
  tallty_duck_record
73
- thread_safe (0.3.6)
74
- tzinfo (1.2.8)
75
- thread_safe (~> 0.1)
76
- zeitwerk (2.4.1)
75
+ tzinfo (2.0.4)
76
+ concurrent-ruby (~> 1.0)
77
+ zeitwerk (2.4.2)
77
78
  zip-zip (0.3)
78
79
  rubyzip (>= 1.0.0)
79
80
 
@@ -86,4 +87,4 @@ DEPENDENCIES
86
87
  tallty_import_export!
87
88
 
88
89
  BUNDLED WITH
89
- 2.1.4
90
+ 2.2.15
@@ -27,6 +27,7 @@ module TalltyImportExport
27
27
  # index: 数组方式,需要嵌套拿到里面的
28
28
  # merge: true/false,默认false,某一列,如果上下行的内容相同,则直接合并单元格
29
29
  # json: model_payload,代表存储在某一个列中
30
+ # select: [{ label: '已报备', value: 'submitted'}, ...],需要转换的枚举类型
30
31
 
31
32
  def export_xlsx records, **options
32
33
  records = with_scope records
@@ -138,7 +139,7 @@ module TalltyImportExport
138
139
  end
139
140
 
140
141
  def export_headers_result
141
- @headers || export_headers
142
+ @headers ||= export_headers&.with_indifferent_access
142
143
  end
143
144
 
144
145
  def export_headers **args
@@ -159,7 +160,8 @@ module TalltyImportExport
159
160
  else
160
161
  try_method(record, header[:key])
161
162
  end
162
- handle_format(data, header)
163
+ data = handle_format(data, header)
164
+ data = handle_select(data, header)
163
165
  rescue
164
166
  ''
165
167
  end
@@ -186,5 +188,14 @@ module TalltyImportExport
186
188
  data
187
189
  end
188
190
  end
191
+
192
+ def handle_select data, header
193
+ if header[:select].present?
194
+ select_option = header[:select].find { |option| option[:value].to_s == data.to_s }
195
+ select_option.present? ? select_option[:label] : data
196
+ else
197
+ data
198
+ end
199
+ end
189
200
  end
190
201
  end
@@ -89,7 +89,7 @@ module TalltyImportExport
89
89
  h[header[:json]] ||= {}
90
90
  h[header[:json]][k] = val
91
91
  elsif header[:finder]
92
- $SAFE = 2
92
+ # $SAFE = 2
93
93
  h[k.to_sym] = eval header[:finder]
94
94
  else
95
95
  h[k.to_sym] = val
@@ -104,7 +104,7 @@ module TalltyImportExport
104
104
  end
105
105
 
106
106
  def import_headers_result
107
- @headers ||= import_headers
107
+ @headers ||= import_headers&.with_indifferent_access
108
108
  end
109
109
 
110
110
  def import_headers **args
@@ -1,3 +1,3 @@
1
1
  module TalltyImportExport
2
- VERSION = "1.0.22"
2
+ VERSION = "1.0.23"
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.22
4
+ version: 1.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - liyijie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-28 00:00:00.000000000 Z
11
+ date: 2021-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zip-zip