excel2csv 0.0.9 → 0.1.0
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/excel2csv/version.rb
CHANGED
data/lib/excel2csv.rb
CHANGED
@@ -58,6 +58,7 @@ module Excel2CSV
|
|
58
58
|
tmp_dir = Dir.mktmpdir
|
59
59
|
working_folder = options[:working_folder] || tmp_dir
|
60
60
|
limit = options[:rows]
|
61
|
+
path = File.expand_path(path)
|
61
62
|
if path =~ /\.csv$/
|
62
63
|
total_rows = 0
|
63
64
|
preview_rows = []
|
@@ -84,7 +85,7 @@ module Excel2CSV
|
|
84
85
|
java_options = options[:java_options] || "-Dfile.encoding=utf8 -Xms512m -Xmx512m -XX:MaxPermSize=256m"
|
85
86
|
rows_limit = limit ? "-r #{limit}" : ""
|
86
87
|
jar_path = File.join(File.dirname(__FILE__), "excel2csv.jar")
|
87
|
-
`java #{java_options} -jar #{jar_path} #{rows_limit} #{path} #{working_folder}`
|
88
|
+
`java #{java_options} -jar #{jar_path} #{rows_limit} "#{path}" #{working_folder}`
|
88
89
|
end
|
89
90
|
|
90
91
|
Info.read(working_folder)
|
data/spec/excel2csv_spec.rb
CHANGED
@@ -8,6 +8,9 @@ describe Excel2CSV do
|
|
8
8
|
let(:csv_basic_types) {"spec/fixtures/basic_types.csv"}
|
9
9
|
let(:xls_basic_types) {"spec/fixtures/basic_types.xls"}
|
10
10
|
let(:xlsx_basic_types) {"spec/fixtures/basic_types.xlsx"}
|
11
|
+
let(:csv_with_spaces) {"spec/fixtures/file name with spaces.csv"}
|
12
|
+
let(:xls_with_spaces) {"spec/fixtures/file name with spaces.xls"}
|
13
|
+
let(:xlsx_with_spaces) {"spec/fixtures/file name with spaces.xlsx"}
|
11
14
|
let(:date_24) {Time.new(2011,12,24).strftime("%Y-%m-%dT%H:%M:%S")}
|
12
15
|
let(:date_25) {Time.new(2011,12,25).strftime("%Y-%m-%dT%H:%M:%S")}
|
13
16
|
let(:date_26) {Time.new(2011,12,26).strftime("%Y-%m-%dT%H:%M:%S")}
|
@@ -93,8 +96,22 @@ describe Excel2CSV do
|
|
93
96
|
data[1].should == ["2.00","12/25/11 12:00 AM","Привет"]
|
94
97
|
end
|
95
98
|
|
96
|
-
|
97
|
-
|
99
|
+
context "file names with spaces" do
|
100
|
+
it "reads csv files" do
|
101
|
+
data = excel.read(csv_with_spaces, encoding:'windows-1251:utf-8')
|
102
|
+
data.should == [["1.00"], ["2.00"]]
|
103
|
+
end
|
104
|
+
|
105
|
+
it "reads xls files" do
|
106
|
+
data = excel.read(xls_with_spaces)
|
107
|
+
data.should == [["1"], ["2"]]
|
108
|
+
end
|
109
|
+
|
110
|
+
it "reads xlsx files" do
|
111
|
+
data = excel.read(xlsx_with_spaces)
|
112
|
+
data.should == [["1"], ["2"]]
|
113
|
+
end
|
114
|
+
end
|
98
115
|
|
99
116
|
|
100
117
|
end
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel2csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70182857005000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - <=
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.6'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70182857005000
|
25
25
|
description: gem for converting Excel files to csv
|
26
26
|
email:
|
27
27
|
- yury.korolev@gmail.com
|
@@ -42,6 +42,9 @@ files:
|
|
42
42
|
- spec/fixtures/basic_types.csv
|
43
43
|
- spec/fixtures/basic_types.xls
|
44
44
|
- spec/fixtures/basic_types.xlsx
|
45
|
+
- spec/fixtures/file name with spaces.csv
|
46
|
+
- spec/fixtures/file name with spaces.xls
|
47
|
+
- spec/fixtures/file name with spaces.xlsx
|
45
48
|
- spec/spec_helper.rb
|
46
49
|
homepage: https://github.com/anjlab/excel2csv-ruby
|
47
50
|
licenses: []
|
@@ -63,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
66
|
version: '0'
|
64
67
|
requirements: []
|
65
68
|
rubyforge_project:
|
66
|
-
rubygems_version: 1.8.
|
69
|
+
rubygems_version: 1.8.10
|
67
70
|
signing_key:
|
68
71
|
specification_version: 3
|
69
72
|
summary: extract excel worksheets to csv files
|
@@ -72,4 +75,7 @@ test_files:
|
|
72
75
|
- spec/fixtures/basic_types.csv
|
73
76
|
- spec/fixtures/basic_types.xls
|
74
77
|
- spec/fixtures/basic_types.xlsx
|
78
|
+
- spec/fixtures/file name with spaces.csv
|
79
|
+
- spec/fixtures/file name with spaces.xls
|
80
|
+
- spec/fixtures/file name with spaces.xlsx
|
75
81
|
- spec/spec_helper.rb
|