roo 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/lib/roo/base.rb +43 -19
- data/lib/roo/excelx.rb +390 -542
- data/lib/roo/excelx/cell.rb +77 -0
- data/lib/roo/excelx/comments.rb +9 -11
- data/lib/roo/excelx/extractor.rb +12 -10
- data/lib/roo/excelx/relationships.rb +13 -14
- data/lib/roo/excelx/shared_strings.rb +19 -22
- data/lib/roo/excelx/sheet.rb +107 -0
- data/lib/roo/excelx/sheet_doc.rb +98 -100
- data/lib/roo/excelx/styles.rb +42 -40
- data/lib/roo/excelx/workbook.rb +36 -36
- data/lib/roo/open_office.rb +4 -1
- data/lib/roo/version.rb +1 -1
- data/spec/lib/roo/excelx_spec.rb +36 -0
- data/spec/lib/roo/openoffice_spec.rb +11 -0
- data/test/test_generic_spreadsheet.rb +104 -78
- data/test/test_roo.rb +22 -1
- metadata +5 -4
- data/scripts/txt2html +0 -67
data/test/test_roo.rb
CHANGED
@@ -18,6 +18,7 @@
|
|
18
18
|
#STDERR.reopen "/dev/null","w"
|
19
19
|
|
20
20
|
require 'test_helper'
|
21
|
+
require 'stringio'
|
21
22
|
|
22
23
|
class TestRoo < Minitest::Test
|
23
24
|
|
@@ -63,7 +64,7 @@ class TestRoo < Minitest::Test
|
|
63
64
|
yield Roo::Spreadsheet.open(File.join(TESTDIR,
|
64
65
|
fixture_filename(options[:name], format)))
|
65
66
|
rescue => e
|
66
|
-
raise e, "#{e.message} for #{format}", e.backtrace
|
67
|
+
raise e, "#{e.message} for #{format}", e.backtrace unless options[:ignore_errors]
|
67
68
|
end
|
68
69
|
end
|
69
70
|
end
|
@@ -2063,5 +2064,25 @@ where the expected result is
|
|
2063
2064
|
end
|
2064
2065
|
end
|
2065
2066
|
|
2067
|
+
def test_open_stream
|
2068
|
+
return unless EXCELX
|
2069
|
+
file_contents = File.read File.join(TESTDIR, fixture_filename(:numbers1, :excelx))
|
2070
|
+
stream = StringIO.new(file_contents)
|
2071
|
+
xlsx = Roo::Excelx.new(stream)
|
2072
|
+
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], xlsx.sheets
|
2073
|
+
end
|
2066
2074
|
|
2075
|
+
def test_close
|
2076
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
2077
|
+
next unless (tempdir = oo.instance_variable_get('@tmpdir'))
|
2078
|
+
oo.close
|
2079
|
+
assert !File.exists?(tempdir), "Expected #{tempdir} to be cleaned up, but it still exists"
|
2080
|
+
end
|
2081
|
+
end
|
2082
|
+
|
2083
|
+
def test_cleanup_on_error
|
2084
|
+
old_temp_files = Dir.open(Dir.tmpdir).to_a
|
2085
|
+
with_each_spreadsheet(:name=>'non_existent_file', :ignore_errors=>true) do |oo|; end
|
2086
|
+
assert_equal Dir.open(Dir.tmpdir).to_a, old_temp_files
|
2087
|
+
end
|
2067
2088
|
end # class
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Preymesser
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-06-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: nokogiri
|
@@ -110,10 +110,12 @@ files:
|
|
110
110
|
- lib/roo/base.rb
|
111
111
|
- lib/roo/csv.rb
|
112
112
|
- lib/roo/excelx.rb
|
113
|
+
- lib/roo/excelx/cell.rb
|
113
114
|
- lib/roo/excelx/comments.rb
|
114
115
|
- lib/roo/excelx/extractor.rb
|
115
116
|
- lib/roo/excelx/relationships.rb
|
116
117
|
- lib/roo/excelx/shared_strings.rb
|
118
|
+
- lib/roo/excelx/sheet.rb
|
117
119
|
- lib/roo/excelx/sheet_doc.rb
|
118
120
|
- lib/roo/excelx/styles.rb
|
119
121
|
- lib/roo/excelx/workbook.rb
|
@@ -125,7 +127,6 @@ files:
|
|
125
127
|
- lib/roo/utils.rb
|
126
128
|
- lib/roo/version.rb
|
127
129
|
- roo.gemspec
|
128
|
-
- scripts/txt2html
|
129
130
|
- spec/fixtures/vcr_cassettes/google_drive.yml
|
130
131
|
- spec/fixtures/vcr_cassettes/google_drive_access_token.yml
|
131
132
|
- spec/fixtures/vcr_cassettes/google_drive_set.yml
|
@@ -162,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
163
|
version: '0'
|
163
164
|
requirements: []
|
164
165
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.4.
|
166
|
+
rubygems_version: 2.4.5
|
166
167
|
signing_key:
|
167
168
|
specification_version: 4
|
168
169
|
summary: Roo can access the contents of various spreadsheet files.
|
data/scripts/txt2html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'redcloth'
|
5
|
-
require 'syntax/convertors/html'
|
6
|
-
require 'erb'
|
7
|
-
require File.dirname(__FILE__) + '/../lib/roo/version.rb'
|
8
|
-
|
9
|
-
version = Roo::VERSION::STRING
|
10
|
-
download = 'http://rubyforge.org/projects/roo'
|
11
|
-
|
12
|
-
class Fixnum
|
13
|
-
def ordinal
|
14
|
-
# teens
|
15
|
-
return 'th' if (10..19).include?(self % 100)
|
16
|
-
# others
|
17
|
-
case self % 10
|
18
|
-
when 1: return 'st'
|
19
|
-
when 2: return 'nd'
|
20
|
-
when 3: return 'rd'
|
21
|
-
else return 'th'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class Time
|
27
|
-
def pretty
|
28
|
-
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def convert_syntax(syntax, source)
|
33
|
-
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
34
|
-
end
|
35
|
-
|
36
|
-
if ARGV.length >= 1
|
37
|
-
src, template = ARGV
|
38
|
-
template ||= File.dirname(__FILE__) + '/../website/template.rhtml'
|
39
|
-
|
40
|
-
else
|
41
|
-
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
42
|
-
exit!
|
43
|
-
end
|
44
|
-
|
45
|
-
template = ERB.new(File.open(template).read)
|
46
|
-
|
47
|
-
title = nil
|
48
|
-
body = nil
|
49
|
-
File.open(src) do |fsrc|
|
50
|
-
title_text = fsrc.readline
|
51
|
-
body_text = fsrc.read
|
52
|
-
syntax_items = []
|
53
|
-
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</>!m){
|
54
|
-
ident = syntax_items.length
|
55
|
-
element, syntax, source = $1, $2, $3
|
56
|
-
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
57
|
-
"syntax-temp-#{ident}"
|
58
|
-
}
|
59
|
-
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
60
|
-
body = RedCloth.new(body_text).to_html
|
61
|
-
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
62
|
-
end
|
63
|
-
stat = File.stat(src)
|
64
|
-
created = stat.ctime
|
65
|
-
modified = stat.mtime
|
66
|
-
|
67
|
-
$stdout << template.result(binding)
|