windows_csv 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/windows_csv.rb CHANGED
@@ -15,6 +15,11 @@ class WindowsCsv
15
15
  csv_args.merge!(args[:csv_args]) if args[:csv_args]
16
16
 
17
17
  Csv_lazy.new(csv_args) do |row|
18
+ real = []
19
+ row.each do |col|
20
+ real << col
21
+ end
22
+
18
23
  yield row
19
24
  end
20
25
  end
@@ -53,7 +58,7 @@ class WindowsCsv
53
58
  elsif col.is_a?(Date)
54
59
  encoded << col.strftime("%Y-%m-%d")
55
60
  else
56
- encoded << col
61
+ encoded << WindowsCsv.escape(col)
57
62
  end
58
63
  end
59
64
 
@@ -61,4 +66,8 @@ class WindowsCsv
61
66
 
62
67
  return nil
63
68
  end
69
+
70
+ def self.escape(str)
71
+ return str.to_s.gsub("\n", "\\r\\n")
72
+ end
64
73
  end
@@ -11,8 +11,8 @@ describe "WindowsCsv" do
11
11
  tmpfile = "#{Dir.tmpdir}/windows_csv_test_#{Digest::MD5.hexdigest(Time.now.to_f.to_s)}.csv"
12
12
 
13
13
  WindowsCsv.new(:path => tmpfile) do |csv|
14
- csv << ["Name1", "Name2", "Encoding", "Date", "Time", "DateTime"]
15
- csv << ["Kasper", "Christina", "æøå", Date.new, Time.new, DateTime.new]
14
+ csv << ["Name1", "Name2", "Encoding", "Date", "Time", "DateTime", "MultiLine"]
15
+ csv << ["Kasper", "Christina", "æøå", Date.new, Time.new, DateTime.new, "Multi\nLine"]
16
16
  end
17
17
 
18
18
  #puts "Path: #{tmpfile}"
@@ -22,6 +22,7 @@ describe "WindowsCsv" do
22
22
  #puts "Row: #{row}"
23
23
  row[:Name2].should eql("Christina")
24
24
  row[:Encoding].should eql("æøå")
25
+ row[:MultiLine].should eql("Multi\r\nLine")
25
26
  end
26
27
  rescue => e
27
28
  puts e.inspect
data/windows_csv.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "windows_csv"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kaspernj"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: windows_csv
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - kaspernj
@@ -125,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  segments:
127
127
  - 0
128
- hash: -4189247397405598293
128
+ hash: -3862628782425158957
129
129
  version: '0'
130
130
  required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  none: false