excel2csv 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +23 -14
- data/lib/excel2csv.rb +1 -1
- data/lib/excel2csv/version.rb +1 -1
- data/spec/excel2csv_spec.rb +7 -0
- data/spec/fixtures/plain.txt +2 -0
- metadata +13 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d82c4f79d2db413159681cea44901ccbd7779f39
|
4
|
+
data.tar.gz: eeb83b71101e88137056b9c0adefca42e87416e4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 228d9d81100a7a23730b1a99b7f40f21fdeb0a8120400b931faba8ae75fffafa6da69263a77be3e1fdf1c2fe01d63bcac46e67a00ebfec4fed4400d20b885155
|
7
|
+
data.tar.gz: fc63b8f94b3e31e6bf5cf8b97384a246a3c07d0c42b1153f7589d92fa3e248ceab0bc3a3837fc1b0c31eabf4cc3fcff20f18841fadeb75559de829aa9d7389cf
|
data/Rakefile
CHANGED
@@ -1,22 +1,31 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
require
|
2
|
+
require 'bundler/gem_tasks'
|
3
3
|
require 'rspec/core/rake_task'
|
4
4
|
|
5
|
-
desc "Build java jar with mvn"
|
6
|
-
task "build-jar" do
|
7
|
-
java_excel2csv_home = "vendor/excel2csv-java"
|
8
|
-
system "cd #{java_excel2csv_home} && mvn clean package"
|
9
|
-
jar = FileList["#{java_excel2csv_home}/target/excel2csv*.jar"].first
|
10
|
-
if File.exist? jar.to_s
|
11
|
-
cp jar, "lib/excel2csv.jar"
|
12
|
-
else
|
13
|
-
raise "Can't find #{vendor/excel2csv-java/target}/excel2csv-x.x.x.jar. Java build is broken?"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
5
|
desc "Run specs"
|
18
6
|
RSpec::Core::RakeTask.new do |t|
|
19
7
|
t.rspec_opts = %w(-fs --color)
|
20
8
|
end
|
21
9
|
|
22
|
-
task :default => :spec
|
10
|
+
task :default => :spec
|
11
|
+
|
12
|
+
namespace :java do
|
13
|
+
desc "Build java jar with mvn"
|
14
|
+
task :build do
|
15
|
+
java_excel2csv_home = "vendor/excel2csv-java"
|
16
|
+
system "cd #{java_excel2csv_home} && mvn clean package"
|
17
|
+
jar = FileList["#{java_excel2csv_home}/target/excel2csv*.jar"].first
|
18
|
+
if File.exist? jar.to_s
|
19
|
+
cp jar, "lib/excel2csv.jar"
|
20
|
+
else
|
21
|
+
abort "Can't find #{vendor/excel2csv-java/target}/excel2csv-x.x.x.jar. Java build is broken?"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Pull excel2csv-java/master subtree."
|
26
|
+
task :pull do
|
27
|
+
if !system "git pull -s subtree java master"
|
28
|
+
abort "Have to add java remote `git remote add -f java git@github.com:anjlab/excel2csv-java.git`"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/excel2csv.rb
CHANGED
@@ -60,7 +60,7 @@ module Excel2CSV
|
|
60
60
|
working_folder = options[:working_folder] || tmp_dir
|
61
61
|
limit = options[:rows]
|
62
62
|
path = File.expand_path(path)
|
63
|
-
if path =~ /\.csv$/
|
63
|
+
if path =~ /\.(csv)|(txt)$/
|
64
64
|
json = {
|
65
65
|
'generatePreviews' => !!limit,
|
66
66
|
'perSheetRowLimitForPreviews' => limit,
|
data/lib/excel2csv/version.rb
CHANGED
data/spec/excel2csv_spec.rb
CHANGED
@@ -5,6 +5,7 @@ require 'excel2csv'
|
|
5
5
|
describe Excel2CSV do
|
6
6
|
|
7
7
|
let(:excel) {Excel2CSV}
|
8
|
+
let(:plain) {"spec/fixtures/plain.txt"}
|
8
9
|
let(:csv_basic_types) {"spec/fixtures/basic_types.csv"}
|
9
10
|
let(:xls_basic_types) {"spec/fixtures/basic_types.xls"}
|
10
11
|
let(:xlsx_basic_types) {"spec/fixtures/basic_types.xlsx"}
|
@@ -15,6 +16,12 @@ describe Excel2CSV do
|
|
15
16
|
let(:date_25) {Time.new(2011,12,25).strftime("%Y-%m-%dT%H:%M:%S")}
|
16
17
|
let(:date_26) {Time.new(2011,12,26).strftime("%Y-%m-%dT%H:%M:%S")}
|
17
18
|
|
19
|
+
it "reads plain txt files" do
|
20
|
+
data = excel.read plain
|
21
|
+
data[0].should == ["123"]
|
22
|
+
data[1].should == ["456"]
|
23
|
+
end
|
24
|
+
|
18
25
|
it "reads xls files" do
|
19
26
|
data = excel.read xls_basic_types
|
20
27
|
data[0].should == ["1.00", date_24, "Hello"]
|
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel2csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Yury Korolev
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-03-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '2.8'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '2.8'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: gem for converting Excel files to csv
|
@@ -66,36 +61,30 @@ files:
|
|
66
61
|
- spec/fixtures/file name with spaces.csv
|
67
62
|
- spec/fixtures/file name with spaces.xls
|
68
63
|
- spec/fixtures/file name with spaces.xlsx
|
64
|
+
- spec/fixtures/plain.txt
|
69
65
|
- spec/spec_helper.rb
|
70
66
|
homepage: https://github.com/anjlab/excel2csv-ruby
|
71
67
|
licenses: []
|
68
|
+
metadata: {}
|
72
69
|
post_install_message:
|
73
70
|
rdoc_options: []
|
74
71
|
require_paths:
|
75
72
|
- lib
|
76
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
74
|
requirements:
|
79
|
-
- -
|
75
|
+
- - '>='
|
80
76
|
- !ruby/object:Gem::Version
|
81
77
|
version: '0'
|
82
|
-
segments:
|
83
|
-
- 0
|
84
|
-
hash: -3724984622859506611
|
85
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
79
|
requirements:
|
88
|
-
- -
|
80
|
+
- - '>='
|
89
81
|
- !ruby/object:Gem::Version
|
90
82
|
version: '0'
|
91
|
-
segments:
|
92
|
-
- 0
|
93
|
-
hash: -3724984622859506611
|
94
83
|
requirements: []
|
95
84
|
rubyforge_project:
|
96
|
-
rubygems_version:
|
85
|
+
rubygems_version: 2.0.0
|
97
86
|
signing_key:
|
98
|
-
specification_version:
|
87
|
+
specification_version: 4
|
99
88
|
summary: extract excel worksheets to csv files
|
100
89
|
test_files:
|
101
90
|
- spec/excel2csv_spec.rb
|
@@ -105,4 +94,5 @@ test_files:
|
|
105
94
|
- spec/fixtures/file name with spaces.csv
|
106
95
|
- spec/fixtures/file name with spaces.xls
|
107
96
|
- spec/fixtures/file name with spaces.xlsx
|
97
|
+
- spec/fixtures/plain.txt
|
108
98
|
- spec/spec_helper.rb
|