spreadsheet_architect 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +2 -4
- data/lib/spreadsheet_architect.rb +21 -6
- data/lib/spreadsheet_architect/version.rb +1 -1
- data/test/spreadsheet_architect.sqlite3.db +0 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e6911d8fb0ff208566956b06e86539b556f4645
|
4
|
+
data.tar.gz: ba207bef1497f6ddc468ad48dda064f14fbc80f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b39d5bc1b8289309f89c78782b395d18131a7c582d126d5964f9c80d3b4d36265dac085a198b7bce3a19690ad8e06bb9bbabd8420360cc7c0d24435563ec0373
|
7
|
+
data.tar.gz: 8cd7b96a7471c55114c5d6e8f616e1d3cb94d16b2e1659f89feab82ce36f6eb2121d6a7b2b57e0b6a923d1e38537f3fae773d03732490a2e4417b67d2098c6a8
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
3
|
|
4
|
+
- **March.3.2016**: 1.2.2
|
5
|
+
- Make cell type numeric if value is numeric
|
6
|
+
- **March.3.2016**: 1.2.1
|
7
|
+
- Better error reporting
|
8
|
+
- Fix for Plain ruby models
|
9
|
+
- **March.3.2016**: 1.2.0
|
10
|
+
- Fix Bug: first row data repeated for all records on custom values
|
4
11
|
- **March.3.2016**: 1.1.0 - Breaking Changes
|
5
12
|
- Move spreadsheet_columns method from the class to the instance
|
6
13
|
- Fix Bug: remove default underline on cells
|
data/README.md
CHANGED
@@ -16,9 +16,6 @@ Post.order(name: :asc).where(published: true).to_ods
|
|
16
16
|
Post.order(name: :asc).where(published: true).to_csv
|
17
17
|
```
|
18
18
|
|
19
|
-
## Note: Major bug fix in 1.2.0
|
20
|
-
v.1.1.0 had a major bug in it where it would use only the first records data for non-symbol methods. Please update to 1.2.0 from 1.1.0 as soon as possible.
|
21
|
-
|
22
19
|
## Note: Breaking Changes in 1.1.0
|
23
20
|
The `spreadsheet_columns` method has been moved from the class to the instance. So now you can use string interpolation in your values. Please re-read the Model section below to see the changes. The side effect of this is if you are using the spreadsheet_columns option directly on the .to_* methods.
|
24
21
|
|
@@ -42,6 +39,7 @@ class Post < ActiveRecord::Base #activerecord not required
|
|
42
39
|
|
43
40
|
#optional for activerecord classes, defaults to the models column_names
|
44
41
|
def spreadsheet_columns
|
42
|
+
|
45
43
|
#[[Label, Method/Statement to Call on each Instance]....]
|
46
44
|
[
|
47
45
|
['Title', :title],
|
@@ -55,7 +53,7 @@ class Post < ActiveRecord::Base #activerecord not required
|
|
55
53
|
[:title, content, (author.name rescue nil), :published]
|
56
54
|
|
57
55
|
# OR a Combination of Both
|
58
|
-
[:title, :content, ['Author',(author.name rescue nil)], :published
|
56
|
+
[:title, :content, ['Author',(author.name rescue nil)], :published]
|
59
57
|
end
|
60
58
|
end
|
61
59
|
```
|
@@ -28,7 +28,18 @@ module SpreadsheetArchitect
|
|
28
28
|
if capitalize
|
29
29
|
str = str.gsub(/(\A|\ )\w/){|x| x.upcase}
|
30
30
|
end
|
31
|
-
str
|
31
|
+
return str
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.get_type(value, type=nil)
|
35
|
+
#return type.to_sym if !type.blank?
|
36
|
+
return :string if value.blank?
|
37
|
+
if value.is_a?(Numeric)
|
38
|
+
type = :float
|
39
|
+
else
|
40
|
+
type = :string
|
41
|
+
end
|
42
|
+
return type
|
32
43
|
end
|
33
44
|
|
34
45
|
def self.get_options(options={}, klass)
|
@@ -43,20 +54,26 @@ module SpreadsheetArchitect
|
|
43
54
|
end
|
44
55
|
|
45
56
|
if !has_custom_columns && defined?(ActiveRecord) && klass.ancestors.include?(ActiveRecord::Base)
|
46
|
-
|
57
|
+
ignored_columns = ["id","created_at","updated_at","deleted_at"]
|
58
|
+
the_column_names = (klass.column_names - ignored_columns)
|
47
59
|
headers = the_column_names.map{|x| str_humanize(x)}
|
48
60
|
columns = the_column_names.map{|x| x.to_sym}
|
61
|
+
types = klass.columns.keep_if{|x| !ignored_columns.include?(x.name)}.collect(&:type)
|
62
|
+
types.map!{|type| self.get_type(nil, type)}
|
49
63
|
elsif has_custom_columns
|
50
64
|
headers = []
|
51
65
|
columns = []
|
66
|
+
types = []
|
52
67
|
array = options[:spreadsheet_columns] || options[:data].first.spreadsheet_columns
|
53
68
|
array.each do |x|
|
54
69
|
if x.is_a?(Array)
|
55
70
|
headers.push x[0].to_s
|
56
71
|
columns.push x[1]
|
72
|
+
types.push self.get_type(x[1], x[2])
|
57
73
|
else
|
58
74
|
headers.push str_humanize(x.to_s)
|
59
75
|
columns.push x
|
76
|
+
types.push self.get_type(x, nil)
|
60
77
|
end
|
61
78
|
end
|
62
79
|
else
|
@@ -97,8 +114,6 @@ module SpreadsheetArchitect
|
|
97
114
|
|
98
115
|
sheet_name = options[:sheet_name] || klass.name
|
99
116
|
|
100
|
-
types = (options[:types] || []).flatten
|
101
|
-
|
102
117
|
return {headers: headers, header_style: header_style, row_style: row_style, types: types, sheet_name: sheet_name, data: data}
|
103
118
|
end
|
104
119
|
end
|
@@ -164,8 +179,8 @@ module SpreadsheetArchitect
|
|
164
179
|
end
|
165
180
|
options[:data].each do |row_data|
|
166
181
|
row do
|
167
|
-
row_data.
|
168
|
-
cell y, style: :row_style
|
182
|
+
row_data.each_with_index do |y,i|
|
183
|
+
cell y, style: :row_style, type: options[:types][i]
|
169
184
|
end
|
170
185
|
end
|
171
186
|
end
|
Binary file
|
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.2.
|
4
|
+
version: 1.2.2
|
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-03-
|
11
|
+
date: 2016-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: axlsx
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/spreadsheet_architect/version.rb
|
128
128
|
- test/database.yml
|
129
129
|
- test/helper.rb
|
130
|
+
- test/spreadsheet_architect.sqlite3.db
|
130
131
|
- test/tc_spreadsheet_architect.rb
|
131
132
|
homepage: https://github.com/westonganger/spreadsheet_architect
|
132
133
|
licenses: []
|
@@ -147,11 +148,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
148
|
version: '0'
|
148
149
|
requirements: []
|
149
150
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.5.2
|
151
152
|
signing_key:
|
152
153
|
specification_version: 4
|
153
154
|
summary: Spreadsheet Generator for ActiveRecord Models and Ruby Classes/Modules
|
154
155
|
test_files:
|
155
|
-
- test/helper.rb
|
156
156
|
- test/database.yml
|
157
|
+
- test/helper.rb
|
158
|
+
- test/spreadsheet_architect.sqlite3.db
|
157
159
|
- test/tc_spreadsheet_architect.rb
|