windows_csv 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/windows_csv.rb +3 -3
- data/spec/windows_csv_spec.rb +5 -11
- data/windows_csv.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/windows_csv.rb
CHANGED
@@ -8,7 +8,7 @@ class WindowsCsv
|
|
8
8
|
require "rubygems"
|
9
9
|
require "csv_lazy"
|
10
10
|
|
11
|
-
File.open(path, "
|
11
|
+
File.open(path, "r", :encoding => "UTF-8") do |fp|
|
12
12
|
fp.sysread(2)
|
13
13
|
|
14
14
|
csv_args = {:debug => false, :io => fp, :col_sep => COL_SEP, :quote_char => QUOTE_CHAR}
|
@@ -33,14 +33,14 @@ class WindowsCsv
|
|
33
33
|
@args = args
|
34
34
|
|
35
35
|
if @args[:path]
|
36
|
-
fp = File.open(@args[:path], "
|
36
|
+
fp = File.open(@args[:path], "w", :encoding => ENCODING)
|
37
37
|
@args[:io] = fp
|
38
38
|
end
|
39
39
|
|
40
40
|
begin
|
41
41
|
@args[:io].write(BOM)
|
42
42
|
|
43
|
-
::CSV.open(@args[:io], "
|
43
|
+
::CSV.open(@args[:io], "w", :col_sep => COL_SEP, :quote_char => QUOTE_CHAR, :force_quotes => true) do |csv|
|
44
44
|
@csv = csv
|
45
45
|
yield self
|
46
46
|
end
|
data/spec/windows_csv_spec.rb
CHANGED
@@ -17,17 +17,11 @@ describe "WindowsCsv" do
|
|
17
17
|
|
18
18
|
#puts "Path: #{tmpfile}"
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
row[:MultiLine].should eql("Multi\r\nLine")
|
26
|
-
end
|
27
|
-
rescue => e
|
28
|
-
puts e.inspect
|
29
|
-
puts e.backtrace
|
30
|
-
raise e
|
20
|
+
WindowsCsv.foreach(tmpfile, :csv_args => {:headers => true}) do |row|
|
21
|
+
#puts "Row: #{row}"
|
22
|
+
row[:Name2].should eql("Christina")
|
23
|
+
row[:Encoding].should eql("æøå")
|
24
|
+
row[:MultiLine].should eql("Multi\r\nLine")
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
data/windows_csv.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "windows_csv"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["kaspernj"]
|
12
|
-
s.date = "2013-05-
|
12
|
+
s.date = "2013-05-02"
|
13
13
|
s.description = "A framework to write Windows CSV files."
|
14
14
|
s.email = "k@spernj.org"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: windows_csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- kaspernj
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -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:
|
128
|
+
hash: 2642998020291054997
|
129
129
|
version: '0'
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
none: false
|