simple-spreadsheet-extractor 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/jars/{simple-spreadsheet-extractor-0.6.3.jar → simple-spreadsheet-extractor-0.6.4.jar} +0 -0
- data/lib/simple-spreadsheet-extractor.rb +1 -1
- data/simple-spreadsheet-extractor.gemspec +5 -4
- data/test/files/not-a-spreadsheet.xls +1 -0
- data/test/files/test-csv-output1-trimmed.csv +2 -0
- data/test/files/test-csv-output1.csv +4 -0
- data/test/files/test-spreadsheet.xls +0 -0
- data/test/test_extraction.rb +78 -0
- metadata +14 -8
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.4
|
Binary file
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{simple-spreadsheet-extractor}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.4"
|
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 = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-25}
|
13
13
|
s.description = %q{Takes a stream to a spreadsheet file and produces an XML or CSV representation of its contents}
|
14
14
|
s.email = %q{stuart.owen@manchester.ac.uk}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,16 +27,17 @@ Gem::Specification.new do |s|
|
|
27
27
|
"jars/lib/poi-ooxml-3.7.jar",
|
28
28
|
"jars/lib/poi-ooxml-schemas-3.7.jar",
|
29
29
|
"jars/lib/xmlbeans-2.3.0.jar",
|
30
|
-
"jars/simple-spreadsheet-extractor-0.6.
|
30
|
+
"jars/simple-spreadsheet-extractor-0.6.4.jar",
|
31
31
|
"lib/simple-spreadsheet-extractor.rb",
|
32
32
|
"simple-spreadsheet-extractor.gemspec"
|
33
33
|
]
|
34
34
|
s.homepage = %q{http://github.com/myGrid/simple-spreadsheet-extractor-gem}
|
35
35
|
s.require_paths = ["lib"]
|
36
|
-
s.rubygems_version = %q{1.
|
36
|
+
s.rubygems_version = %q{1.3.7}
|
37
37
|
s.summary = %q{Basic spreadsheet content extraction using Apache POI}
|
38
38
|
|
39
39
|
if s.respond_to? :specification_version then
|
40
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
40
41
|
s.specification_version = 3
|
41
42
|
|
42
43
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
@@ -0,0 +1 @@
|
|
1
|
+
this is not a spreadsheet
|
Binary file
|
@@ -0,0 +1,78 @@
|
|
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_validate_xml
|
19
|
+
test_sheet = File.dirname(__FILE__) + "/files/test-spreadsheet.xls"
|
20
|
+
f=open(test_sheet,"rb")
|
21
|
+
xml = spreadsheet_to_xml(f)
|
22
|
+
validate_against_schema(xml)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_failure
|
26
|
+
test_sheet = File.dirname(__FILE__) + "/files/not-a-spreadsheet.xls"
|
27
|
+
f=open(test_sheet,"rb")
|
28
|
+
assert_raise SysMODB::SpreadsheetExtractionException do
|
29
|
+
spreadsheet_to_xml(f)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate_against_schema xml
|
34
|
+
document = LibXML::XML::Document.string(xml)
|
35
|
+
schema = LibXML::XML::Schema.new(SCHEMA_FILE_PATH)
|
36
|
+
begin
|
37
|
+
document.validate_schema(schema)
|
38
|
+
rescue LibXML::XML::Error => e
|
39
|
+
puts xml
|
40
|
+
assert false,"Error validating against schema: #{e.message}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_csv_output
|
45
|
+
test_sheet = File.dirname(__FILE__) + "/files/test-spreadsheet.xls"
|
46
|
+
expected_file = File.dirname(__FILE__) + "/files/test-csv-output1.csv"
|
47
|
+
expected = open(expected_file,"rb").read
|
48
|
+
|
49
|
+
f=open(test_sheet,"rb")
|
50
|
+
csv = spreadsheet_to_csv(f,2)
|
51
|
+
assert_equal expected,csv
|
52
|
+
|
53
|
+
#try sheet as a string
|
54
|
+
f=open(test_sheet,"rb")
|
55
|
+
csv = spreadsheet_to_csv(f,"2")
|
56
|
+
assert_equal expected,csv
|
57
|
+
end
|
58
|
+
|
59
|
+
# def test_csv_output_trimmed
|
60
|
+
# test_sheet = File.dirname(__FILE__) + "/files/test-spreadsheet.xls"
|
61
|
+
# expected_file = File.dirname(__FILE__) + "/files/test-csv-output1-trimmed.csv"
|
62
|
+
# expected = open(expected_file,"rb").read
|
63
|
+
#
|
64
|
+
# f=open(test_sheet,"rb")
|
65
|
+
# csv = spreadsheet_to_csv(f,2,true)
|
66
|
+
# assert_equal expected,csv
|
67
|
+
# end
|
68
|
+
|
69
|
+
def test_for_segfault
|
70
|
+
test_sheet = File.dirname(__FILE__) + "/files/test-spreadsheet.xls"
|
71
|
+
10.times do |x|
|
72
|
+
f=open(test_sheet,"rb")
|
73
|
+
xml = spreadsheet_to_xml(f)
|
74
|
+
end
|
75
|
+
true
|
76
|
+
end
|
77
|
+
|
78
|
+
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: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 4
|
10
|
+
version: 0.6.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stuart Owen
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-08-15 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -71,9 +71,14 @@ files:
|
|
71
71
|
- jars/lib/poi-ooxml-3.7.jar
|
72
72
|
- jars/lib/poi-ooxml-schemas-3.7.jar
|
73
73
|
- jars/lib/xmlbeans-2.3.0.jar
|
74
|
-
- jars/simple-spreadsheet-extractor-0.6.
|
74
|
+
- jars/simple-spreadsheet-extractor-0.6.4.jar
|
75
75
|
- lib/simple-spreadsheet-extractor.rb
|
76
76
|
- simple-spreadsheet-extractor.gemspec
|
77
|
+
- test/files/not-a-spreadsheet.xls
|
78
|
+
- test/files/test-csv-output1-trimmed.csv
|
79
|
+
- test/files/test-csv-output1.csv
|
80
|
+
- test/files/test-spreadsheet.xls
|
81
|
+
- test/test_extraction.rb
|
77
82
|
has_rdoc: true
|
78
83
|
homepage: http://github.com/myGrid/simple-spreadsheet-extractor-gem
|
79
84
|
licenses: []
|
@@ -104,9 +109,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
109
|
requirements: []
|
105
110
|
|
106
111
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.
|
112
|
+
rubygems_version: 1.4.2
|
108
113
|
signing_key:
|
109
114
|
specification_version: 3
|
110
115
|
summary: Basic spreadsheet content extraction using Apache POI
|
111
|
-
test_files:
|
112
|
-
|
116
|
+
test_files:
|
117
|
+
- examples/example.rb
|
118
|
+
- test/test_extraction.rb
|