roo 1.13.1 → 2.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +17 -0
- data/.github/issue_template.md +16 -0
- data/.github/pull_request_template.md +14 -0
- data/.github/workflows/pull-request.yml +15 -0
- data/.github/workflows/ruby.yml +34 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +186 -0
- data/.simplecov +4 -0
- data/CHANGELOG.md +702 -0
- data/Gemfile +18 -12
- data/Guardfile +23 -0
- data/LICENSE +5 -1
- data/README.md +328 -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 +317 -504
- data/lib/roo/constants.rb +7 -0
- data/lib/roo/csv.rb +141 -113
- data/lib/roo/errors.rb +11 -0
- data/lib/roo/excelx/cell/base.rb +108 -0
- data/lib/roo/excelx/cell/boolean.rb +30 -0
- data/lib/roo/excelx/cell/date.rb +28 -0
- data/lib/roo/excelx/cell/datetime.rb +107 -0
- data/lib/roo/excelx/cell/empty.rb +20 -0
- data/lib/roo/excelx/cell/number.rb +99 -0
- data/lib/roo/excelx/cell/string.rb +19 -0
- data/lib/roo/excelx/cell/time.rb +44 -0
- data/lib/roo/excelx/cell.rb +110 -0
- data/lib/roo/excelx/comments.rb +55 -0
- data/lib/roo/excelx/coordinate.rb +19 -0
- data/lib/roo/excelx/extractor.rb +39 -0
- data/lib/roo/excelx/format.rb +71 -0
- data/lib/roo/excelx/images.rb +26 -0
- data/lib/roo/excelx/relationships.rb +33 -0
- data/lib/roo/excelx/shared.rb +39 -0
- data/lib/roo/excelx/shared_strings.rb +151 -0
- data/lib/roo/excelx/sheet.rb +151 -0
- data/lib/roo/excelx/sheet_doc.rb +257 -0
- data/lib/roo/excelx/styles.rb +64 -0
- data/lib/roo/excelx/workbook.rb +64 -0
- data/lib/roo/excelx.rb +407 -601
- data/lib/roo/font.rb +17 -0
- data/lib/roo/formatters/base.rb +15 -0
- data/lib/roo/formatters/csv.rb +84 -0
- data/lib/roo/formatters/matrix.rb +23 -0
- data/lib/roo/formatters/xml.rb +31 -0
- data/lib/roo/formatters/yaml.rb +40 -0
- data/lib/roo/helpers/default_attr_reader.rb +20 -0
- data/lib/roo/helpers/weak_instance_cache.rb +41 -0
- data/lib/roo/libre_office.rb +4 -0
- data/lib/roo/link.rb +34 -0
- data/lib/roo/open_office.rb +631 -0
- data/lib/roo/spreadsheet.rb +28 -23
- data/lib/roo/tempdir.rb +24 -0
- data/lib/roo/utils.rb +128 -0
- data/lib/roo/version.rb +3 -0
- data/lib/roo.rb +26 -24
- data/roo.gemspec +29 -202
- data/spec/helpers.rb +5 -0
- data/spec/lib/roo/base_spec.rb +291 -3
- data/spec/lib/roo/csv_spec.rb +38 -11
- data/spec/lib/roo/excelx/cell/time_spec.rb +15 -0
- data/spec/lib/roo/excelx/format_spec.rb +7 -6
- 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 +682 -6
- data/spec/lib/roo/libreoffice_spec.rb +16 -6
- data/spec/lib/roo/openoffice_spec.rb +30 -8
- data/spec/lib/roo/spreadsheet_spec.rb +60 -12
- data/spec/lib/roo/strict_spec.rb +43 -0
- data/spec/lib/roo/utils_spec.rb +119 -0
- data/spec/lib/roo/weak_instance_cache_spec.rb +92 -0
- data/spec/lib/roo_spec.rb +0 -0
- data/spec/spec_helper.rb +7 -6
- data/test/all_ss.rb +12 -11
- data/test/excelx/cell/test_attr_reader_default.rb +72 -0
- data/test/excelx/cell/test_base.rb +68 -0
- data/test/excelx/cell/test_boolean.rb +36 -0
- data/test/excelx/cell/test_date.rb +38 -0
- data/test/excelx/cell/test_datetime.rb +45 -0
- data/test/excelx/cell/test_empty.rb +18 -0
- data/test/excelx/cell/test_number.rb +90 -0
- data/test/excelx/cell/test_string.rb +48 -0
- data/test/excelx/cell/test_time.rb +30 -0
- data/test/excelx/test_coordinate.rb +51 -0
- data/test/formatters/test_csv.rb +136 -0
- data/test/formatters/test_matrix.rb +76 -0
- data/test/formatters/test_xml.rb +78 -0
- data/test/formatters/test_yaml.rb +20 -0
- data/test/helpers/test_accessing_files.rb +81 -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 +88 -0
- data/test/roo/test_excelx.rb +360 -0
- data/test/roo/test_libre_office.rb +9 -0
- data/test/roo/test_open_office.rb +289 -0
- data/test/test_helper.rb +123 -59
- data/test/test_roo.rb +392 -2292
- metadata +153 -296
- data/CHANGELOG +0 -412
- 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/openoffice.rb +0 -496
- data/lib/roo/roo_rails_helper.rb +0 -83
- data/lib/roo/worksheet.rb +0 -18
- data/scripts/txt2html +0 -67
- 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/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/test/test_generic_spreadsheet.rb +0 -259
- 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
data/test/test_helper.rb
CHANGED
@@ -1,36 +1,47 @@
|
|
1
|
-
#
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require 'webmock/test_unit'
|
1
|
+
# encoding: utf-8
|
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
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
require "roo"
|
13
|
+
require "minitest/reporters"
|
14
|
+
if ENV["USE_REPORTERS"]
|
15
|
+
Minitest::Reporters.use!(
|
16
|
+
[
|
17
|
+
Minitest::Reporters::DefaultReporter.new,
|
18
|
+
Minitest::Reporters::SpecReporter.new
|
19
|
+
]
|
20
|
+
)
|
21
|
+
end
|
19
22
|
|
20
|
-
|
21
|
-
|
23
|
+
TESTDIR = File.join(File.dirname(__FILE__), "files")
|
24
|
+
ROO_FORMATS = [
|
25
|
+
:excelx,
|
26
|
+
:excelxm,
|
27
|
+
:openoffice,
|
28
|
+
:libreoffice
|
29
|
+
]
|
22
30
|
|
23
|
-
|
24
|
-
|
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"
|
25
37
|
|
26
|
-
DISPLAY_LOG = false
|
27
38
|
|
28
39
|
# very simple diff implementation
|
29
40
|
# output is an empty string if the files are equal
|
30
41
|
# otherwise differences a printen (not compatible to
|
31
42
|
# the diff command)
|
32
43
|
def file_diff(fn1,fn2)
|
33
|
-
result =
|
44
|
+
result = ""
|
34
45
|
File.open(fn1) do |f1|
|
35
46
|
File.open(fn2) do |f2|
|
36
47
|
while f1.eof? == false and f2.eof? == false
|
@@ -47,7 +58,7 @@ def file_diff(fn1,fn2)
|
|
47
58
|
if f2.eof? == false
|
48
59
|
while f2.eof? == false
|
49
60
|
line2 = f2.gets
|
50
|
-
result ">#{line2}\n"
|
61
|
+
result << ">#{line2}\n"
|
51
62
|
end
|
52
63
|
end
|
53
64
|
end
|
@@ -63,43 +74,96 @@ class File
|
|
63
74
|
end
|
64
75
|
end
|
65
76
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
#"
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
77
|
+
def local_server(port)
|
78
|
+
raise ArgumentError unless port.to_i > 0
|
79
|
+
"http://0.0.0.0:#{port}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def start_local_server(filename, port = nil)
|
83
|
+
require "rack"
|
84
|
+
content_type = filename.split(".").last
|
85
|
+
port ||= TEST_RACK_PORT
|
86
|
+
|
87
|
+
web_server = Proc.new do |env|
|
88
|
+
[
|
89
|
+
"200",
|
90
|
+
{ "Content-Type" => content_type },
|
91
|
+
[File.read("#{TESTDIR}/#{filename}")]
|
92
|
+
]
|
93
|
+
end
|
94
|
+
|
95
|
+
t = Thread.new { Rack::Handler::WEBrick.run web_server, Host: "0.0.0.0", Port: port , Logger: WEBrick::BasicLog.new(nil,1) }
|
96
|
+
# give the app a chance to startup
|
97
|
+
sleep(0.2)
|
98
|
+
|
99
|
+
yield
|
100
|
+
ensure
|
101
|
+
t.kill
|
102
|
+
end
|
103
|
+
|
104
|
+
# call a block of code for each spreadsheet type
|
105
|
+
# and yield a reference to the roo object
|
106
|
+
def with_each_spreadsheet(options)
|
107
|
+
if options[:format]
|
108
|
+
formats = Array(options[:format])
|
109
|
+
invalid_formats = formats - ROO_FORMATS
|
110
|
+
unless invalid_formats.empty?
|
111
|
+
raise "invalid spreadsheet types: #{invalid_formats.join(', ')}"
|
112
|
+
end
|
113
|
+
else
|
114
|
+
formats = ROO_FORMATS
|
115
|
+
end
|
116
|
+
formats.each do |format|
|
117
|
+
begin
|
118
|
+
yield Roo::Spreadsheet.open(File.join(TESTDIR,
|
119
|
+
fixture_filename(options[:name], format)))
|
120
|
+
rescue => e
|
121
|
+
raise e, "#{e.message} for #{format}", e.backtrace unless options[:ignore_errors]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def get_extension(oo)
|
127
|
+
case oo
|
128
|
+
when Roo::OpenOffice
|
129
|
+
".ods"
|
130
|
+
when Roo::Excelx
|
131
|
+
".xlsx"
|
100
132
|
end
|
133
|
+
end
|
101
134
|
|
102
|
-
|
103
|
-
|
135
|
+
def fixture_filename(name, format)
|
136
|
+
case format
|
137
|
+
when :excelx
|
138
|
+
"#{name}.xlsx"
|
139
|
+
when :excelxm
|
140
|
+
"#{name}.xlsm"
|
141
|
+
when :openoffice, :libreoffice
|
142
|
+
"#{name}.ods"
|
143
|
+
else
|
144
|
+
raise ArgumentError, "unexpected format #{format}"
|
145
|
+
end
|
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
|
104
168
|
end
|
105
169
|
end
|