roo 1.13.2 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +17 -0
- data/.github/ISSUE_TEMPLATE +10 -0
- data/.gitignore +11 -0
- data/.simplecov +4 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +626 -0
- data/Gemfile +17 -12
- data/Gemfile_ruby2 +30 -0
- data/Guardfile +23 -0
- data/LICENSE +3 -1
- data/README.md +285 -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 +298 -495
- data/lib/roo/constants.rb +5 -0
- data/lib/roo/csv.rb +127 -113
- data/lib/roo/errors.rb +11 -0
- data/lib/roo/excelx/cell/base.rb +94 -0
- data/lib/roo/excelx/cell/boolean.rb +27 -0
- data/lib/roo/excelx/cell/date.rb +28 -0
- data/lib/roo/excelx/cell/datetime.rb +111 -0
- data/lib/roo/excelx/cell/empty.rb +19 -0
- data/lib/roo/excelx/cell/number.rb +87 -0
- data/lib/roo/excelx/cell/string.rb +19 -0
- data/lib/roo/excelx/cell/time.rb +43 -0
- data/lib/roo/excelx/cell.rb +106 -0
- data/lib/roo/excelx/comments.rb +55 -0
- data/lib/roo/excelx/coordinate.rb +12 -0
- data/lib/roo/excelx/extractor.rb +21 -0
- data/lib/roo/excelx/format.rb +64 -0
- data/lib/roo/excelx/relationships.rb +25 -0
- data/lib/roo/excelx/shared.rb +32 -0
- data/lib/roo/excelx/shared_strings.rb +157 -0
- data/lib/roo/excelx/sheet.rb +112 -0
- data/lib/roo/excelx/sheet_doc.rb +211 -0
- data/lib/roo/excelx/styles.rb +64 -0
- data/lib/roo/excelx/workbook.rb +59 -0
- data/lib/roo/excelx.rb +376 -602
- 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/libre_office.rb +4 -0
- data/lib/roo/link.rb +34 -0
- data/lib/roo/open_office.rb +626 -0
- data/lib/roo/spreadsheet.rb +22 -23
- data/lib/roo/tempdir.rb +21 -0
- data/lib/roo/utils.rb +78 -0
- data/lib/roo/version.rb +3 -0
- data/lib/roo.rb +23 -24
- data/roo.gemspec +21 -204
- data/spec/helpers.rb +5 -0
- data/spec/lib/roo/base_spec.rb +229 -3
- data/spec/lib/roo/csv_spec.rb +38 -11
- data/spec/lib/roo/excelx/format_spec.rb +7 -6
- data/spec/lib/roo/excelx_spec.rb +510 -11
- 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/utils_spec.rb +106 -0
- data/spec/spec_helper.rb +7 -6
- data/test/all_ss.rb +12 -11
- data/test/excelx/cell/test_base.rb +63 -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 +7 -0
- data/test/excelx/cell/test_number.rb +74 -0
- data/test/excelx/cell/test_string.rb +28 -0
- data/test/excelx/cell/test_time.rb +30 -0
- data/test/formatters/test_csv.rb +119 -0
- data/test/formatters/test_matrix.rb +76 -0
- data/test/formatters/test_xml.rb +74 -0
- data/test/formatters/test_yaml.rb +20 -0
- data/test/roo/test_csv.rb +52 -0
- data/test/roo/test_excelx.rb +186 -0
- data/test/roo/test_libre_office.rb +9 -0
- data/test/roo/test_open_office.rb +126 -0
- data/test/test_helper.rb +73 -53
- data/test/test_roo.rb +1211 -2292
- metadata +119 -298
- 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/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/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/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,29 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'simplecov'
|
1
3
|
# require deps
|
2
4
|
require 'tmpdir'
|
3
5
|
require 'fileutils'
|
4
|
-
require '
|
6
|
+
require 'minitest/autorun'
|
5
7
|
require 'shoulda'
|
6
|
-
require 'fileutils'
|
7
8
|
require 'timeout'
|
8
9
|
require 'logger'
|
9
10
|
require 'date'
|
10
|
-
require 'webmock/test_unit'
|
11
11
|
|
12
12
|
# require gem files
|
13
|
-
require
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
13
|
+
require 'roo'
|
14
|
+
require "minitest/reporters"
|
15
|
+
Minitest::Reporters.use!([Minitest::Reporters::DefaultReporter.new,
|
16
|
+
Minitest::Reporters::SpecReporter.new]) unless defined? JRUBY_VERSION
|
25
17
|
|
26
|
-
|
18
|
+
TESTDIR = File.join(File.dirname(__FILE__), 'files')
|
27
19
|
|
28
20
|
# very simple diff implementation
|
29
21
|
# output is an empty string if the files are equal
|
@@ -47,7 +39,7 @@ def file_diff(fn1,fn2)
|
|
47
39
|
if f2.eof? == false
|
48
40
|
while f2.eof? == false
|
49
41
|
line2 = f2.gets
|
50
|
-
result ">#{line2}\n"
|
42
|
+
result << ">#{line2}\n"
|
51
43
|
end
|
52
44
|
end
|
53
45
|
end
|
@@ -63,43 +55,71 @@ class File
|
|
63
55
|
end
|
64
56
|
end
|
65
57
|
|
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
|
-
|
58
|
+
def local_server(port)
|
59
|
+
raise ArgumentError unless port.to_i > 0
|
60
|
+
"http://0.0.0.0:#{port}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def start_local_server(filename, port = nil)
|
64
|
+
require "rack"
|
65
|
+
content_type = filename.split(".").last
|
66
|
+
port ||= TEST_RACK_PORT
|
67
|
+
|
68
|
+
web_server = Proc.new do |env|
|
69
|
+
[
|
70
|
+
"200",
|
71
|
+
{ "Content-Type" => content_type },
|
72
|
+
[File.read("#{TESTDIR}/#{filename}")]
|
73
|
+
]
|
74
|
+
end
|
75
|
+
|
76
|
+
t = Thread.new { Rack::Handler::WEBrick.run web_server, Host: '0.0.0.0', Port: port , Logger: WEBrick::BasicLog.new(nil,1) }
|
77
|
+
# give the app a chance to startup
|
78
|
+
sleep(0.2)
|
79
|
+
|
80
|
+
yield
|
81
|
+
ensure
|
82
|
+
t.kill
|
83
|
+
end
|
84
|
+
|
85
|
+
ROO_FORMATS = [
|
86
|
+
:excelx,
|
87
|
+
:excelxm,
|
88
|
+
:openoffice,
|
89
|
+
:libreoffice
|
90
|
+
]
|
91
|
+
|
92
|
+
# call a block of code for each spreadsheet type
|
93
|
+
# and yield a reference to the roo object
|
94
|
+
def with_each_spreadsheet(options)
|
95
|
+
if options[:format]
|
96
|
+
formats = Array(options[:format])
|
97
|
+
invalid_formats = formats - ROO_FORMATS
|
98
|
+
unless invalid_formats.empty?
|
99
|
+
raise "invalid spreadsheet types: #{invalid_formats.join(', ')}"
|
100
|
+
end
|
101
|
+
else
|
102
|
+
formats = ROO_FORMATS
|
103
|
+
end
|
104
|
+
formats.each do |format|
|
105
|
+
begin
|
106
|
+
yield Roo::Spreadsheet.open(File.join(TESTDIR,
|
107
|
+
fixture_filename(options[:name], format)))
|
108
|
+
rescue => e
|
109
|
+
raise e, "#{e.message} for #{format}", e.backtrace unless options[:ignore_errors]
|
110
|
+
end
|
100
111
|
end
|
112
|
+
end
|
101
113
|
|
102
|
-
|
103
|
-
|
114
|
+
def fixture_filename(name, format)
|
115
|
+
case format
|
116
|
+
when :excelx
|
117
|
+
"#{name}.xlsx"
|
118
|
+
when :excelxm
|
119
|
+
"#{name}.xlsm"
|
120
|
+
when :openoffice, :libreoffice
|
121
|
+
"#{name}.ods"
|
122
|
+
else
|
123
|
+
raise ArgumentError, "unexpected format #{format}"
|
104
124
|
end
|
105
125
|
end
|