roo 2.7.0 → 2.8.3
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.
- checksums.yaml +5 -5
- data/.github/issue_template.md +16 -0
- data/.github/pull_request_template.md +14 -0
- data/.rubocop.yml +186 -0
- data/.travis.yml +12 -7
- data/CHANGELOG.md +53 -2
- data/LICENSE +2 -0
- data/README.md +29 -13
- data/lib/roo/base.rb +69 -61
- data/lib/roo/constants.rb +5 -3
- data/lib/roo/csv.rb +20 -12
- data/lib/roo/excelx/cell/base.rb +26 -12
- data/lib/roo/excelx/cell/boolean.rb +9 -6
- data/lib/roo/excelx/cell/date.rb +7 -7
- data/lib/roo/excelx/cell/datetime.rb +14 -18
- data/lib/roo/excelx/cell/empty.rb +3 -2
- data/lib/roo/excelx/cell/number.rb +35 -34
- data/lib/roo/excelx/cell/string.rb +3 -3
- data/lib/roo/excelx/cell/time.rb +4 -3
- data/lib/roo/excelx/cell.rb +10 -6
- data/lib/roo/excelx/comments.rb +3 -3
- data/lib/roo/excelx/coordinate.rb +11 -4
- data/lib/roo/excelx/extractor.rb +21 -3
- data/lib/roo/excelx/format.rb +38 -31
- data/lib/roo/excelx/images.rb +26 -0
- data/lib/roo/excelx/relationships.rb +12 -4
- data/lib/roo/excelx/shared.rb +10 -3
- data/lib/roo/excelx/shared_strings.rb +9 -15
- data/lib/roo/excelx/sheet.rb +49 -10
- data/lib/roo/excelx/sheet_doc.rb +89 -48
- data/lib/roo/excelx/styles.rb +3 -3
- data/lib/roo/excelx/workbook.rb +7 -3
- data/lib/roo/excelx.rb +42 -16
- data/lib/roo/helpers/default_attr_reader.rb +20 -0
- data/lib/roo/helpers/weak_instance_cache.rb +41 -0
- data/lib/roo/open_office.rb +8 -6
- data/lib/roo/spreadsheet.rb +1 -1
- data/lib/roo/utils.rb +70 -20
- data/lib/roo/version.rb +1 -1
- data/lib/roo.rb +4 -1
- data/roo.gemspec +13 -11
- data/spec/lib/roo/base_spec.rb +45 -3
- data/spec/lib/roo/excelx/relationships_spec.rb +43 -0
- data/spec/lib/roo/excelx/sheet_doc_spec.rb +11 -0
- data/spec/lib/roo/excelx_spec.rb +150 -31
- data/spec/lib/roo/strict_spec.rb +43 -0
- data/spec/lib/roo/utils_spec.rb +25 -3
- data/spec/lib/roo/weak_instance_cache_spec.rb +92 -0
- data/spec/lib/roo_spec.rb +0 -0
- data/spec/spec_helper.rb +1 -1
- data/test/excelx/cell/test_attr_reader_default.rb +72 -0
- data/test/excelx/cell/test_base.rb +5 -0
- data/test/excelx/cell/test_datetime.rb +6 -6
- data/test/excelx/cell/test_empty.rb +11 -0
- data/test/excelx/cell/test_number.rb +9 -0
- data/test/excelx/cell/test_string.rb +20 -0
- data/test/excelx/cell/test_time.rb +4 -4
- data/test/excelx/test_coordinate.rb +51 -0
- data/test/formatters/test_csv.rb +19 -2
- data/test/formatters/test_xml.rb +13 -9
- data/test/helpers/test_accessing_files.rb +60 -0
- data/test/helpers/test_comments.rb +43 -0
- data/test/helpers/test_formulas.rb +9 -0
- data/test/helpers/test_labels.rb +103 -0
- data/test/helpers/test_sheets.rb +55 -0
- data/test/helpers/test_styles.rb +62 -0
- data/test/roo/test_base.rb +182 -0
- data/test/roo/test_csv.rb +37 -1
- data/test/roo/test_excelx.rb +157 -13
- data/test/roo/test_open_office.rb +196 -33
- data/test/test_helper.rb +66 -22
- data/test/test_roo.rb +32 -881
- metadata +32 -14
- data/.github/ISSUE_TEMPLATE +0 -10
- data/Gemfile_ruby2 +0 -30
@@ -8,14 +8,14 @@ class TestRooOpenOffice < Minitest::Test
|
|
8
8
|
start_local_server(file, port) do
|
9
9
|
url = "#{local_server(port)}/#{file}"
|
10
10
|
|
11
|
-
|
12
|
-
assert_in_delta 0.001, 505.14,
|
11
|
+
workbook = roo_class.new(url, packed: :zip)
|
12
|
+
assert_in_delta 0.001, 505.14, workbook.cell("c", 33).to_f
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_download_uri_with_invalid_host
|
17
17
|
assert_raises(RuntimeError) do
|
18
|
-
roo_class.new("http://
|
18
|
+
roo_class.new("http://examples.com/file.ods")
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -30,9 +30,9 @@ class TestRooOpenOffice < Minitest::Test
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_openoffice_zipped
|
33
|
-
|
34
|
-
assert
|
35
|
-
assert_equal 'ist "e" im Nenner von H(s)',
|
33
|
+
workbook = roo_class.new(File.join(TESTDIR, "bode-v1.ods.zip"), packed: :zip)
|
34
|
+
assert workbook
|
35
|
+
assert_equal 'ist "e" im Nenner von H(s)', workbook.cell("b", 5)
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_should_raise_file_not_found_error
|
@@ -41,7 +41,6 @@ class TestRooOpenOffice < Minitest::Test
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
44
|
def test_file_warning_default_is_error
|
46
45
|
expected_message = "test/files/numbers1.xls is not an openoffice spreadsheet"
|
47
46
|
assert_raises(TypeError, expected_message) do
|
@@ -54,45 +53,44 @@ class TestRooOpenOffice < Minitest::Test
|
|
54
53
|
end
|
55
54
|
|
56
55
|
def test_file_warning_error
|
56
|
+
options = { packed: false, file_warning: :error }
|
57
|
+
|
57
58
|
assert_raises(TypeError) do
|
58
|
-
roo_class.new(File.join(TESTDIR, "numbers1.xls"),
|
59
|
-
packed: false,
|
60
|
-
file_warning: :error
|
61
|
-
)
|
59
|
+
roo_class.new(File.join(TESTDIR, "numbers1.xls"), options)
|
62
60
|
end
|
63
61
|
|
64
62
|
assert_raises(TypeError) do
|
65
|
-
roo_class.new(File.join(TESTDIR, "numbers1.xlsx"),
|
66
|
-
packed: false,
|
67
|
-
file_warning: :error)
|
63
|
+
roo_class.new(File.join(TESTDIR, "numbers1.xlsx"), options)
|
68
64
|
end
|
69
65
|
end
|
70
66
|
|
71
67
|
def test_file_warning_warning
|
72
68
|
assert_raises(ArgumentError) do
|
73
|
-
|
74
|
-
|
75
|
-
file_warning: :warning)
|
69
|
+
options = { packed: false, file_warning: :warning }
|
70
|
+
roo_class.new(File.join(TESTDIR, "numbers1.xlsx"), options)
|
76
71
|
end
|
77
72
|
end
|
78
73
|
|
79
74
|
def test_file_warning_ignore
|
80
|
-
|
81
|
-
|
82
|
-
file_warning: :ignore), "Should not throw an error"
|
75
|
+
options = { packed: false, file_warning: :ignore }
|
76
|
+
assert roo_class.new(File.join(TESTDIR, "type_openoffice.xlsx"), options), "Should not throw an error"
|
83
77
|
end
|
84
78
|
|
85
79
|
def test_encrypted_file
|
86
|
-
|
87
|
-
assert_equal "Hello World",
|
80
|
+
workbook = roo_class.new(File.join(TESTDIR, "encrypted-letmein.ods"), password: "letmein")
|
81
|
+
assert_equal "Hello World", workbook.cell("a", 1)
|
88
82
|
end
|
89
83
|
|
90
84
|
def test_encrypted_file_requires_password
|
91
|
-
assert_raises(ArgumentError)
|
85
|
+
assert_raises(ArgumentError) do
|
86
|
+
roo_class.new(File.join(TESTDIR, "encrypted-letmein.ods"))
|
87
|
+
end
|
92
88
|
end
|
93
89
|
|
94
90
|
def test_encrypted_file_with_incorrect_password
|
95
|
-
assert_raises(ArgumentError)
|
91
|
+
assert_raises(ArgumentError) do
|
92
|
+
roo_class.new(File.join(TESTDIR, "encrypted-letmein.ods"), password: "badpassword")
|
93
|
+
end
|
96
94
|
end
|
97
95
|
|
98
96
|
# 2011-08-11
|
@@ -104,16 +102,181 @@ class TestRooOpenOffice < Minitest::Test
|
|
104
102
|
# Bei den OpenOffice-Dateien ist in diesem Feld in der XML-
|
105
103
|
# Datei of: als Prefix enthalten, waehrend in dieser Datei
|
106
104
|
# irgendetwas mit oooc: als Prefix verwendet wird.
|
107
|
-
|
108
|
-
assert_equal
|
109
|
-
assert_equal
|
110
|
-
assert_equal
|
111
|
-
|
112
|
-
[1,5,
|
113
|
-
[2,5,
|
114
|
-
[3,5,
|
115
|
-
|
105
|
+
workbook = roo_class.new(File.join(TESTDIR, "dreimalvier.ods"))
|
106
|
+
assert_equal "=SUM([.A1:.D1])", workbook.formula("e", 1)
|
107
|
+
assert_equal "=SUM([.A2:.D2])", workbook.formula("e", 2)
|
108
|
+
assert_equal "=SUM([.A3:.D3])", workbook.formula("e", 3)
|
109
|
+
expected_formulas = [
|
110
|
+
[1, 5, "=SUM([.A1:.D1])"],
|
111
|
+
[2, 5, "=SUM([.A2:.D2])"],
|
112
|
+
[3, 5, "=SUM([.A3:.D3])"],
|
113
|
+
]
|
114
|
+
assert_equal expected_formulas, workbook.formulas
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_header_with_brackets_open_office
|
118
|
+
options = { name: "advanced_header", format: :openoffice }
|
119
|
+
with_each_spreadsheet(options) do |workbook|
|
120
|
+
parsed_head = workbook.parse(headers: true)
|
121
|
+
assert_equal "Date(yyyy-mm-dd)", workbook.cell("A", 1)
|
122
|
+
assert_equal parsed_head[0].keys, ["Date(yyyy-mm-dd)"]
|
123
|
+
assert_equal parsed_head[0].values, ["Date(yyyy-mm-dd)"]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_office_version
|
128
|
+
with_each_spreadsheet(name: "numbers1", format: :openoffice) do |workbook|
|
129
|
+
assert_equal "1.0", workbook.officeversion
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_bug_contiguous_cells
|
134
|
+
with_each_spreadsheet(name: "numbers1", format: :openoffice) do |workbook|
|
135
|
+
workbook.default_sheet = "Sheet4"
|
136
|
+
assert_equal Date.new(2007, 06, 16), workbook.cell("a", 1)
|
137
|
+
assert_equal 10, workbook.cell("b", 1)
|
138
|
+
assert_equal 10, workbook.cell("c", 1)
|
139
|
+
assert_equal 10, workbook.cell("d", 1)
|
140
|
+
assert_equal 10, workbook.cell("e", 1)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_italo_table
|
145
|
+
with_each_spreadsheet(name: "simple_spreadsheet_from_italo", format: :openoffice) do |workbook|
|
146
|
+
assert_equal "1", workbook.cell("A", 1)
|
147
|
+
assert_equal "1", workbook.cell("B", 1)
|
148
|
+
assert_equal "1", workbook.cell("C", 1)
|
149
|
+
assert_equal 1, workbook.cell("A", 2).to_i
|
150
|
+
assert_equal 2, workbook.cell("B", 2).to_i
|
151
|
+
assert_equal 1, workbook.cell("C", 2).to_i
|
152
|
+
assert_equal 1, workbook.cell("A", 3)
|
153
|
+
assert_equal 3, workbook.cell("B", 3)
|
154
|
+
assert_equal 1, workbook.cell("C", 3)
|
155
|
+
assert_equal "A", workbook.cell("A", 4)
|
156
|
+
assert_equal "A", workbook.cell("B", 4)
|
157
|
+
assert_equal "A", workbook.cell("C", 4)
|
158
|
+
assert_equal 0.01, workbook.cell("A", 5)
|
159
|
+
assert_equal 0.01, workbook.cell("B", 5)
|
160
|
+
assert_equal 0.01, workbook.cell("C", 5)
|
161
|
+
assert_equal 0.03, workbook.cell("a", 5) + workbook.cell("b", 5) + workbook.cell("c", 5)
|
162
|
+
|
163
|
+
# Cells values in row 1:
|
164
|
+
assert_equal "1:string", [workbook.cell(1, 1), workbook.celltype(1, 1)].join(":")
|
165
|
+
assert_equal "1:string", [workbook.cell(1, 2), workbook.celltype(1, 2)].join(":")
|
166
|
+
assert_equal "1:string", [workbook.cell(1, 3), workbook.celltype(1, 3)].join(":")
|
116
167
|
|
168
|
+
# Cells values in row 2:
|
169
|
+
assert_equal "1:string", [workbook.cell(2, 1), workbook.celltype(2, 1)].join(":")
|
170
|
+
assert_equal "2:string", [workbook.cell(2, 2), workbook.celltype(2, 2)].join(":")
|
171
|
+
assert_equal "1:string", [workbook.cell(2, 3), workbook.celltype(2, 3)].join(":")
|
172
|
+
|
173
|
+
# Cells values in row 3:
|
174
|
+
assert_equal "1:float", [workbook.cell(3, 1), workbook.celltype(3, 1)].join(":")
|
175
|
+
assert_equal "3:float", [workbook.cell(3, 2), workbook.celltype(3, 2)].join(":")
|
176
|
+
assert_equal "1:float", [workbook.cell(3, 3), workbook.celltype(3, 3)].join(":")
|
177
|
+
|
178
|
+
# Cells values in row 4:
|
179
|
+
assert_equal "A:string", [workbook.cell(4, 1), workbook.celltype(4, 1)].join(":")
|
180
|
+
assert_equal "A:string", [workbook.cell(4, 2), workbook.celltype(4, 2)].join(":")
|
181
|
+
assert_equal "A:string", [workbook.cell(4, 3), workbook.celltype(4, 3)].join(":")
|
182
|
+
|
183
|
+
# Cells values in row 5:
|
184
|
+
assert_equal "0.01:percentage", [workbook.cell(5, 1), workbook.celltype(5, 1)].join(":")
|
185
|
+
assert_equal "0.01:percentage", [workbook.cell(5, 2), workbook.celltype(5, 2)].join(":")
|
186
|
+
assert_equal "0.01:percentage", [workbook.cell(5, 3), workbook.celltype(5, 3)].join(":")
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_formula_openoffice
|
191
|
+
with_each_spreadsheet(name: "formula", format: :openoffice) do |workbook|
|
192
|
+
assert_equal 1, workbook.cell("A", 1)
|
193
|
+
assert_equal 2, workbook.cell("A", 2)
|
194
|
+
assert_equal 3, workbook.cell("A", 3)
|
195
|
+
assert_equal 4, workbook.cell("A", 4)
|
196
|
+
assert_equal 5, workbook.cell("A", 5)
|
197
|
+
assert_equal 6, workbook.cell("A", 6)
|
198
|
+
assert_equal 21, workbook.cell("A", 7)
|
199
|
+
assert_equal :formula, workbook.celltype("A", 7)
|
200
|
+
assert_equal "=[Sheet2.A1]", workbook.formula("C", 7)
|
201
|
+
assert_nil workbook.formula("A", 6)
|
202
|
+
expected_formulas = [
|
203
|
+
[7, 1, "=SUM([.A1:.A6])"],
|
204
|
+
[7, 2, "=SUM([.$A$1:.B6])"],
|
205
|
+
[7, 3, "=[Sheet2.A1]"],
|
206
|
+
[8, 2, "=SUM([.$A$1:.B7])"],
|
207
|
+
]
|
208
|
+
assert_equal expected_formulas, workbook.formulas(workbook.sheets.first)
|
209
|
+
|
210
|
+
# setting a cell
|
211
|
+
workbook.set("A", 15, 41)
|
212
|
+
assert_equal 41, workbook.cell("A", 15)
|
213
|
+
workbook.set("A", 16, "41")
|
214
|
+
assert_equal "41", workbook.cell("A", 16)
|
215
|
+
workbook.set("A", 17, 42.5)
|
216
|
+
assert_equal 42.5, workbook.cell("A", 17)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_bug_ric
|
221
|
+
with_each_spreadsheet(name: "ric", format: :openoffice) do |workbook|
|
222
|
+
assert workbook.empty?("A", 1)
|
223
|
+
assert workbook.empty?("B", 1)
|
224
|
+
assert workbook.empty?("C", 1)
|
225
|
+
assert workbook.empty?("D", 1)
|
226
|
+
expected = 1
|
227
|
+
letter = "e"
|
228
|
+
while letter <= "u"
|
229
|
+
assert_equal expected, workbook.cell(letter, 1)
|
230
|
+
letter.succ!
|
231
|
+
expected += 1
|
232
|
+
end
|
233
|
+
assert_equal "J", workbook.cell("v", 1)
|
234
|
+
assert_equal "P", workbook.cell("w", 1)
|
235
|
+
assert_equal "B", workbook.cell("x", 1)
|
236
|
+
assert_equal "All", workbook.cell("y", 1)
|
237
|
+
assert_equal 0, workbook.cell("a", 2)
|
238
|
+
assert workbook.empty?("b", 2)
|
239
|
+
assert workbook.empty?("c", 2)
|
240
|
+
assert workbook.empty?("d", 2)
|
241
|
+
assert_equal "B", workbook.cell("e", 2)
|
242
|
+
assert_equal "B", workbook.cell("f", 2)
|
243
|
+
assert_equal "B", workbook.cell("g", 2)
|
244
|
+
assert_equal "B", workbook.cell("h", 2)
|
245
|
+
assert_equal "B", workbook.cell("i", 2)
|
246
|
+
assert_equal "B", workbook.cell("j", 2)
|
247
|
+
assert_equal "B", workbook.cell("k", 2)
|
248
|
+
assert_equal "B", workbook.cell("l", 2)
|
249
|
+
assert_equal "B", workbook.cell("m", 2)
|
250
|
+
assert_equal "B", workbook.cell("n", 2)
|
251
|
+
assert_equal "B", workbook.cell("o", 2)
|
252
|
+
assert_equal "B", workbook.cell("p", 2)
|
253
|
+
assert_equal "B", workbook.cell("q", 2)
|
254
|
+
assert_equal "B", workbook.cell("r", 2)
|
255
|
+
assert_equal "B", workbook.cell("s", 2)
|
256
|
+
assert workbook.empty?("t", 2)
|
257
|
+
assert workbook.empty?("u", 2)
|
258
|
+
assert_equal 0, workbook.cell("v", 2)
|
259
|
+
assert_equal 0, workbook.cell("w", 2)
|
260
|
+
assert_equal 15, workbook.cell("x", 2)
|
261
|
+
assert_equal 15, workbook.cell("y", 2)
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_mehrteilig
|
266
|
+
with_each_spreadsheet(name: "Bibelbund1", format: :openoffice) do |workbook|
|
267
|
+
assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", workbook.cell(45, "A")
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_cell_openoffice_html_escape
|
272
|
+
with_each_spreadsheet(name: "html-escape", format: :openoffice) do |workbook|
|
273
|
+
assert_equal "'", workbook.cell(1, 1)
|
274
|
+
assert_equal "&", workbook.cell(2, 1)
|
275
|
+
assert_equal ">", workbook.cell(3, 1)
|
276
|
+
assert_equal "<", workbook.cell(4, 1)
|
277
|
+
assert_equal "`", workbook.cell(5, 1)
|
278
|
+
# test_openoffice_zipped will catch issues with "
|
279
|
+
end
|
117
280
|
end
|
118
281
|
|
119
282
|
def roo_class
|
data/test/test_helper.rb
CHANGED
@@ -1,28 +1,47 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
3
|
-
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require 'date'
|
2
|
+
require "simplecov"
|
3
|
+
require "tmpdir"
|
4
|
+
require "fileutils"
|
5
|
+
require "minitest/autorun"
|
6
|
+
require "shoulda"
|
7
|
+
require "timeout"
|
8
|
+
require "logger"
|
9
|
+
require "date"
|
11
10
|
|
12
11
|
# require gem files
|
13
|
-
require
|
12
|
+
require "roo"
|
14
13
|
require "minitest/reporters"
|
15
|
-
|
16
|
-
|
14
|
+
if ENV["USE_REPORTERS"]
|
15
|
+
Minitest::Reporters.use!(
|
16
|
+
[
|
17
|
+
Minitest::Reporters::DefaultReporter.new,
|
18
|
+
Minitest::Reporters::SpecReporter.new
|
19
|
+
]
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
TESTDIR = File.join(File.dirname(__FILE__), "files")
|
24
|
+
ROO_FORMATS = [
|
25
|
+
:excelx,
|
26
|
+
:excelxm,
|
27
|
+
:openoffice,
|
28
|
+
:libreoffice
|
29
|
+
]
|
30
|
+
|
31
|
+
require "helpers/test_accessing_files"
|
32
|
+
require "helpers/test_comments"
|
33
|
+
require "helpers/test_formulas"
|
34
|
+
require "helpers/test_labels"
|
35
|
+
require "helpers/test_sheets"
|
36
|
+
require "helpers/test_styles"
|
17
37
|
|
18
|
-
TESTDIR = File.join(File.dirname(__FILE__), 'files')
|
19
38
|
|
20
39
|
# very simple diff implementation
|
21
40
|
# output is an empty string if the files are equal
|
22
41
|
# otherwise differences a printen (not compatible to
|
23
42
|
# the diff command)
|
24
43
|
def file_diff(fn1,fn2)
|
25
|
-
result =
|
44
|
+
result = ""
|
26
45
|
File.open(fn1) do |f1|
|
27
46
|
File.open(fn2) do |f2|
|
28
47
|
while f1.eof? == false and f2.eof? == false
|
@@ -73,7 +92,7 @@ def start_local_server(filename, port = nil)
|
|
73
92
|
]
|
74
93
|
end
|
75
94
|
|
76
|
-
t = Thread.new { Rack::Handler::WEBrick.run web_server, Host:
|
95
|
+
t = Thread.new { Rack::Handler::WEBrick.run web_server, Host: "0.0.0.0", Port: port , Logger: WEBrick::BasicLog.new(nil,1) }
|
77
96
|
# give the app a chance to startup
|
78
97
|
sleep(0.2)
|
79
98
|
|
@@ -82,13 +101,6 @@ ensure
|
|
82
101
|
t.kill
|
83
102
|
end
|
84
103
|
|
85
|
-
ROO_FORMATS = [
|
86
|
-
:excelx,
|
87
|
-
:excelxm,
|
88
|
-
:openoffice,
|
89
|
-
:libreoffice
|
90
|
-
]
|
91
|
-
|
92
104
|
# call a block of code for each spreadsheet type
|
93
105
|
# and yield a reference to the roo object
|
94
106
|
def with_each_spreadsheet(options)
|
@@ -111,6 +123,15 @@ def with_each_spreadsheet(options)
|
|
111
123
|
end
|
112
124
|
end
|
113
125
|
|
126
|
+
def get_extension(oo)
|
127
|
+
case oo
|
128
|
+
when Roo::OpenOffice
|
129
|
+
".ods"
|
130
|
+
when Roo::Excelx
|
131
|
+
".xlsx"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
114
135
|
def fixture_filename(name, format)
|
115
136
|
case format
|
116
137
|
when :excelx
|
@@ -123,3 +144,26 @@ def fixture_filename(name, format)
|
|
123
144
|
raise ArgumentError, "unexpected format #{format}"
|
124
145
|
end
|
125
146
|
end
|
147
|
+
|
148
|
+
def skip_long_test
|
149
|
+
msg = "This is very slow, test use `LONG_RUN=true bundle exec rake` to run it"
|
150
|
+
skip(msg) unless ENV["LONG_RUN"]
|
151
|
+
end
|
152
|
+
|
153
|
+
def skip_jruby_incompatible_test
|
154
|
+
msg = "This test uses a feature incompatible with JRuby"
|
155
|
+
skip(msg) if defined?(JRUBY_VERSION)
|
156
|
+
end
|
157
|
+
|
158
|
+
def with_timezone(new_tz)
|
159
|
+
if new_tz
|
160
|
+
begin
|
161
|
+
prev_tz, ENV['TZ'] = ENV['TZ'], new_tz
|
162
|
+
yield
|
163
|
+
ensure
|
164
|
+
ENV['TZ'] = prev_tz
|
165
|
+
end
|
166
|
+
else
|
167
|
+
yield
|
168
|
+
end
|
169
|
+
end
|