comma-heaven 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,10 @@ module CommaHeaven
|
|
25
25
|
value = resource.send(field)
|
26
26
|
|
27
27
|
if options[:format]
|
28
|
-
|
28
|
+
begin
|
29
|
+
value = value.to_time.strftime(options[:format][:datetime]) if value =~ %r{^(\d{4,4})-(\d{2,2})-(\d{2,2})} && options[:format][:datetime]
|
30
|
+
rescue
|
31
|
+
end
|
29
32
|
end
|
30
33
|
|
31
34
|
acc << options[:converter].call(value)
|
@@ -231,4 +231,17 @@ Ulivo,Bob,,0
|
|
231
231
|
Ulivo,Bob,,5
|
232
232
|
EOS
|
233
233
|
end
|
234
|
+
|
235
|
+
|
236
|
+
it "shouldn't raise errors with text fields containing dates" do
|
237
|
+
pero = Tree.create(:name => 'Pero (marzo 2011)', :age => 10)
|
238
|
+
|
239
|
+
Tree.to_comma_heaven(:format => {:datetime => '%d/%m/%Y %H:%M'}, :export => {:name => {0 => {}}, :age => {1 => {}}, :leafs => {2 => {:export => {:position => {4 => {}}}, :limit => ''}}}).to_csv.should == <<-EOS
|
240
|
+
tree_name,tree_age,leaf_0_position
|
241
|
+
Olmo,100,top
|
242
|
+
Ulivo,150,0
|
243
|
+
Pero (marzo 2011),10,
|
244
|
+
EOS
|
245
|
+
end
|
246
|
+
|
234
247
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comma-heaven
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 4
|
10
|
+
version: 0.5.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Silvano Stralla
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-02-08 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|