tallty_import_export 1.0.24 → 1.0.25

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: f5b4baee923834e5a843ab33b902d60cb200c4706c278793f45626fb1a93182e
4
- data.tar.gz: 83feee2c88ef9d40ab6273002bb0764447ed450d9262e97bad4ba0a5781f5f7c
3
+ metadata.gz: bc0e8d3d68e999a6b3f67fa31dbec4ac510d948ddb391a38ef12e06cd8d2674c
4
+ data.tar.gz: 0c6751bba32cf9eeed209efa7aef3514cdd64d0c3db4518e717b46336b96e174
5
5
  SHA512:
6
- metadata.gz: 12c078e974198c3471a9c211a80edaeb7dfe7b1bd8e551320663bb08d9f933d74aa734cdb40c8b1a58175eebff3d98b1676f52c9da4f2c8eb160010cb462139e
7
- data.tar.gz: 2fa62a1f0d57499115c734ca854274b354e55e3ad752e0b55c339b8a71668fcff9051062839a4bedce680df721d9629fde9fb59be62904b89b8cd4e037dade56
6
+ metadata.gz: 79b629e699808fd77b57631abd8fa2cabdc43140d524f9287c0a9ea1c5d5dfdf8fe5013f9d4422d23b7487c88c2154e39f818f2f1d32171be83ab20fb5c3ba92
7
+ data.tar.gz: 3fcc361eebf3f0ec4cc1d9b10e0d6a5060c3fbb7c22a75841397cb172e24abd77d0d9e0cb2c6a02eec7be1702c6455aa3068a2d08eb184ae1d9f50e593c00574
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tallty_import_export (1.0.22)
4
+ tallty_import_export (1.0.24)
5
5
  activesupport
6
6
  caxlsx
7
7
  redis
@@ -22,7 +22,7 @@ GEM
22
22
  minitest (>= 5.1)
23
23
  tzinfo (~> 2.0)
24
24
  zeitwerk (~> 2.3)
25
- caxlsx (3.1.0)
25
+ caxlsx (3.1.1)
26
26
  htmlentities (~> 4.3, >= 4.3.4)
27
27
  marcel (~> 1.0)
28
28
  nokogiri (~> 1.10, >= 1.10.4)
@@ -32,7 +32,7 @@ GEM
32
32
  htmlentities (4.3.4)
33
33
  i18n (1.8.10)
34
34
  concurrent-ruby (~> 1.0)
35
- marcel (1.0.1)
35
+ marcel (1.0.2)
36
36
  mini_portile2 (2.6.1)
37
37
  minitest (5.14.4)
38
38
  nokogiri (1.12.4)
@@ -65,7 +65,7 @@ GEM
65
65
  rspec-support (3.10.0)
66
66
  ruby-ole (1.2.12.2)
67
67
  rubyzip (2.3.2)
68
- spreadsheet (1.2.9)
68
+ spreadsheet (1.3.0)
69
69
  ruby-ole
70
70
  tallty_duck_record (1.1.3)
71
71
  activemodel (>= 5.0)
@@ -89,7 +89,7 @@ module TalltyImportExport
89
89
  merge_column_hash = {}
90
90
  first_content_row_index = respond_to?(:first_header) ? 2 : 1
91
91
 
92
- each_method = records.is_a?(Array) ? :each : :each
92
+ each_method = @each_method || :each
93
93
  records.send(each_method).with_index do |record, index|
94
94
  row = []
95
95
  headers.each_with_index do |header, col_index|
@@ -123,8 +123,13 @@ module TalltyImportExport
123
123
  end
124
124
  end
125
125
 
126
+ # 地处整体配置信息
127
+ def export_options
128
+ {}
129
+ end
130
+
126
131
  def process_options options = {}
127
- options = options.with_indifferent_access
132
+ options = export_options.merge(options).with_indifferent_access
128
133
 
129
134
  @row_height ||= options.delete(:row_height) || 25
130
135
  @width ||= (options.delete(:width) || 20).to_f
@@ -132,6 +137,7 @@ module TalltyImportExport
132
137
  @group_by ||= options.delete(:group_by)
133
138
  @group_where = "#{@group_by}_eq" if @group_by.present?
134
139
  @headers ||= options.delete(:headers)
140
+ @each_method ||= options.delete(:each_method)
135
141
  end
136
142
 
137
143
  def with_scope records
@@ -51,7 +51,7 @@ module TalltyImportExport
51
51
  end
52
52
 
53
53
  def process_options options
54
- options = options.with_indifferent_access
54
+ options = import_options.merge(options).with_indifferent_access
55
55
  @headers = options.delete(:headers) || import_headers
56
56
  @primary_keys = options.delete(:primary_keys) || @headers.map { |header| header[:primary_key] ? header[:key].to_sym : nil }.compact
57
57
  @params = options
@@ -107,6 +107,10 @@ module TalltyImportExport
107
107
  @headers ||= import_headers&.with_indifferent_access
108
108
  end
109
109
 
110
+ def import_options
111
+ {}
112
+ end
113
+
110
114
  def import_headers **args
111
115
  @headers || klass.try(:headers) || klass.try(:model_headers) || (raise ArgumentError.new('missing import_headers'))
112
116
  end
@@ -1,3 +1,3 @@
1
1
  module TalltyImportExport
2
- VERSION = "1.0.24"
2
+ VERSION = "1.0.25"
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.24
4
+ version: 1.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - liyijie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-20 00:00:00.000000000 Z
11
+ date: 2021-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zip-zip