comma-heaven 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.3
|
data/comma-heaven.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "comma-heaven"
|
8
|
-
s.version = "0.8.
|
8
|
+
s.version = "0.8.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Silvano Stralla"]
|
12
|
-
s.date = "2013-05
|
12
|
+
s.date = "2013-09-05"
|
13
13
|
s.description = "CommaHeaven permits easy exports of Rails models to CSV"
|
14
14
|
s.email = "silvano.stralla@sistrall.it"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -13,7 +13,7 @@ module CommaHeaven
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_comma_heaven(options = {})
|
16
|
-
options.symbolize_keys!
|
16
|
+
options.symbolize_keys! if options.respond_to?(:symbolize_keys!)
|
17
17
|
options[:limit] = options[:limit].to_i if options[:limit].kind_of?(String)
|
18
18
|
options[:converter] ||= lambda { |v| v }
|
19
19
|
|
@@ -57,7 +57,7 @@ module CommaHeaven
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def to_comma_heaven(options = {})
|
60
|
-
options.symbolize_keys!
|
60
|
+
options.symbolize_keys! if options.respond_to?(:symbolize_keys!)
|
61
61
|
options[:limit] = options[:limit].to_i if options[:limit].kind_of?(String)
|
62
62
|
options[:converter] ||= lambda { |v| v }
|
63
63
|
|
@@ -74,7 +74,7 @@ module CommaHeaven
|
|
74
74
|
|
75
75
|
if options[:format]
|
76
76
|
begin
|
77
|
-
value = value.
|
77
|
+
value = value.strftime(options[:format][:datetime]) if (value.is_a?(Date) || value.is_a?(Time)) && options[:format][:datetime]
|
78
78
|
rescue
|
79
79
|
end
|
80
80
|
end
|
data/lib/comma-heaven/export.rb
CHANGED
@@ -36,11 +36,11 @@ module CommaHeaven
|
|
36
36
|
self.current_scope = current_scope
|
37
37
|
self.options = options || {}
|
38
38
|
|
39
|
-
self.options.symbolize_keys!
|
39
|
+
self.options.symbolize_keys! if self.options.respond_to?(:symbolize_keys!)
|
40
40
|
|
41
41
|
self.export = self.options[:export] || {}
|
42
42
|
|
43
|
-
self.export.symbolize_keys!
|
43
|
+
self.export.symbolize_keys! if self.export.respond_to?(:symbolize_keys!)
|
44
44
|
|
45
45
|
self.limit = self.options[:limit]
|
46
46
|
end
|
@@ -50,10 +50,13 @@ module CommaHeaven
|
|
50
50
|
|
51
51
|
csv_options = all_options.slice(*FasterCSV::DEFAULT_OPTIONS.keys)
|
52
52
|
tch_options = all_options.except(*FasterCSV::DEFAULT_OPTIONS.keys) # TCH means To Comma Heaven
|
53
|
+
|
54
|
+
tch_options = tch_options.symbolize_keys if tch_options.respond_to?(:symbolize_keys!)
|
55
|
+
csv_options = csv_options.symbolize_keys if csv_options.respond_to?(:symbolize_keys!)
|
53
56
|
|
54
57
|
current_scope
|
55
|
-
.to_comma_heaven(tch_options
|
56
|
-
.to_csv(csv_options
|
58
|
+
.to_comma_heaven(tch_options)
|
59
|
+
.to_csv(csv_options)
|
57
60
|
end
|
58
61
|
|
59
62
|
private
|
@@ -89,7 +89,7 @@ module CommaHeaven
|
|
89
89
|
end.sort do |a,b|
|
90
90
|
a[1] <=> b[1]
|
91
91
|
end.each do |column_or_association, position, opts|
|
92
|
-
opts.symbolize_keys!
|
92
|
+
opts.symbolize_keys! if opts.respond_to?(:symbolize_keys!)
|
93
93
|
|
94
94
|
unless opts[:include] == '0'
|
95
95
|
association = @model.reflect_on_association(column_or_association.to_sym)
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: comma-heaven
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.8.
|
5
|
+
version: 0.8.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Silvano Stralla
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05
|
12
|
+
date: 2013-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|
@@ -301,7 +301,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
301
301
|
- !ruby/object:Gem::Version
|
302
302
|
segments:
|
303
303
|
- 0
|
304
|
-
hash: -
|
304
|
+
hash: -454386425193293639
|
305
305
|
version: '0'
|
306
306
|
none: false
|
307
307
|
required_rubygems_version: !ruby/object:Gem::Requirement
|