cloudxls 0.5.0 → 0.5.1

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.
@@ -91,6 +91,14 @@ class Range
91
91
  end
92
92
  end
93
93
 
94
+ class Hash
95
+ def as_csv(options = nil)
96
+ map do |key, val|
97
+ val.as_csv(options)
98
+ end
99
+ end
100
+ end
101
+
94
102
  class Array
95
103
  def as_csv(options = nil)
96
104
  map do |val|
@@ -1,3 +1,3 @@
1
1
  module CloudXLS
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe "as_csv" do
4
+ it "should handle Hash" do
5
+ expect( {:foo => 1, :bar => Date.new(2013,12,24)}.as_csv ).to eq([1,'2013-12-24'])
6
+ end
7
+
8
+ it "should handle Array" do
9
+ expect( [1, Date.new(2013,12,24)].as_csv ).to eq([1,'2013-12-24'])
10
+ end
11
+
12
+ it "should handle Symbol" do
13
+ expect( :foo.as_csv ).to eq('foo')
14
+ end
15
+
16
+ it "should handle Symbol" do
17
+ expect( :foo.as_csv ).to eq('foo')
18
+ end
19
+
20
+ it "should handle nil" do
21
+ expect( nil.as_csv ).to eq(nil)
22
+ end
23
+
24
+ it "should handle boolean" do
25
+ expect( false.as_csv ).to eq(false)
26
+ expect( true.as_csv ).to eq(true)
27
+ end
28
+
29
+ it "should handle float" do
30
+ expect( (1.123).as_csv ).to eq(1.123)
31
+ expect( (1.0/0.0).as_csv ).to eq("#DIV/0!")
32
+ expect( (-1.0/0.0).as_csv ).to eq("#DIV/0!")
33
+ expect( (0.0/0.0).as_csv ).to eq("#DIV/0!")
34
+ end
35
+
36
+ it "should handle Time" do
37
+ expect( Time.new(2012,12,24,18,30,5,'+00:00').as_csv ).to eq("2012-12-24T18:30:05.000+0000")
38
+ end
39
+
40
+ it "should handle DateTime" do
41
+ expect( DateTime.new(2012,12,24,18,30,5,'+00:00').as_csv ).to eq("2012-12-24T18:30:05.000+0000")
42
+ expect( DateTime.new(2012,12,24).as_csv ).to eq("2012-12-24T00:00:00.000+0000")
43
+ end
44
+
45
+ it "should handle DateTime" do
46
+ expect( Date.new(2012,12,24).as_csv ).to eq("2012-12-24")
47
+ end
48
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudxls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -114,6 +114,7 @@ files:
114
114
  - lib/cloudxls/csv_writer.rb
115
115
  - lib/cloudxls/version.rb
116
116
  - lib/data/ca-certificates.txt
117
+ - spec/core_ext_spec.rb
117
118
  - spec/csv_writer_spec.rb
118
119
  - spec/spec_helper.rb
119
120
  homepage: https://cloudxls.com
@@ -141,5 +142,6 @@ signing_key:
141
142
  specification_version: 3
142
143
  summary: Ruby wrapper for the CloudXLS xpipe API
143
144
  test_files:
145
+ - spec/core_ext_spec.rb
144
146
  - spec/csv_writer_spec.rb
145
147
  - spec/spec_helper.rb