tallty_import_export 1.0.22 → 1.0.23
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 +4 -4
- data/Gemfile.lock +32 -31
- data/lib/tallty_import_export/export.rb +13 -2
- data/lib/tallty_import_export/import.rb +2 -2
- data/lib/tallty_import_export/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f43fcc903c964ff3a19c273f812535777d8606ff24627f1e3e465431a8be327
|
|
4
|
+
data.tar.gz: a78bfa23bd82f2eb659218bff7b68c477a83bc6d6a9f9cab5e2a34a7f97009e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 (
|
|
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.
|
|
18
|
-
activesupport (= 6.
|
|
19
|
-
activesupport (6.
|
|
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 (>=
|
|
22
|
-
minitest (
|
|
23
|
-
tzinfo (~>
|
|
24
|
-
zeitwerk (~> 2.
|
|
25
|
-
caxlsx (3.0
|
|
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
|
-
|
|
27
|
+
marcel (~> 1.0)
|
|
28
28
|
nokogiri (~> 1.10, >= 1.10.4)
|
|
29
29
|
rubyzip (>= 1.3.0, < 3)
|
|
30
|
-
concurrent-ruby (1.1.
|
|
30
|
+
concurrent-ruby (1.1.9)
|
|
31
31
|
diff-lcs (1.4.4)
|
|
32
32
|
htmlentities (4.3.4)
|
|
33
|
-
i18n (1.8.
|
|
33
|
+
i18n (1.8.10)
|
|
34
34
|
concurrent-ruby (~> 1.0)
|
|
35
|
-
|
|
36
|
-
mini_portile2 (2.
|
|
37
|
-
minitest (5.14.
|
|
38
|
-
nokogiri (1.
|
|
39
|
-
mini_portile2 (~> 2.
|
|
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.
|
|
42
|
-
redis-objects (1.5.
|
|
43
|
-
redis (~> 4.
|
|
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.
|
|
66
|
-
spreadsheet (1.2.
|
|
67
|
-
ruby-ole
|
|
68
|
-
tallty_duck_record (1.
|
|
69
|
-
activemodel (
|
|
70
|
-
activesupport (
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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.
|
|
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
|
|
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
|
-
|
|
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
|
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.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-
|
|
11
|
+
date: 2021-09-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: zip-zip
|