export_to 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcdb1f8a1a6dec33c36024fc0f577b1a492d7fe7e1bd7a8cf3d639be76814bde
4
- data.tar.gz: 8b844513054aba11c5384dfc30a46ba9ae9abded9ed62001c9fb4af9d0e9a0d1
3
+ metadata.gz: 6e6900888a5e2ff9dc099b3f6327a4ce1b07869c80991afc86c48be902baa554
4
+ data.tar.gz: f5dc1916c65e52376fcce1de96699628262b340cfacb97c32576b0c5d9b5afeb
5
5
  SHA512:
6
- metadata.gz: 58e3294ec055895590fe1766d0b0ab54b0c5176942481400ec9d142b25dc2680171888e0a8f9d8338d264bc75870f08ab8d564b198b0ee95d2bac26edacbc66c
7
- data.tar.gz: e7dd88214c37584d37c164dc1be3ec418adaa7e51bf5fce99b8f60ad648646378584f95d79d9bb7347df8fd8370f8d51b92fc006a9f6a25829ce6319005ebd8d
6
+ metadata.gz: 100069ed5dc91b24173488fb30a2d7c821673184ddd9dfc68290756f7e752e0a5bb35611e1037e236d1e8040746ed20963a0db3840d26303d66f4ea8a6e3477c
7
+ data.tar.gz: a69f77a907acaec0f701ad692b10072b1060d1502aae48e15b5e9fc0c547947db97ca0a3b83ea2fd3ecccedc6692278aea6259a6c38cedc61b82faf6e6881c62
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- export_to (0.1.2)
4
+ export_to (1.0.0)
5
5
  activesupport (>= 6, < 7)
6
6
  fast_excel
7
7
  iconv
@@ -3,7 +3,7 @@ module ExportTo
3
3
  class_attribute :options
4
4
  class_attribute :head_titles
5
5
  class_attribute :body_keys
6
- class_attribute :column_formats
6
+ class_attribute :column_options
7
7
  class_attribute :body_column_proc
8
8
 
9
9
  class_attribute :presenter_klass
@@ -99,15 +99,15 @@ module ExportTo
99
99
  self.options = options
100
100
  end
101
101
 
102
- def set(title, key, format: {}, &block)
102
+ def set(title, key, options={}, &block)
103
103
  self.head_titles ||= []
104
104
  self.body_keys ||= []
105
- self.column_formats ||= []
105
+ self.column_options ||= []
106
106
  self.body_column_proc ||= []
107
107
 
108
108
  self.head_titles.push(title)
109
109
  self.body_keys.push(key)
110
- self.column_formats.push(format)
110
+ self.column_options.push(options)
111
111
  self.body_column_proc.push(block)
112
112
  end
113
113
 
@@ -4,7 +4,7 @@ module ExportTo
4
4
 
5
5
  def export
6
6
  rows.each! do |columns, model, x|
7
- worksheet.set_row(x, height, nil)
7
+ worksheet.set_row(x, height, nil) if x > 0
8
8
  worksheet.write_row(x, columns)
9
9
  end
10
10
 
@@ -20,20 +20,20 @@ module ExportTo
20
20
  def worksheet
21
21
  @worksheet ||= begin
22
22
  ws = workbook.add_worksheet(options.fetch(:worksheet) { "Default" })
23
- # 設定表頭樣式
24
- ws.set_row(0, height, head_format)
25
23
 
26
24
  # 表身樣式
27
- column_formats.each_with_index do |format, i|
28
- next if format.blank?
29
-
30
- width = format.delete(:width) { FastExcel::DEF_COL_WIDTH }
25
+ column_options.each_with_index do |column_options, i|
26
+ next if column_options.blank?
31
27
 
32
- puts "#{i} -> #{width} -> #{format}"
28
+ width = column_options.fetch(:width) { FastExcel::DEF_COL_WIDTH }
29
+ format = column_options.fetch(:format) { {} }
33
30
 
34
31
  ws.set_column(i, i, width, workbook.add_format(format))
35
32
  end
36
33
 
34
+ # 設定表頭樣式
35
+ ws.set_row(0, height, head_format)
36
+
37
37
  ws
38
38
  end
39
39
  end
@@ -54,8 +54,8 @@ module ExportTo
54
54
  options.fetch(:height) { 20 }
55
55
  end
56
56
 
57
- def column_formats
58
- @column_formats ||= rows.class.column_formats.dup || []
57
+ def column_options
58
+ @column_options ||= rows.class.column_options
59
59
  end
60
60
  end
61
61
  end
@@ -1,3 +1,3 @@
1
1
  module ExportTo
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: export_to
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - eddie