spreadsheet_architect 1.2.6 → 1.3.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 +4 -4
- data/README.md +35 -3
- data/lib/spreadsheet_architect.rb +26 -4
- data/lib/spreadsheet_architect/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c47812616a2147f2ebeb28ed3c273832623524a1
|
4
|
+
data.tar.gz: aff49fef3145d607e3f0bf744052c75436200488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e00552e22011fa1d4b0b7b3d43a5d85a6d7d24656fd48898602c48ef93e5f0a3b2a65a1ebfb5f6c6a1caa38f6249168c78c4aa8a65a45f67a1cf583de732e019
|
7
|
+
data.tar.gz: 19e936f1628d565193dc383be1203ba641ab81b4ec5c3e144680f2a7a297a88356be8af5a299d54d4fdde0cd747ffb74b5a8ad676612cc6db389a67258dca9d3
|
data/README.md
CHANGED
@@ -131,7 +131,6 @@ File.open('path/to/file.xlsx') do |f|
|
|
131
131
|
end
|
132
132
|
```
|
133
133
|
|
134
|
-
|
135
134
|
# Method Options
|
136
135
|
|
137
136
|
### to_xlsx, to_ods, to_csv
|
@@ -151,14 +150,47 @@ end
|
|
151
150
|
### to_ods
|
152
151
|
**sheet_name** - *String*
|
153
152
|
|
154
|
-
**header_style** - *Hash* - Default: {color: "000000", align: :center, font_size: 10, bold: true} - Note: Currently only supports these options
|
153
|
+
**header_style** - *Hash* - Default: `{color: "000000", align: :center, font_size: 10, bold: true}` - Note: Currently only supports these options
|
155
154
|
|
156
|
-
**row_style** - *Hash* - Default: {color: "000000", align: :left, font_size: 10, bold: false} - Note: Currently only supports these options
|
155
|
+
**row_style** - *Hash* - Default: `{color: "000000", align: :left, font_size: 10, bold: false}` - Note: Currently only supports these options
|
157
156
|
|
158
157
|
### to_csv
|
159
158
|
Only the generic options
|
160
159
|
|
161
160
|
|
161
|
+
# Change model default method options
|
162
|
+
```ruby
|
163
|
+
class Post
|
164
|
+
include SpreadsheetArchitect
|
165
|
+
|
166
|
+
def spreadsheet_columns
|
167
|
+
[:name, :content]
|
168
|
+
end
|
169
|
+
|
170
|
+
SPREADSHEET_OPTIONS = {
|
171
|
+
headers: true,
|
172
|
+
header_style: {background_color: "AAAAAA", color: "FFFFFF", align: :center, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
|
173
|
+
row_style: {background_color: nil, color: "FFFFFF", align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
|
174
|
+
sheet_name: self.name
|
175
|
+
}
|
176
|
+
end
|
177
|
+
```
|
178
|
+
|
179
|
+
# Change project wide default method options
|
180
|
+
```ruby
|
181
|
+
# config/initializers/spreadsheet_architect.rb
|
182
|
+
|
183
|
+
SpreadsheetArchitect.module_eval do
|
184
|
+
set_const('SPREADSHEET_OPTIONS, {
|
185
|
+
headers: true,
|
186
|
+
header_style: {background_color: "AAAAAA", color: "FFFFFF", align: :center, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
|
187
|
+
row_style: {background_color: nil, color: "FFFFFF", align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
|
188
|
+
sheet_name: 'My Project Export'
|
189
|
+
})
|
190
|
+
end
|
191
|
+
```
|
192
|
+
|
193
|
+
|
162
194
|
# Credits
|
163
195
|
Created by Weston Ganger - @westonganger
|
164
196
|
|
@@ -112,9 +112,15 @@ module SpreadsheetArchitect
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
|
115
|
+
if options[:headers] == false || klass::SPREADSHEET_OPTIONS[:headers] == false
|
116
|
+
headers = false
|
117
|
+
end
|
116
118
|
|
117
|
-
|
119
|
+
if defined?(klass::SPREADSHEET_OPTIONS)
|
120
|
+
header_style = SpreadsheetArchitect::SPREADSHEET_OPTIONS[:header_style].merge(klass::SPREADSHEET_OPTIONS[:header_style] || {})
|
121
|
+
else
|
122
|
+
header_style = SpreadsheetArchitect::SPREADSHEET_OPTIONS[:header_style]
|
123
|
+
end
|
118
124
|
|
119
125
|
if options[:header_style]
|
120
126
|
header_style.merge!(options[:header_style])
|
@@ -122,12 +128,21 @@ module SpreadsheetArchitect
|
|
122
128
|
header_style = false
|
123
129
|
end
|
124
130
|
|
125
|
-
|
131
|
+
if defined?(klass::SPREADSHEET_OPTIONS)
|
132
|
+
row_style = SpreadsheetArchitect::SPREADSHEET_OPTIONS[:row_style].merge(klass::SPREADSHEET_OPTIONS[:row_style] || {})
|
133
|
+
else
|
134
|
+
row_style = SpreadsheetArchitect::SPREADSHEET_OPTIONS[:row_style]
|
135
|
+
end
|
136
|
+
|
126
137
|
if options[:row_style]
|
127
138
|
row_style.merge!(options[:row_style])
|
128
139
|
end
|
129
140
|
|
130
|
-
|
141
|
+
if defined?(klass::SPREADSHEET_OPTIONS)
|
142
|
+
sheet_name = options[:sheet_name] || klass::SPREADSHEET_OPTIONS[:sheet_name] || SpreadsheetArchitect::SPREADSHEET_OPTIONS[:sheet_name] || klass.name
|
143
|
+
else
|
144
|
+
sheet_name = options[:sheet_name] || SpreadsheetArchitect::SPREADSHEET_OPTIONS[:sheet_name] || klass.name
|
145
|
+
end
|
131
146
|
|
132
147
|
return {headers: headers, header_style: header_style, row_style: row_style, types: types, sheet_name: sheet_name, data: data}
|
133
148
|
end
|
@@ -254,4 +269,11 @@ module SpreadsheetArchitect
|
|
254
269
|
return package.to_stream.read
|
255
270
|
end
|
256
271
|
end
|
272
|
+
|
273
|
+
SPREADSHEET_OPTIONS = {
|
274
|
+
headers: true,
|
275
|
+
#sheet_name: self.name,
|
276
|
+
header_style: {background_color: "AAAAAA", color: "FFFFFF", align: :center, bold: false, font_name: 'Arial', font_size: 10, italic: false, underline: false},
|
277
|
+
row_style: {background_color: nil, color: "000000", align: :left, bold: false, font_name: 'Arial', font_size: 10, italic: false, underline: false}
|
278
|
+
}
|
257
279
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spreadsheet_architect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Weston Ganger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: axlsx
|