dumpster 0.0.1 → 0.1.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.
data/lib/dumpster/csv.rb
CHANGED
@@ -8,17 +8,25 @@ module Dumpster
|
|
8
8
|
@model = model
|
9
9
|
end
|
10
10
|
|
11
|
+
def write_to(io)
|
12
|
+
csv = build_csv(io)
|
13
|
+
@model.each do |row|
|
14
|
+
csv << row
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
11
18
|
def write_to_file(path)
|
12
19
|
File.open(path, 'w+') do |file|
|
13
20
|
write_to file
|
14
21
|
end
|
15
22
|
end
|
16
23
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
def write_to_string
|
25
|
+
require 'stringio'
|
26
|
+
io = StringIO.new
|
27
|
+
write_to(io)
|
28
|
+
io.rewind
|
29
|
+
io.readlines.join
|
22
30
|
end
|
23
31
|
|
24
32
|
def build_csv(io)
|
data/lib/dumpster/version.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'integration/spec_helper'
|
2
3
|
|
3
4
|
describe Dumpster::CSV::Writer do
|
@@ -14,6 +15,10 @@ describe Dumpster::CSV::Writer do
|
|
14
15
|
io.readlines.should == ["col1-row1,col2-row1\n", "col1-row2,col2-row2\n"]
|
15
16
|
end
|
16
17
|
|
18
|
+
it '#write_to_string gibt die CSV-Daten als String zurück' do
|
19
|
+
subject.write_to_string.should == "col1-row1,col2-row1\ncol1-row2,col2-row2\n"
|
20
|
+
end
|
21
|
+
|
17
22
|
it '#write_to_file schreibt die CSV Daten in eine Datei' do
|
18
23
|
output_path = File.join(File.dirname(__FILE__), 'output', 'example.csv')
|
19
24
|
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dumpster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -81,7 +81,7 @@ files:
|
|
81
81
|
- spec/integration/csv/writer_spec.rb
|
82
82
|
- spec/integration/excel/writer_spec.rb
|
83
83
|
- spec/integration/spec_helper.rb
|
84
|
-
- spec/unit/
|
84
|
+
- spec/unit/dumpster_spec.rb
|
85
85
|
- spec/unit/model/generic_spec.rb
|
86
86
|
- spec/unit/spec_helper.rb
|
87
87
|
- tasks/spec.rake
|
@@ -113,6 +113,6 @@ test_files:
|
|
113
113
|
- spec/integration/csv/writer_spec.rb
|
114
114
|
- spec/integration/excel/writer_spec.rb
|
115
115
|
- spec/integration/spec_helper.rb
|
116
|
-
- spec/unit/
|
116
|
+
- spec/unit/dumpster_spec.rb
|
117
117
|
- spec/unit/model/generic_spec.rb
|
118
118
|
- spec/unit/spec_helper.rb
|