Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tallty_import_export
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
tallty_import_export
Commits
06908e25
Commit
06908e25
authored
Jul 04, 2023
by
Ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: import and export add format file process
parent
d08d72c1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
22 deletions
+57
-22
Gemfile.lock
Gemfile.lock
+22
-22
export.rb
lib/tallty_import_export/export.rb
+11
-0
import.rb
lib/tallty_import_export/import.rb
+24
-0
No files found.
Gemfile.lock
View file @
06908e25
PATH
remote: .
specs:
tallty_import_export (1.1.
1
)
tallty_import_export (1.1.
6
)
activesupport
attr_json
caxlsx
...
...
@@ -15,44 +15,44 @@ PATH
GEM
remote: https://gems.ruby-china.com/
specs:
activemodel (7.0.
2.4
)
activesupport (= 7.0.
2.4
)
activerecord (7.0.
2.4
)
activemodel (= 7.0.
2.4
)
activesupport (= 7.0.
2.4
)
activesupport (7.0.
2.4
)
activemodel (7.0.
6
)
activesupport (= 7.0.
6
)
activerecord (7.0.
6
)
activemodel (= 7.0.
6
)
activesupport (= 7.0.
6
)
activesupport (7.0.
6
)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
attr_json (
1.4.0
)
activerecord (>=
5
.0.0, < 7.1)
caxlsx (3.
3.0
)
attr_json (
2.0.1
)
activerecord (>=
6
.0.0, < 7.1)
caxlsx (3.
4.1
)
htmlentities (~> 4.3, >= 4.3.4)
marcel (~> 1.0)
nokogiri (~> 1.10, >= 1.10.4)
rubyzip (>= 1.3.0, < 3)
concurrent-ruby (1.
1.10
)
connection_pool (2.
3.0
)
concurrent-ruby (1.
2.2
)
connection_pool (2.
4.1
)
diff-lcs (1.4.4)
htmlentities (4.3.4)
i18n (1.1
2.0
)
i18n (1.1
4.1
)
concurrent-ruby (~> 1.0)
marcel (1.0.2)
mini_portile2 (2.8.
0
)
minitest (5.1
6.3
)
nokogiri (1.1
3.9
)
mini_portile2 (~> 2.8.
0
)
mini_portile2 (2.8.
2
)
minitest (5.1
8.1
)
nokogiri (1.1
5.2
)
mini_portile2 (~> 2.8.
2
)
racc (~> 1.4)
racc (1.
6.0
)
racc (1.
7.1
)
rake (12.3.3)
redis (5.0.
5
)
redis (5.0.
6
)
redis-client (>= 0.9.0)
redis-client (0.1
0.0
)
redis-client (0.1
4.1
)
connection_pool
redis-objects (1.7.0)
redis
roo (2.
9
.0)
roo (2.
10
.0)
nokogiri (~> 1)
rubyzip (>= 1.3.0, < 3.0.0)
roo-xls (1.2.0)
...
...
@@ -81,7 +81,7 @@ GEM
activesupport (>= 5.0)
tallty_form (1.0.0)
tallty_duck_record
tzinfo (2.0.
5
)
tzinfo (2.0.
6
)
concurrent-ruby (~> 1.0)
zip-zip (0.3)
rubyzip (>= 1.0.0)
...
...
lib/tallty_import_export/export.rb
View file @
06908e25
...
...
@@ -278,6 +278,17 @@ module TalltyImportExport
data
?
data
.
in_time_zone
.
strftime
(
'%F %H:%M'
)
:
nil
when
'date'
data
?
data
.
in_time_zone
.
strftime
(
'%F'
)
:
nil
when
'file'
if
data
.
is_a?
(
Array
)
&&
!
opts
[
:keep_array
]
data
.
map
do
|
item
|
url
=
item
.
dig
(
'url'
)
url
.
present?
?
"
#{
url
}
?fileName=
#{
URI
.
encode_www_form_component
(
item
.
dig
(
'fileName'
))
}
&fileSize=
#{
URI
.
encode_www_form_component
(
item
.
dig
(
'fileSize'
))
}
&fileType=
#{
URI
.
encode_www_form_component
(
item
.
dig
(
'fileType'
))
}
"
:
nil
end
.
compact
.
join
(
"
\n
"
)
else
data
end
else
data
end
...
...
lib/tallty_import_export/import.rb
View file @
06908e25
...
...
@@ -145,6 +145,9 @@ module TalltyImportExport
# handle_xxx(val, processing_line_info, raw_line_info)
val
=
header
[
:convert
]
?
send
(
header
[:
convert
],
v
,
h
,
info
)
:
v
val
.
strip!
if
val
.
is_a?
(
String
)
val
=
handle_format
(
val
,
header
,
line_info
)
if
header
[
:json
]
h
[
header
[
:json
]]
||=
{}
h
[
header
[
:json
]][
k
]
=
val
...
...
@@ -165,6 +168,27 @@ module TalltyImportExport
end
.
with_indifferent_access
end
def
handle_format
val
,
header
,
line_info
case
header
[
:format
].
to_s
when
'file'
if
val
.
is_a?
(
String
)
val
=
val
.
split
(
"
\n
"
).
map
do
|
url
|
params
=
url
.
include?
(
'?'
)
?
CGI
::
parse
(
url
.
split
(
'?'
).
last
)
:
{}
{
url:
url
,
fileName:
params
[
'fileName'
]
&
.
first
,
fileType:
params
[
'fileType'
]
&
.
first
,
fileSize:
params
[
'fileSize'
]
&
.
first
&
.
to_i
,
}
end
else
val
end
else
val
end
end
# 通过转换后,数据是否合法,如果不合法,则直接跳过不处理这个数据
def
valid?
(
line_info
)
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment