simple-spreadsheet-extractor 0.12.3 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -1
- data/Gemfile.lock +46 -1
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/jars/lib/{poi-ooxml-3.8.jar → poi-ooxml-3.9.jar} +0 -0
- data/jars/lib/{poi-ooxml-schemas-3.8.jar → poi-ooxml-schemas-3.9.jar} +0 -0
- data/jars/lib/{rightfield-poi-3.8.jar → rightfield-poi-3.9.jar} +0 -0
- data/jars/simple-spreadsheet-extractor-0.13.0.jar +0 -0
- data/lib/simple-spreadsheet-extractor.rb +1 -1
- data/simple-spreadsheet-extractor.gemspec +14 -7
- data/test/test_extraction.rb +93 -0
- metadata +49 -20
- data/jars/simple-spreadsheet-extractor-0.12.1.jar +0 -0
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,57 @@
|
|
1
1
|
GEM
|
2
|
-
remote:
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
remote: http://gems.github.com/
|
3
4
|
specs:
|
5
|
+
addressable (2.3.5)
|
6
|
+
builder (3.2.2)
|
7
|
+
faraday (0.8.8)
|
8
|
+
multipart-post (~> 1.2.0)
|
9
|
+
git (1.2.6)
|
10
|
+
github_api (0.10.1)
|
11
|
+
addressable
|
12
|
+
faraday (~> 0.8.1)
|
13
|
+
hashie (>= 1.2)
|
14
|
+
multi_json (~> 1.4)
|
15
|
+
nokogiri (~> 1.5.2)
|
16
|
+
oauth2
|
17
|
+
hashie (2.0.5)
|
18
|
+
highline (1.6.20)
|
19
|
+
httpauth (0.2.0)
|
20
|
+
jeweler (1.8.8)
|
21
|
+
builder
|
22
|
+
bundler (~> 1.0)
|
23
|
+
git (>= 1.2.5)
|
24
|
+
github_api (= 0.10.1)
|
25
|
+
highline (>= 1.6.15)
|
26
|
+
nokogiri (= 1.5.10)
|
27
|
+
rake
|
28
|
+
rdoc
|
29
|
+
json (1.8.1)
|
30
|
+
jwt (0.1.8)
|
31
|
+
multi_json (>= 1.5)
|
4
32
|
libxml-ruby (2.6.0)
|
33
|
+
multi_json (1.8.2)
|
34
|
+
multi_xml (0.5.5)
|
35
|
+
multipart-post (1.2.0)
|
36
|
+
nokogiri (1.5.10)
|
37
|
+
oauth2 (0.9.2)
|
38
|
+
faraday (~> 0.8)
|
39
|
+
httpauth (~> 0.2)
|
40
|
+
jwt (~> 0.1.4)
|
41
|
+
multi_json (~> 1.0)
|
42
|
+
multi_xml (~> 0.5)
|
43
|
+
rack (~> 1.2)
|
5
44
|
open4 (1.3.0)
|
45
|
+
rack (1.5.2)
|
46
|
+
rake (10.1.0)
|
47
|
+
rdoc (4.0.1)
|
48
|
+
json (~> 1.4)
|
6
49
|
|
7
50
|
PLATFORMS
|
8
51
|
ruby
|
9
52
|
|
10
53
|
DEPENDENCIES
|
54
|
+
jeweler
|
11
55
|
libxml-ruby (= 2.6.0)
|
12
56
|
open4 (= 1.3.0)
|
57
|
+
rdoc
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.13.0
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "simple-spreadsheet-extractor"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.13.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Stuart Owen", "Finn Bacall"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-11-13"
|
13
13
|
s.description = "Takes a stream to a spreadsheet file and produces an XML or CSV representation of its contents"
|
14
14
|
s.email = "stuart.owen@manchester.ac.uk"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,18 +26,19 @@ Gem::Specification.new do |s|
|
|
26
26
|
"doc/schema-v1.xsd",
|
27
27
|
"examples/example.rb",
|
28
28
|
"jars/lib/dom4j-1.6.1.jar",
|
29
|
-
"jars/lib/poi-ooxml-3.
|
30
|
-
"jars/lib/poi-ooxml-schemas-3.
|
31
|
-
"jars/lib/rightfield-poi-3.
|
29
|
+
"jars/lib/poi-ooxml-3.9.jar",
|
30
|
+
"jars/lib/poi-ooxml-schemas-3.9.jar",
|
31
|
+
"jars/lib/rightfield-poi-3.9.jar",
|
32
32
|
"jars/lib/xmlbeans-2.3.0.jar",
|
33
|
-
"jars/simple-spreadsheet-extractor-0.
|
33
|
+
"jars/simple-spreadsheet-extractor-0.13.0.jar",
|
34
34
|
"lib/simple-spreadsheet-extractor.rb",
|
35
35
|
"simple-spreadsheet-extractor.gemspec",
|
36
36
|
"test/files/not-a-spreadsheet.xls",
|
37
37
|
"test/files/problem_with_dv.xls",
|
38
38
|
"test/files/test-csv-output1-trimmed.csv",
|
39
39
|
"test/files/test-csv-output1.csv",
|
40
|
-
"test/files/test-spreadsheet.xls"
|
40
|
+
"test/files/test-spreadsheet.xls",
|
41
|
+
"test/test_extraction.rb"
|
41
42
|
]
|
42
43
|
s.homepage = "http://github.com/myGrid/simple-spreadsheet-extractor-gem"
|
43
44
|
s.require_paths = ["lib"]
|
@@ -50,17 +51,23 @@ Gem::Specification.new do |s|
|
|
50
51
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
52
|
s.add_runtime_dependency(%q<libxml-ruby>, ["= 2.6.0"])
|
52
53
|
s.add_runtime_dependency(%q<open4>, ["= 1.3.0"])
|
54
|
+
s.add_runtime_dependency(%q<rdoc>, [">= 0"])
|
55
|
+
s.add_runtime_dependency(%q<jeweler>, [">= 0"])
|
53
56
|
s.add_runtime_dependency(%q<libxml-ruby>, ["= 2.6.0"])
|
54
57
|
s.add_runtime_dependency(%q<open4>, ["= 1.3.0"])
|
55
58
|
else
|
56
59
|
s.add_dependency(%q<libxml-ruby>, ["= 2.6.0"])
|
57
60
|
s.add_dependency(%q<open4>, ["= 1.3.0"])
|
61
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
62
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
58
63
|
s.add_dependency(%q<libxml-ruby>, ["= 2.6.0"])
|
59
64
|
s.add_dependency(%q<open4>, ["= 1.3.0"])
|
60
65
|
end
|
61
66
|
else
|
62
67
|
s.add_dependency(%q<libxml-ruby>, ["= 2.6.0"])
|
63
68
|
s.add_dependency(%q<open4>, ["= 1.3.0"])
|
69
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
70
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
64
71
|
s.add_dependency(%q<libxml-ruby>, ["= 2.6.0"])
|
65
72
|
s.add_dependency(%q<open4>, ["= 1.3.0"])
|
66
73
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'simple-spreadsheet-extractor'
|
3
|
+
require 'libxml'
|
4
|
+
|
5
|
+
class TestExtraction < Test::Unit::TestCase
|
6
|
+
|
7
|
+
SCHEMA_FILE_PATH = File.dirname(__FILE__) + "/../doc/schema-v1.xsd"
|
8
|
+
|
9
|
+
include SysMODB::SpreadsheetExtractor
|
10
|
+
|
11
|
+
def test_from_file_object
|
12
|
+
test_sheet = File.dirname(__FILE__) + "/files/test-spreadsheet.xls"
|
13
|
+
f=open(test_sheet,"rb")
|
14
|
+
xml = spreadsheet_to_xml(f)
|
15
|
+
assert_not_nil xml
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_from_non_file_io_object
|
19
|
+
test_sheet = File.dirname(__FILE__) + "/files/test-spreadsheet.xls"
|
20
|
+
contents = open(test_sheet, "rb") {|io| io.read }
|
21
|
+
io=StringIO.new contents
|
22
|
+
assert_nil io.path
|
23
|
+
xml = spreadsheet_to_xml(io)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_validate_xml
|
27
|
+
test_sheet = File.dirname(__FILE__) + "/files/test-spreadsheet.xls"
|
28
|
+
f=open(test_sheet,"rb")
|
29
|
+
xml = spreadsheet_to_xml(f)
|
30
|
+
validate_against_schema(xml)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_failure
|
34
|
+
test_sheet = File.dirname(__FILE__) + "/files/not-a-spreadsheet.xls"
|
35
|
+
f=open(test_sheet,"rb")
|
36
|
+
assert_raise SysMODB::SpreadsheetExtractionException do
|
37
|
+
spreadsheet_to_xml(f)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_problem_with_dv
|
42
|
+
test_sheet = File.dirname(__FILE__) + "/files/problem_with_dv.xls"
|
43
|
+
f=open(test_sheet,"rb")
|
44
|
+
xml = spreadsheet_to_xml(f)
|
45
|
+
validate_against_schema(xml)
|
46
|
+
end
|
47
|
+
|
48
|
+
def validate_against_schema xml
|
49
|
+
document = LibXML::XML::Document.string(xml)
|
50
|
+
schema = LibXML::XML::Schema.new(SCHEMA_FILE_PATH)
|
51
|
+
begin
|
52
|
+
document.validate_schema(schema)
|
53
|
+
rescue LibXML::XML::Error => e
|
54
|
+
puts xml
|
55
|
+
assert false,"Error validating against schema: #{e.message}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_csv_output
|
60
|
+
test_sheet = File.dirname(__FILE__) + "/files/test-spreadsheet.xls"
|
61
|
+
expected_file = File.dirname(__FILE__) + "/files/test-csv-output1.csv"
|
62
|
+
expected = open(expected_file,"rb").read.strip
|
63
|
+
|
64
|
+
f=open(test_sheet,"rb")
|
65
|
+
csv = spreadsheet_to_csv(f,2)
|
66
|
+
assert_equal expected,csv
|
67
|
+
|
68
|
+
#try sheet as a string
|
69
|
+
f=open(test_sheet,"rb")
|
70
|
+
csv = spreadsheet_to_csv(f,"2")
|
71
|
+
assert_equal expected,csv
|
72
|
+
end
|
73
|
+
|
74
|
+
# def test_csv_output_trimmed
|
75
|
+
# test_sheet = File.dirname(__FILE__) + "/files/test-spreadsheet.xls"
|
76
|
+
# expected_file = File.dirname(__FILE__) + "/files/test-csv-output1-trimmed.csv"
|
77
|
+
# expected = open(expected_file,"rb").read
|
78
|
+
#
|
79
|
+
# f=open(test_sheet,"rb")
|
80
|
+
# csv = spreadsheet_to_csv(f,2,true)
|
81
|
+
# assert_equal expected,csv
|
82
|
+
# end
|
83
|
+
|
84
|
+
def test_for_segfault
|
85
|
+
test_sheet = File.dirname(__FILE__) + "/files/test-spreadsheet.xls"
|
86
|
+
5.times do |x|
|
87
|
+
f=open(test_sheet,"rb")
|
88
|
+
xml = spreadsheet_to_xml(f)
|
89
|
+
end
|
90
|
+
true
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-spreadsheet-extractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 13
|
9
|
+
- 0
|
10
|
+
version: 0.13.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stuart Owen
|
@@ -16,11 +16,11 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-
|
19
|
+
date: 2013-11-13 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
type: :runtime
|
23
|
-
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
26
|
- - "="
|
@@ -31,12 +31,12 @@ dependencies:
|
|
31
31
|
- 6
|
32
32
|
- 0
|
33
33
|
version: 2.6.0
|
34
|
-
|
35
|
-
name: libxml-ruby
|
34
|
+
requirement: *id001
|
36
35
|
prerelease: false
|
36
|
+
name: libxml-ruby
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
type: :runtime
|
39
|
-
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - "="
|
@@ -47,12 +47,40 @@ dependencies:
|
|
47
47
|
- 3
|
48
48
|
- 0
|
49
49
|
version: 1.3.0
|
50
|
-
|
50
|
+
requirement: *id002
|
51
|
+
prerelease: false
|
51
52
|
name: open4
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
requirement: *id003
|
52
65
|
prerelease: false
|
66
|
+
name: rdoc
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
type: :runtime
|
55
|
-
|
69
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
requirement: *id004
|
79
|
+
prerelease: false
|
80
|
+
name: jeweler
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
type: :runtime
|
83
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
56
84
|
none: false
|
57
85
|
requirements:
|
58
86
|
- - "="
|
@@ -63,12 +91,12 @@ dependencies:
|
|
63
91
|
- 6
|
64
92
|
- 0
|
65
93
|
version: 2.6.0
|
66
|
-
|
67
|
-
name: libxml-ruby
|
94
|
+
requirement: *id005
|
68
95
|
prerelease: false
|
96
|
+
name: libxml-ruby
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
type: :runtime
|
71
|
-
|
99
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
72
100
|
none: false
|
73
101
|
requirements:
|
74
102
|
- - "="
|
@@ -79,9 +107,9 @@ dependencies:
|
|
79
107
|
- 3
|
80
108
|
- 0
|
81
109
|
version: 1.3.0
|
82
|
-
|
83
|
-
name: open4
|
110
|
+
requirement: *id006
|
84
111
|
prerelease: false
|
112
|
+
name: open4
|
85
113
|
description: Takes a stream to a spreadsheet file and produces an XML or CSV representation of its contents
|
86
114
|
email: stuart.owen@manchester.ac.uk
|
87
115
|
executables: []
|
@@ -101,11 +129,11 @@ files:
|
|
101
129
|
- doc/schema-v1.xsd
|
102
130
|
- examples/example.rb
|
103
131
|
- jars/lib/dom4j-1.6.1.jar
|
104
|
-
- jars/lib/poi-ooxml-3.
|
105
|
-
- jars/lib/poi-ooxml-schemas-3.
|
106
|
-
- jars/lib/rightfield-poi-3.
|
132
|
+
- jars/lib/poi-ooxml-3.9.jar
|
133
|
+
- jars/lib/poi-ooxml-schemas-3.9.jar
|
134
|
+
- jars/lib/rightfield-poi-3.9.jar
|
107
135
|
- jars/lib/xmlbeans-2.3.0.jar
|
108
|
-
- jars/simple-spreadsheet-extractor-0.
|
136
|
+
- jars/simple-spreadsheet-extractor-0.13.0.jar
|
109
137
|
- lib/simple-spreadsheet-extractor.rb
|
110
138
|
- simple-spreadsheet-extractor.gemspec
|
111
139
|
- test/files/not-a-spreadsheet.xls
|
@@ -113,6 +141,7 @@ files:
|
|
113
141
|
- test/files/test-csv-output1-trimmed.csv
|
114
142
|
- test/files/test-csv-output1.csv
|
115
143
|
- test/files/test-spreadsheet.xls
|
144
|
+
- test/test_extraction.rb
|
116
145
|
homepage: http://github.com/myGrid/simple-spreadsheet-extractor-gem
|
117
146
|
licenses: []
|
118
147
|
|
Binary file
|