roo 1.13.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -0
- data/.simplecov +4 -0
- data/.travis.yml +13 -0
- data/CHANGELOG.md +500 -0
- data/Gemfile +16 -10
- data/Guardfile +24 -0
- data/LICENSE +3 -1
- data/README.md +254 -0
- data/Rakefile +23 -23
- data/examples/roo_soap_client.rb +28 -31
- data/examples/roo_soap_server.rb +4 -6
- data/examples/write_me.rb +9 -10
- data/lib/roo/base.rb +303 -388
- data/lib/roo/csv.rb +120 -113
- data/lib/roo/excelx/comments.rb +24 -0
- data/lib/roo/excelx/extractor.rb +20 -0
- data/lib/roo/excelx/relationships.rb +26 -0
- data/lib/roo/excelx/shared_strings.rb +40 -0
- data/lib/roo/excelx/sheet_doc.rb +202 -0
- data/lib/roo/excelx/styles.rb +62 -0
- data/lib/roo/excelx/workbook.rb +59 -0
- data/lib/roo/excelx.rb +452 -484
- data/lib/roo/font.rb +17 -0
- data/lib/roo/libre_office.rb +5 -0
- data/lib/roo/link.rb +15 -0
- data/lib/roo/{openoffice.rb → open_office.rb} +678 -496
- data/lib/roo/spreadsheet.rb +20 -23
- data/lib/roo/utils.rb +78 -0
- data/lib/roo/version.rb +3 -0
- data/lib/roo.rb +18 -24
- data/roo.gemspec +20 -204
- data/spec/lib/roo/base_spec.rb +1 -4
- data/spec/lib/roo/csv_spec.rb +21 -13
- data/spec/lib/roo/excelx/format_spec.rb +7 -6
- data/spec/lib/roo/excelx_spec.rb +388 -11
- data/spec/lib/roo/libreoffice_spec.rb +16 -6
- data/spec/lib/roo/openoffice_spec.rb +2 -8
- data/spec/lib/roo/spreadsheet_spec.rb +40 -12
- data/spec/lib/roo/utils_spec.rb +106 -0
- data/spec/spec_helper.rb +2 -1
- data/test/test_generic_spreadsheet.rb +19 -67
- data/test/test_helper.rb +9 -56
- data/test/test_roo.rb +252 -477
- metadata +63 -302
- data/CHANGELOG +0 -417
- data/Gemfile.lock +0 -78
- data/README.markdown +0 -126
- data/VERSION +0 -1
- data/lib/roo/excel.rb +0 -355
- data/lib/roo/excel2003xml.rb +0 -300
- data/lib/roo/google.rb +0 -292
- data/lib/roo/roo_rails_helper.rb +0 -83
- data/lib/roo/worksheet.rb +0 -18
- data/spec/lib/roo/excel2003xml_spec.rb +0 -15
- data/spec/lib/roo/excel_spec.rb +0 -17
- data/spec/lib/roo/google_spec.rb +0 -64
- data/test/files/1900_base.xls +0 -0
- data/test/files/1900_base.xlsx +0 -0
- data/test/files/1904_base.xls +0 -0
- data/test/files/1904_base.xlsx +0 -0
- data/test/files/Bibelbund.csv +0 -3741
- data/test/files/Bibelbund.ods +0 -0
- data/test/files/Bibelbund.xls +0 -0
- data/test/files/Bibelbund.xlsx +0 -0
- data/test/files/Bibelbund.xml +0 -62518
- data/test/files/Bibelbund1.ods +0 -0
- data/test/files/Pfand_from_windows_phone.xlsx +0 -0
- data/test/files/bad_excel_date.xls +0 -0
- data/test/files/bbu.ods +0 -0
- data/test/files/bbu.xls +0 -0
- data/test/files/bbu.xlsx +0 -0
- data/test/files/bbu.xml +0 -152
- data/test/files/bode-v1.ods.zip +0 -0
- data/test/files/bode-v1.xls.zip +0 -0
- data/test/files/boolean.csv +0 -2
- data/test/files/boolean.ods +0 -0
- data/test/files/boolean.xls +0 -0
- data/test/files/boolean.xlsx +0 -0
- data/test/files/boolean.xml +0 -112
- data/test/files/borders.ods +0 -0
- data/test/files/borders.xls +0 -0
- data/test/files/borders.xlsx +0 -0
- data/test/files/borders.xml +0 -144
- data/test/files/bug-numbered-sheet-names.xlsx +0 -0
- data/test/files/bug-row-column-fixnum-float.xls +0 -0
- data/test/files/bug-row-column-fixnum-float.xml +0 -127
- data/test/files/comments.ods +0 -0
- data/test/files/comments.xls +0 -0
- data/test/files/comments.xlsx +0 -0
- data/test/files/csvtypes.csv +0 -1
- data/test/files/datetime.ods +0 -0
- data/test/files/datetime.xls +0 -0
- data/test/files/datetime.xlsx +0 -0
- data/test/files/datetime.xml +0 -142
- data/test/files/datetime_floatconv.xls +0 -0
- data/test/files/datetime_floatconv.xml +0 -148
- data/test/files/dreimalvier.ods +0 -0
- data/test/files/emptysheets.ods +0 -0
- data/test/files/emptysheets.xls +0 -0
- data/test/files/emptysheets.xlsx +0 -0
- data/test/files/emptysheets.xml +0 -105
- data/test/files/excel2003.xml +0 -21140
- data/test/files/false_encoding.xls +0 -0
- data/test/files/false_encoding.xml +0 -132
- data/test/files/file_item_error.xlsx +0 -0
- data/test/files/formula.ods +0 -0
- data/test/files/formula.xls +0 -0
- data/test/files/formula.xlsx +0 -0
- data/test/files/formula.xml +0 -134
- data/test/files/formula_parse_error.xls +0 -0
- data/test/files/formula_parse_error.xml +0 -1833
- data/test/files/formula_string_error.xlsx +0 -0
- data/test/files/html-escape.ods +0 -0
- data/test/files/link.xls +0 -0
- data/test/files/link.xlsx +0 -0
- data/test/files/matrix.ods +0 -0
- data/test/files/matrix.xls +0 -0
- data/test/files/named_cells.ods +0 -0
- data/test/files/named_cells.xls +0 -0
- data/test/files/named_cells.xlsx +0 -0
- data/test/files/no_spreadsheet_file.txt +0 -1
- data/test/files/numbers1.csv +0 -18
- data/test/files/numbers1.ods +0 -0
- data/test/files/numbers1.xls +0 -0
- data/test/files/numbers1.xlsx +0 -0
- data/test/files/numbers1.xml +0 -312
- data/test/files/numeric-link.xlsx +0 -0
- data/test/files/only_one_sheet.ods +0 -0
- data/test/files/only_one_sheet.xls +0 -0
- data/test/files/only_one_sheet.xlsx +0 -0
- data/test/files/only_one_sheet.xml +0 -67
- data/test/files/paragraph.ods +0 -0
- data/test/files/paragraph.xls +0 -0
- data/test/files/paragraph.xlsx +0 -0
- data/test/files/paragraph.xml +0 -127
- data/test/files/prova.xls +0 -0
- data/test/files/ric.ods +0 -0
- data/test/files/simple_spreadsheet.ods +0 -0
- data/test/files/simple_spreadsheet.xls +0 -0
- data/test/files/simple_spreadsheet.xlsx +0 -0
- data/test/files/simple_spreadsheet.xml +0 -225
- data/test/files/simple_spreadsheet_from_italo.ods +0 -0
- data/test/files/simple_spreadsheet_from_italo.xls +0 -0
- data/test/files/simple_spreadsheet_from_italo.xml +0 -242
- data/test/files/so_datetime.csv +0 -7
- data/test/files/style.ods +0 -0
- data/test/files/style.xls +0 -0
- data/test/files/style.xlsx +0 -0
- data/test/files/style.xml +0 -154
- data/test/files/time-test.csv +0 -2
- data/test/files/time-test.ods +0 -0
- data/test/files/time-test.xls +0 -0
- data/test/files/time-test.xlsx +0 -0
- data/test/files/time-test.xml +0 -131
- data/test/files/type_excel.ods +0 -0
- data/test/files/type_excel.xlsx +0 -0
- data/test/files/type_excelx.ods +0 -0
- data/test/files/type_excelx.xls +0 -0
- data/test/files/type_openoffice.xls +0 -0
- data/test/files/type_openoffice.xlsx +0 -0
- data/test/files/whitespace.ods +0 -0
- data/test/files/whitespace.xls +0 -0
- data/test/files/whitespace.xlsx +0 -0
- data/test/files/whitespace.xml +0 -184
- data/test/rm_sub_test.rb +0 -12
- data/test/rm_test.rb +0 -7
- data/website/index.html +0 -385
- data/website/index.txt +0 -423
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -130
- data/website/template.rhtml +0 -48
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require File.dirname(__FILE__) + '/test_helper'
|
3
3
|
|
4
|
-
class TestBase < Test
|
4
|
+
class TestBase < Minitest::Test
|
5
5
|
|
6
6
|
def setup
|
7
7
|
@klass = Class.new(Roo::Base) do
|
@@ -15,12 +15,12 @@ class TestBase < Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def cell(row, col, sheet=nil)
|
18
|
-
sheet ||=
|
18
|
+
sheet ||= default_sheet
|
19
19
|
@cell[sheet][[row,col]]
|
20
20
|
end
|
21
21
|
|
22
22
|
def celltype(row, col, sheet=nil)
|
23
|
-
sheet ||=
|
23
|
+
sheet ||= default_sheet
|
24
24
|
@cell_type[sheet][[row,col]]
|
25
25
|
end
|
26
26
|
|
@@ -32,79 +32,24 @@ class TestBase < Test::Unit::TestCase
|
|
32
32
|
setup_test_sheet(@oo)
|
33
33
|
end
|
34
34
|
|
35
|
-
context 'Roo::Base.
|
36
|
-
should "
|
37
|
-
assert_equal
|
38
|
-
assert_equal
|
35
|
+
context 'private method Roo::Base.uri?(filename)' do
|
36
|
+
should "return true when passed a filename starts with http(s)://" do
|
37
|
+
assert_equal true, @oo.send(:uri?, 'http://example.com/')
|
38
|
+
assert_equal true, @oo.send(:uri?, 'https://example.com/')
|
39
39
|
end
|
40
40
|
|
41
|
-
should "
|
42
|
-
assert_equal
|
41
|
+
should "return false when passed a filename which does not start with http(s)://" do
|
42
|
+
assert_equal false, @oo.send(:uri?, 'example.com')
|
43
43
|
end
|
44
44
|
|
45
|
-
should "
|
46
|
-
assert_equal
|
47
|
-
assert_equal 27, Roo::Base.letter_to_number('aA')
|
48
|
-
assert_equal 27, Roo::Base.letter_to_number('Aa')
|
49
|
-
assert_equal 27, Roo::Base.letter_to_number('aa')
|
50
|
-
end
|
51
|
-
|
52
|
-
should "give us the correct value for 'AB'" do
|
53
|
-
assert_equal 28, Roo::Base.letter_to_number('AB')
|
54
|
-
end
|
55
|
-
|
56
|
-
should "give us the correct value for 'AZ'" do
|
57
|
-
assert_equal 26*2, Roo::Base.letter_to_number('AZ')
|
58
|
-
end
|
59
|
-
|
60
|
-
should "give us the correct value for 'BZ'" do
|
61
|
-
assert_equal 26*3, Roo::Base.letter_to_number('BZ')
|
62
|
-
end
|
63
|
-
|
64
|
-
should "give us the correct value for 'ZZ'" do
|
65
|
-
assert_equal 26**2 + 26,Roo::Base.letter_to_number('ZZ')
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "Roo::Base.number_to_letter" do
|
70
|
-
Roo::Base::LETTERS.each_with_index do |l,i|
|
71
|
-
should "return '#{l}' when passed #{i+1}" do
|
72
|
-
assert_equal l,Roo::Base.number_to_letter(i+1)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
should "return 'AA' when passed 27" do
|
77
|
-
assert_equal 'AA',Roo::Base.number_to_letter(27)
|
78
|
-
end
|
79
|
-
|
80
|
-
should "return 'AZ' when passed #{26*2}" do
|
81
|
-
assert_equal 'AZ', Roo::Base.number_to_letter(26*2)
|
82
|
-
end
|
83
|
-
|
84
|
-
should "return 'BZ' when passed #{26*3}" do
|
85
|
-
assert_equal 'BZ', Roo::Base.number_to_letter(26*3)
|
86
|
-
end
|
87
|
-
|
88
|
-
should "return 'ZZ' when passed #{26**2 + 26}" do
|
89
|
-
assert_equal 'ZZ',Roo::Base.number_to_letter(26**2 + 26)
|
90
|
-
end
|
91
|
-
|
92
|
-
should "return 'AAA' when passed #{26**2 + 27}" do
|
93
|
-
assert_equal 'AAA',Roo::Base.number_to_letter(26**2 + 27)
|
94
|
-
end
|
95
|
-
|
96
|
-
should "return 'ZZZ' when passed #{26**3 + 26**2 + 26}" do
|
97
|
-
assert_equal 'ZZZ',Roo::Base.number_to_letter(26**3 + 26**2 + 26)
|
98
|
-
end
|
99
|
-
|
100
|
-
should "return the correct letter when passed a Float" do
|
101
|
-
assert_equal 'A',Roo::Base.number_to_letter(1.0)
|
45
|
+
should "return false when passed non-String object such as Tempfile" do
|
46
|
+
assert_equal false, @oo.send(:uri?, Tempfile.new('test'))
|
102
47
|
end
|
103
48
|
end
|
104
49
|
|
105
50
|
def test_setting_invalid_type_does_not_update_cell
|
106
51
|
@oo.set(1,1,1)
|
107
|
-
|
52
|
+
assert_raises(ArgumentError){@oo.set(1,1, :invalid_type)}
|
108
53
|
assert_equal 1, @oo.cell(1,1)
|
109
54
|
assert_equal :float, @oo.celltype(1,1)
|
110
55
|
end
|
@@ -174,6 +119,10 @@ class TestBase < Test::Unit::TestCase
|
|
174
119
|
def test_to_csv
|
175
120
|
assert_equal expected_csv,@oo.to_csv
|
176
121
|
end
|
122
|
+
|
123
|
+
def test_to_csv_with_separator
|
124
|
+
assert_equal expected_csv_with_semicolons,@oo.to_csv(nil, ';')
|
125
|
+
end
|
177
126
|
protected
|
178
127
|
def setup_test_sheet(workbook=nil)
|
179
128
|
workbook ||= @oo
|
@@ -256,4 +205,7 @@ protected
|
|
256
205
|
def expected_csv
|
257
206
|
",,,,,,\n,,,,,,\n,,,,,,\n,,,,,,\n1961-11-21,,,,,,\n,,,,,,\n,,,,,,\n,,\"thisisc8\",,,,\"thisisg8\"\n,,,,,,\n,,,,,,\n,,,,,,\n41,42,43,44,45,,\n,,,,,,\n,,,,,,\n,,43,44,45,,\n,,\"dreiundvierzig\",\"vierundvierzig\",\"fuenfundvierzig\",,\n"
|
258
207
|
end
|
208
|
+
def expected_csv_with_semicolons
|
209
|
+
expected_csv.gsub /\,/, ';'
|
210
|
+
end
|
259
211
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,30 +1,20 @@
|
|
1
|
+
require 'simplecov'
|
1
2
|
# require deps
|
2
3
|
require 'tmpdir'
|
3
4
|
require 'fileutils'
|
4
|
-
require '
|
5
|
+
require 'minitest/autorun'
|
5
6
|
require 'shoulda'
|
6
7
|
require 'fileutils'
|
7
8
|
require 'timeout'
|
8
9
|
require 'logger'
|
9
10
|
require 'date'
|
10
|
-
require 'webmock/
|
11
|
+
require 'webmock/minitest'
|
11
12
|
|
12
13
|
# require gem files
|
13
|
-
require
|
14
|
+
require 'roo'
|
14
15
|
|
15
16
|
TESTDIR = File.join(File.dirname(__FILE__), 'files')
|
16
17
|
|
17
|
-
LOG_DIR = File.join(File.dirname(__FILE__),'../log')
|
18
|
-
FileUtils.mkdir_p(LOG_DIR)
|
19
|
-
|
20
|
-
LOG_FILE = File.join(LOG_DIR,'roo_test.log')
|
21
|
-
$log = Logger.new(LOG_FILE)
|
22
|
-
|
23
|
-
#$log.level = Logger::WARN
|
24
|
-
$log.level = Logger::DEBUG
|
25
|
-
|
26
|
-
DISPLAY_LOG = false
|
27
|
-
|
28
18
|
# very simple diff implementation
|
29
19
|
# output is an empty string if the files are equal
|
30
20
|
# otherwise differences a printen (not compatible to
|
@@ -47,7 +37,7 @@ def file_diff(fn1,fn2)
|
|
47
37
|
if f2.eof? == false
|
48
38
|
while f2.eof? == false
|
49
39
|
line2 = f2.gets
|
50
|
-
result ">#{line2}\n"
|
40
|
+
result << ">#{line2}\n"
|
51
41
|
end
|
52
42
|
end
|
53
43
|
end
|
@@ -55,6 +45,10 @@ def file_diff(fn1,fn2)
|
|
55
45
|
result
|
56
46
|
end
|
57
47
|
|
48
|
+
def yaml_entry(row,col,type,value)
|
49
|
+
"cell_#{row}_#{col}: \n row: #{row} \n col: #{col} \n celltype: #{type} \n value: #{value} \n"
|
50
|
+
end
|
51
|
+
|
58
52
|
class File
|
59
53
|
def File.delete_if_exist(filename)
|
60
54
|
if File.exist?(filename)
|
@@ -62,44 +56,3 @@ class File
|
|
62
56
|
end
|
63
57
|
end
|
64
58
|
end
|
65
|
-
|
66
|
-
class Test::Unit::TestCase
|
67
|
-
def key_of(spreadsheetname)
|
68
|
-
{
|
69
|
-
#'formula' => 'rt4Pw1WmjxFtyfrqqy94wPw',
|
70
|
-
'formula' => 'o10837434939102457526.3022866619437760118',
|
71
|
-
#"write.me" => 'r6m7HFlUOwst0RTUTuhQ0Ow',
|
72
|
-
"write.me" => '0AkCuGANLc3jFcHR1NmJiYWhOWnBZME4wUnJ4UWJXZHc',
|
73
|
-
#'numbers1' => "rYraCzjxTtkxw1NxHJgDU8Q",
|
74
|
-
'numbers1' => 'o10837434939102457526.4784396906364855777',
|
75
|
-
#'borders' => "r_nLYMft6uWg_PT9Rc2urXw",
|
76
|
-
'borders' => "o10837434939102457526.664868920231926255",
|
77
|
-
#'simple_spreadsheet' => "r3aMMCBCA153TmU_wyIaxfw",
|
78
|
-
'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
|
79
|
-
'testnichtvorhandenBibelbund.ods' => "invalidkeyforanyspreadsheet", # !!! intentionally false key
|
80
|
-
#"only_one_sheet" => "rqRtkcPJ97nhQ0m9ksDw2rA",
|
81
|
-
"only_one_sheet" => "o10837434939102457526.762705759906130135",
|
82
|
-
#'time-test' => 'r2XfDBJMrLPjmuLrPQQrEYw',
|
83
|
-
'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
|
84
|
-
#'datetime' => "r2kQpXWr6xOSUpw9MyXavYg",
|
85
|
-
'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
|
86
|
-
'whitespace' => "rZyQaoFebVGeHKzjG6e9gRQ",
|
87
|
-
'matrix' => '0AkCuGANLc3jFdHY3cWtYUkM4bVdadjZ5VGpfTzFEUEE',
|
88
|
-
# 'numbers1' => "o10837434939102457526.4784396906364855777",
|
89
|
-
# 'borders' => "o10837434939102457526.664868920231926255",
|
90
|
-
# 'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
|
91
|
-
# 'testnichtvorhandenBibelbund.ods' => "invalidkeyforanyspreadsheet", # !!! intentionally false key
|
92
|
-
# "only_one_sheet" => "o10837434939102457526.762705759906130135",
|
93
|
-
# "write.me" => 'ptu6bbahNZpY0N0RrxQbWdw&hl',
|
94
|
-
# 'formula' => 'o10837434939102457526.3022866619437760118',
|
95
|
-
# 'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
|
96
|
-
# 'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
|
97
|
-
}.fetch(spreadsheetname)
|
98
|
-
rescue KeyError
|
99
|
-
raise "unknown spreadsheetname: #{spreadsheetname}"
|
100
|
-
end
|
101
|
-
|
102
|
-
def yaml_entry(row,col,type,value)
|
103
|
-
"cell_#{row}_#{col}: \n row: #{row} \n col: #{col} \n celltype: #{type} \n value: #{value} \n"
|
104
|
-
end
|
105
|
-
end
|