tallty_import_export 1.0.5 → 1.0.10

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: 01a93e8f64b1aac7a0795ef697fe6fe27f084edc4570805e0bc8000750f3c611
4
- data.tar.gz: 7ee6334bd719ec319f25f64a07c38d88a9073926de5c379cf75483655195aa8a
3
+ metadata.gz: a04b3934c446e2bbf669f01a5e3db5f5cb898a10be14c46da3388b0d45f11ede
4
+ data.tar.gz: f4f1fa8e5cd8d58a52ecd6b82c7547181ee11078c41eeec4a22f4ada037de3c3
5
5
  SHA512:
6
- metadata.gz: b70babba1dcec1b39c0ec311f44b51bf5a41268fc301f365099b960d292e4b6812cf6917acee757c24744db671e66494ced0f2eea457c5f8e8d7e934deff0b60
7
- data.tar.gz: 6ecac3c336068b4331e9fb3525c902f38f70bd0f0a1bfd73209ced1b357a1ad076a660349cdacf51492e5be07e909df77996a2e78435afec0751cee82ad8068c
6
+ metadata.gz: cc7e2b3836f2feebbc23d4844079c57a78b470a7f103d4efd78d456ad4e6b574745668c99054375add3bbc936a62648b0340ab562a977f3b26df4856099a2a9a
7
+ data.tar.gz: 8eff47ec5ea1fa31a819c74f13073f23374819c70f7218ecaebbdfb3853fbb07a84f77943d80a0c55b7f8152afaa1cd68b94a207039b8876040ca52f5627ba73
@@ -174,6 +174,8 @@ module TalltyImportExport
174
174
  # 根据数据类型 attr_type 进行数据的格式化
175
175
  def handle_format data, header
176
176
  case header[:attr_type].to_s
177
+ when 'string'
178
+ date.to_s
177
179
  when 'datetime'
178
180
  data ? data.strftime('%F %H:%M') : nil
179
181
  when 'date'
@@ -51,10 +51,10 @@ module TalltyImportExport
51
51
 
52
52
  def process_options options
53
53
  options = options.with_indifferent_access
54
- self.headers = options.delete(:headers) || []
55
- @primary_keys = options.delete(:primary_keys) || headers.map { |header| header[:primary_key] ? header[:key].to_sym : nil }.compact
54
+ @headers = options.delete(:headers)
55
+ @primary_keys = options.delete(:primary_keys) || @headers.map { |header| header[:primary_key] ? header[:key].to_sym : nil }.compact
56
56
 
57
- @excel_hash = headers.reduce({}) do |h, header|
57
+ @excel_hash = @headers.reduce({}) do |h, header|
58
58
  h[header[:key].to_sym] = header[:name]
59
59
  h
60
60
  end
@@ -75,7 +75,7 @@ module TalltyImportExport
75
75
 
76
76
  def convert_data line_info
77
77
  line_info.with_indifferent_access.reduce({}) do |h, (k, v)|
78
- header = headers.find do |_header|
78
+ header = @headers.find do |_header|
79
79
  _header[:key].to_sym == k.to_sym
80
80
  end
81
81
  # header[:convert] = handle_xxx
@@ -104,29 +104,29 @@ module TalltyImportExport
104
104
  @headers || klass.try(:headers) || klass.try(:model_headers) || (raise ArgumentError.new('missing import_headers'))
105
105
  end
106
106
 
107
- # 只保留 key, name, json, 合并到 import_header
108
- def headers= val
109
- if val.empty?
110
- @headers = import_headers_result.map { |header| header.with_indifferent_access }
111
- return
112
- end
113
-
114
- key_to_coming_header = val.reduce({}) do |out, header|
115
- out[header.with_indifferent_access[:key].to_sym] = header.with_indifferent_access
116
- out
117
- end
118
-
119
- result = []
120
- val.map do |header|
121
- if (exist_header = import_headers_result.find { |model_header| model_header[:key] === header[:key] })
122
- result.push(exist_header.merge(name: header[:name], json: header[:json]))
123
- else
124
- result.push({ key: header[:key], name: header[:name], json: header[:json]})
125
- end
126
- end
127
-
128
- @headers = result
129
- end
107
+ # # 只保留 key, name, json, 合并到 import_header
108
+ # def headers= val
109
+ # if val.empty?
110
+ # @headers = import_headers_result.map { |header| header.with_indifferent_access }
111
+ # return
112
+ # end
113
+ #
114
+ # key_to_coming_header = val.reduce({}) do |out, header|
115
+ # out[header.with_indifferent_access[:key].to_sym] = header.with_indifferent_access
116
+ # out
117
+ # end
118
+ #
119
+ # result = []
120
+ # val.map do |header|
121
+ # if (exist_header = import_headers_result.find { |model_header| model_header[:key] === header[:key] })
122
+ # result.push(exist_header.merge(header.compact))
123
+ # else
124
+ # result.push(header)
125
+ # end
126
+ # end
127
+ #
128
+ # @headers = result
129
+ # end
130
130
 
131
131
  def skip val, processing_line_info, raw_line_info
132
132
  # do nothing there, use for header[:convert]
@@ -1,3 +1,3 @@
1
1
  module TalltyImportExport
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.10"
3
3
  end
Binary file
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.5
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - liyijie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-25 00:00:00.000000000 Z
11
+ date: 2021-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zip-zip
@@ -150,6 +150,7 @@ files:
150
150
  - lib/tallty_import_export/importable.rb
151
151
  - lib/tallty_import_export/version.rb
152
152
  - tallty_import_export-1.0.3.gem
153
+ - tallty_import_export-1.0.5.gem
153
154
  - tallty_import_export.gemspec
154
155
  homepage: https://git.tallty.com/open-source/tallty_import_export
155
156
  licenses: