spreadsheet_architect 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/spreadsheet_architect.rb +22 -6
- 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: 27a117a492113cfe43d238d3eb202961fe951a94
|
4
|
+
data.tar.gz: 3fb49d5a3970d4321e02e56489ffac22b920c14c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6885c1ad45d21e5f1e615ff21717328252a9a1b52981d4a4b70512a20b258c2a74786f9039ff7e2124373186bc15c51d8377ee10e6b87f7f12ad89e29dce4e4d
|
7
|
+
data.tar.gz: 07a7b5642b11746a1aa4602375a90dd962f2321df741ba84c4ea1ba292494786e5345aa8e092ab58411ae8afca630eb89d906484b1990615d21772bff495f6b6
|
data/README.md
CHANGED
@@ -40,12 +40,15 @@ class Post < ActiveRecord::Base #activerecord not required
|
|
40
40
|
#optional for activerecord classes, defaults to the models column_names
|
41
41
|
def spreadsheet_columns
|
42
42
|
|
43
|
-
#[[Label, Method/Statement to Call on each Instance]....]
|
43
|
+
#[[Label, Method/Statement to Call on each Instance, Cell Type(optional)]....]
|
44
44
|
[
|
45
45
|
['Title', :title],
|
46
46
|
['Content', content],
|
47
47
|
['Author', (author.name rescue nil)],
|
48
48
|
['Published?', (published ? 'Yes' : 'No')],
|
49
|
+
['Published At', :published_at],
|
50
|
+
['# of Views', :number_of_views],
|
51
|
+
['Rating', :rating],
|
49
52
|
['Category/Tags', "#{category.name} - #{tags.collect(&:name).join(', ')}"]
|
50
53
|
]
|
51
54
|
|
@@ -31,10 +31,16 @@ module SpreadsheetArchitect
|
|
31
31
|
return str
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.get_type(value, type=nil)
|
35
|
-
|
36
|
-
if value.is_a?(Numeric)
|
37
|
-
|
34
|
+
def self.get_type(value, type=nil, last_run=false)
|
35
|
+
return type if !type.blank?
|
36
|
+
if value.is_a?(Numeric)
|
37
|
+
if [:float, :decimal].include?(type)
|
38
|
+
type = :float
|
39
|
+
else
|
40
|
+
type = :integer
|
41
|
+
end
|
42
|
+
elsif !last_run && value.is_a?(Symbol)
|
43
|
+
type = :symbol
|
38
44
|
else
|
39
45
|
type = :string
|
40
46
|
end
|
@@ -64,11 +70,12 @@ module SpreadsheetArchitect
|
|
64
70
|
columns = []
|
65
71
|
types = []
|
66
72
|
array = options[:spreadsheet_columns] || options[:data].first.spreadsheet_columns
|
67
|
-
array.
|
73
|
+
array.each_with_index do |x,i|
|
68
74
|
if x.is_a?(Array)
|
69
75
|
headers.push x[0].to_s
|
70
76
|
columns.push x[1]
|
71
|
-
types.push self.get_type(x[1], x[2])
|
77
|
+
#types.push self.get_type(x[1], x[2])
|
78
|
+
types.push self.get_type(x[1], nil)
|
72
79
|
else
|
73
80
|
headers.push str_humanize(x.to_s)
|
74
81
|
columns.push x
|
@@ -95,6 +102,15 @@ module SpreadsheetArchitect
|
|
95
102
|
data.push columns.map{|col| col.is_a?(Symbol) ? instance.instance_eval(col.to_s) : col}
|
96
103
|
end
|
97
104
|
end
|
105
|
+
|
106
|
+
# Fixes missing types from symbol methods
|
107
|
+
if has_custom_columns || options[:spreadsheet_columns]
|
108
|
+
options[:data].first.each_with_index do |x,i|
|
109
|
+
if types[i] == :symbol
|
110
|
+
types[i] = self.get_type(x, nil, true)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
98
114
|
|
99
115
|
headers = (options[:headers] == false ? false : headers)
|
100
116
|
|
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.4
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: axlsx
|