sequel_plus 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/extensions/export.rb +4 -1
- data/test/test_export.rb +7 -0
- metadata +2 -2
data/lib/extensions/export.rb
CHANGED
@@ -31,8 +31,11 @@ module Sequel
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def output
|
34
|
+
first_row = @dataset.first
|
35
|
+
return unless first_row
|
36
|
+
|
34
37
|
quot = @options[:quote_char]
|
35
|
-
@columns ||=
|
38
|
+
@columns ||= first_row.keys.sort_by{|x|x.to_s}
|
36
39
|
|
37
40
|
if @options[:headers] == true
|
38
41
|
@file.puts @columns.map{|col| "#{quot}#{col}#{quot}"}.join(@options[:delimiter])
|
data/test/test_export.rb
CHANGED
@@ -50,6 +50,13 @@ module ExportTest
|
|
50
50
|
DB[:nodes].all.size.should == 12
|
51
51
|
end
|
52
52
|
|
53
|
+
it "should do nothing with empty result sets" do
|
54
|
+
mem_stream = StringIO.new("", "w+")
|
55
|
+
DB[:nodes].filter(:name => 'bogus').export(mem_stream)
|
56
|
+
mem_stream.pos = 0
|
57
|
+
mem_stream.read.should == ""
|
58
|
+
end
|
59
|
+
|
53
60
|
it "should export everything tab delimited w/o quotes" do
|
54
61
|
mem_stream = StringIO.new("", "w+")
|
55
62
|
DB[:nodes].export(mem_stream)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Lang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-21 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|