roo 1.13.2 → 2.0.0beta1
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 +21 -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.rb +18 -24
- data/lib/roo/base.rb +303 -388
- data/lib/roo/csv.rb +120 -113
- data/lib/roo/excelx.rb +452 -484
- 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/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/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/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
data/lib/roo/spreadsheet.rb
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
module Roo
|
2
2
|
class Spreadsheet
|
3
3
|
class << self
|
4
|
-
def open(
|
5
|
-
|
4
|
+
def open(path, options = {})
|
5
|
+
path = path.respond_to?(:path) ? path.path : path
|
6
|
+
extension = extension_for(path, options)
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
begin
|
9
|
+
Roo::CLASS_FOR_EXTENSION.fetch(extension).new(path, options)
|
10
|
+
rescue KeyError
|
11
|
+
raise ArgumentError,
|
12
|
+
"Can't detect the type of #{path} - please use the :extension option to declare its type."
|
13
|
+
end
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
when
|
21
|
-
|
22
|
-
|
23
|
-
Roo::Excel2003XML.new(file, options)
|
24
|
-
when ''
|
25
|
-
Roo::Google.new(file, options)
|
26
|
-
when '.csv'
|
27
|
-
Roo::CSV.new(file, options)
|
16
|
+
def extension_for(path, options)
|
17
|
+
case (extension = options.delete(:extension))
|
18
|
+
when ::Symbol
|
19
|
+
options[:file_warning] = :ignore
|
20
|
+
extension
|
21
|
+
when ::String
|
22
|
+
options[:file_warning] = :ignore
|
23
|
+
extension.tr('.', '').downcase.to_sym
|
28
24
|
else
|
29
|
-
|
25
|
+
res = ::File.extname((path =~ ::URI.regexp) ? ::URI.parse(::URI.encode(path)).path : path)
|
26
|
+
res.tr('.', '').downcase.to_sym
|
30
27
|
end
|
31
28
|
end
|
32
29
|
end
|
data/lib/roo/utils.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
module Roo
|
2
|
+
module Utils
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def split_coordinate(str)
|
6
|
+
@split_coordinate ||= {}
|
7
|
+
|
8
|
+
@split_coordinate[str] ||= begin
|
9
|
+
letter, number = split_coord(str)
|
10
|
+
x = letter_to_number(letter)
|
11
|
+
y = number
|
12
|
+
[y, x]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
alias_method :ref_to_key, :split_coordinate
|
17
|
+
|
18
|
+
def split_coord(s)
|
19
|
+
if s =~ /([a-zA-Z]+)([0-9]+)/
|
20
|
+
letter = Regexp.last_match[1]
|
21
|
+
number = Regexp.last_match[2].to_i
|
22
|
+
else
|
23
|
+
fail ArgumentError
|
24
|
+
end
|
25
|
+
[letter, number]
|
26
|
+
end
|
27
|
+
|
28
|
+
# convert a number to something like 'AB' (1 => 'A', 2 => 'B', ...)
|
29
|
+
def number_to_letter(num)
|
30
|
+
results = []
|
31
|
+
num = num.to_i
|
32
|
+
|
33
|
+
while (num > 0)
|
34
|
+
mod = (num - 1) % 26
|
35
|
+
results = [(65 + mod).chr] + results
|
36
|
+
num = ((num - mod) / 26)
|
37
|
+
end
|
38
|
+
|
39
|
+
results.join
|
40
|
+
end
|
41
|
+
|
42
|
+
def letter_to_number(letters)
|
43
|
+
@letter_to_number ||= {}
|
44
|
+
@letter_to_number[letters] ||= begin
|
45
|
+
result = 0
|
46
|
+
|
47
|
+
# :bytes method returns an enumerator in 1.9.3 and an array in 2.0+
|
48
|
+
letters.bytes.to_a.map{|b| b > 96 ? b - 96 : b - 64 }.reverse.each_with_index{ |num, i| result += num * 26 ** i }
|
49
|
+
|
50
|
+
result
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Compute upper bound for cells in a given cell range.
|
55
|
+
def num_cells_in_range(str)
|
56
|
+
cells = str.split(':')
|
57
|
+
return 1 if cells.count == 1
|
58
|
+
raise ArgumentError.new("invalid range string: #{str}. Supported range format 'A1:B2'") if cells.count != 2
|
59
|
+
x1, y1 = split_coordinate(cells[0])
|
60
|
+
x2, y2 = split_coordinate(cells[1])
|
61
|
+
(x2 - (x1 - 1)) * (y2 - (y1 - 1))
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_xml(path)
|
65
|
+
::File.open(path, 'rb') do |file|
|
66
|
+
::Nokogiri::XML(file)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Yield each element of a given type ('row', 'c', etc.) to caller
|
71
|
+
def each_element(path, elements)
|
72
|
+
Nokogiri::XML::Reader(::File.open(path, 'rb'), nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).each do |node|
|
73
|
+
next unless node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT && Array(elements).include?(node.name)
|
74
|
+
yield Nokogiri::XML(node.outer_xml).root if block_given?
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/roo/version.rb
ADDED
data/roo.gemspec
CHANGED
@@ -1,209 +1,25 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'roo/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'roo'
|
8
|
+
spec.version = Roo::VERSION
|
9
|
+
spec.authors = ['Thomas Preymesser', 'Hugh McGowan', 'Ben Woosley', 'Oleksandr Simonov']
|
10
|
+
spec.email = ['ruby.ruby.ruby.roo@gmail.com', 'oleksandr@simonov.me']
|
11
|
+
spec.summary = 'Roo can access the contents of various spreadsheet files.'
|
12
|
+
spec.description = "Roo can access the contents of various spreadsheet files. It can handle\n* OpenOffice\n* Excelx\n* LibreOffice\n* CSV"
|
13
|
+
spec.homepage = 'http://github.com/roo-rb/roo'
|
14
|
+
spec.license = 'MIT'
|
9
15
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
s.description = "Roo can access the contents of various spreadsheet files. It can handle\n* OpenOffice\n* Excel\n* Google spreadsheets\n* Excelx\n* LibreOffice\n* CSV"
|
14
|
-
s.email = "ruby.ruby.ruby.roo@gmail.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.markdown"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
"CHANGELOG",
|
21
|
-
"Gemfile",
|
22
|
-
"Gemfile.lock",
|
23
|
-
"LICENSE",
|
24
|
-
"README.markdown",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"examples/roo_soap_client.rb",
|
28
|
-
"examples/roo_soap_server.rb",
|
29
|
-
"examples/write_me.rb",
|
30
|
-
"lib/roo.rb",
|
31
|
-
"lib/roo/base.rb",
|
32
|
-
"lib/roo/csv.rb",
|
33
|
-
"lib/roo/excel.rb",
|
34
|
-
"lib/roo/excel2003xml.rb",
|
35
|
-
"lib/roo/excelx.rb",
|
36
|
-
"lib/roo/google.rb",
|
37
|
-
"lib/roo/openoffice.rb",
|
38
|
-
"lib/roo/roo_rails_helper.rb",
|
39
|
-
"lib/roo/spreadsheet.rb",
|
40
|
-
"lib/roo/worksheet.rb",
|
41
|
-
"roo.gemspec",
|
42
|
-
"scripts/txt2html",
|
43
|
-
"spec/fixtures/vcr_cassettes/google_drive.yml",
|
44
|
-
"spec/fixtures/vcr_cassettes/google_drive_access_token.yml",
|
45
|
-
"spec/fixtures/vcr_cassettes/google_drive_set.yml",
|
46
|
-
"spec/lib/roo/base_spec.rb",
|
47
|
-
"spec/lib/roo/csv_spec.rb",
|
48
|
-
"spec/lib/roo/excel2003xml_spec.rb",
|
49
|
-
"spec/lib/roo/excel_spec.rb",
|
50
|
-
"spec/lib/roo/excelx/format_spec.rb",
|
51
|
-
"spec/lib/roo/excelx_spec.rb",
|
52
|
-
"spec/lib/roo/google_spec.rb",
|
53
|
-
"spec/lib/roo/libreoffice_spec.rb",
|
54
|
-
"spec/lib/roo/openoffice_spec.rb",
|
55
|
-
"spec/lib/roo/spreadsheet_spec.rb",
|
56
|
-
"spec/spec_helper.rb",
|
57
|
-
"test/all_ss.rb",
|
58
|
-
"test/files/1900_base.xls",
|
59
|
-
"test/files/1900_base.xlsx",
|
60
|
-
"test/files/1904_base.xls",
|
61
|
-
"test/files/1904_base.xlsx",
|
62
|
-
"test/files/Bibelbund.csv",
|
63
|
-
"test/files/Bibelbund.ods",
|
64
|
-
"test/files/Bibelbund.xls",
|
65
|
-
"test/files/Bibelbund.xlsx",
|
66
|
-
"test/files/Bibelbund.xml",
|
67
|
-
"test/files/Bibelbund1.ods",
|
68
|
-
"test/files/Pfand_from_windows_phone.xlsx",
|
69
|
-
"test/files/bad_excel_date.xls",
|
70
|
-
"test/files/bbu.ods",
|
71
|
-
"test/files/bbu.xls",
|
72
|
-
"test/files/bbu.xlsx",
|
73
|
-
"test/files/bbu.xml",
|
74
|
-
"test/files/bode-v1.ods.zip",
|
75
|
-
"test/files/bode-v1.xls.zip",
|
76
|
-
"test/files/boolean.csv",
|
77
|
-
"test/files/boolean.ods",
|
78
|
-
"test/files/boolean.xls",
|
79
|
-
"test/files/boolean.xlsx",
|
80
|
-
"test/files/boolean.xml",
|
81
|
-
"test/files/borders.ods",
|
82
|
-
"test/files/borders.xls",
|
83
|
-
"test/files/borders.xlsx",
|
84
|
-
"test/files/borders.xml",
|
85
|
-
"test/files/bug-numbered-sheet-names.xlsx",
|
86
|
-
"test/files/bug-row-column-fixnum-float.xls",
|
87
|
-
"test/files/bug-row-column-fixnum-float.xml",
|
88
|
-
"test/files/comments.ods",
|
89
|
-
"test/files/comments.xls",
|
90
|
-
"test/files/comments.xlsx",
|
91
|
-
"test/files/csvtypes.csv",
|
92
|
-
"test/files/datetime.ods",
|
93
|
-
"test/files/datetime.xls",
|
94
|
-
"test/files/datetime.xlsx",
|
95
|
-
"test/files/datetime.xml",
|
96
|
-
"test/files/datetime_floatconv.xls",
|
97
|
-
"test/files/datetime_floatconv.xml",
|
98
|
-
"test/files/dreimalvier.ods",
|
99
|
-
"test/files/emptysheets.ods",
|
100
|
-
"test/files/emptysheets.xls",
|
101
|
-
"test/files/emptysheets.xlsx",
|
102
|
-
"test/files/emptysheets.xml",
|
103
|
-
"test/files/excel2003.xml",
|
104
|
-
"test/files/false_encoding.xls",
|
105
|
-
"test/files/false_encoding.xml",
|
106
|
-
"test/files/file_item_error.xlsx",
|
107
|
-
"test/files/formula.ods",
|
108
|
-
"test/files/formula.xls",
|
109
|
-
"test/files/formula.xlsx",
|
110
|
-
"test/files/formula.xml",
|
111
|
-
"test/files/formula_parse_error.xls",
|
112
|
-
"test/files/formula_parse_error.xml",
|
113
|
-
"test/files/formula_string_error.xlsx",
|
114
|
-
"test/files/html-escape.ods",
|
115
|
-
"test/files/link.xls",
|
116
|
-
"test/files/link.xlsx",
|
117
|
-
"test/files/matrix.ods",
|
118
|
-
"test/files/matrix.xls",
|
119
|
-
"test/files/named_cells.ods",
|
120
|
-
"test/files/named_cells.xls",
|
121
|
-
"test/files/named_cells.xlsx",
|
122
|
-
"test/files/no_spreadsheet_file.txt",
|
123
|
-
"test/files/numbers1.csv",
|
124
|
-
"test/files/numbers1.ods",
|
125
|
-
"test/files/numbers1.xls",
|
126
|
-
"test/files/numbers1.xlsx",
|
127
|
-
"test/files/numbers1.xml",
|
128
|
-
"test/files/numeric-link.xlsx",
|
129
|
-
"test/files/only_one_sheet.ods",
|
130
|
-
"test/files/only_one_sheet.xls",
|
131
|
-
"test/files/only_one_sheet.xlsx",
|
132
|
-
"test/files/only_one_sheet.xml",
|
133
|
-
"test/files/paragraph.ods",
|
134
|
-
"test/files/paragraph.xls",
|
135
|
-
"test/files/paragraph.xlsx",
|
136
|
-
"test/files/paragraph.xml",
|
137
|
-
"test/files/prova.xls",
|
138
|
-
"test/files/ric.ods",
|
139
|
-
"test/files/simple_spreadsheet.ods",
|
140
|
-
"test/files/simple_spreadsheet.xls",
|
141
|
-
"test/files/simple_spreadsheet.xlsx",
|
142
|
-
"test/files/simple_spreadsheet.xml",
|
143
|
-
"test/files/simple_spreadsheet_from_italo.ods",
|
144
|
-
"test/files/simple_spreadsheet_from_italo.xls",
|
145
|
-
"test/files/simple_spreadsheet_from_italo.xml",
|
146
|
-
"test/files/so_datetime.csv",
|
147
|
-
"test/files/style.ods",
|
148
|
-
"test/files/style.xls",
|
149
|
-
"test/files/style.xlsx",
|
150
|
-
"test/files/style.xml",
|
151
|
-
"test/files/time-test.csv",
|
152
|
-
"test/files/time-test.ods",
|
153
|
-
"test/files/time-test.xls",
|
154
|
-
"test/files/time-test.xlsx",
|
155
|
-
"test/files/time-test.xml",
|
156
|
-
"test/files/type_excel.ods",
|
157
|
-
"test/files/type_excel.xlsx",
|
158
|
-
"test/files/type_excelx.ods",
|
159
|
-
"test/files/type_excelx.xls",
|
160
|
-
"test/files/type_openoffice.xls",
|
161
|
-
"test/files/type_openoffice.xlsx",
|
162
|
-
"test/files/whitespace.ods",
|
163
|
-
"test/files/whitespace.xls",
|
164
|
-
"test/files/whitespace.xlsx",
|
165
|
-
"test/files/whitespace.xml",
|
166
|
-
"test/rm_sub_test.rb",
|
167
|
-
"test/rm_test.rb",
|
168
|
-
"test/test_generic_spreadsheet.rb",
|
169
|
-
"test/test_helper.rb",
|
170
|
-
"test/test_roo.rb",
|
171
|
-
"website/index.html",
|
172
|
-
"website/index.txt",
|
173
|
-
"website/javascripts/rounded_corners_lite.inc.js",
|
174
|
-
"website/stylesheets/screen.css",
|
175
|
-
"website/template.rhtml"
|
176
|
-
]
|
177
|
-
s.homepage = "http://github.com/Empact/roo"
|
178
|
-
s.licenses = ["MIT"]
|
179
|
-
s.require_paths = ["lib"]
|
180
|
-
s.required_ruby_version = Gem::Requirement.new(">= 1.9.0")
|
181
|
-
s.rubygems_version = "2.0.14"
|
182
|
-
s.summary = "Roo can access the contents of various spreadsheet files."
|
183
|
-
s.test_files = ["spec/fixtures/vcr_cassettes/google_drive.yml", "spec/fixtures/vcr_cassettes/google_drive_access_token.yml", "spec/fixtures/vcr_cassettes/google_drive_set.yml", "spec/lib/roo/base_spec.rb", "spec/lib/roo/csv_spec.rb", "spec/lib/roo/excel2003xml_spec.rb", "spec/lib/roo/excel_spec.rb", "spec/lib/roo/excelx/format_spec.rb", "spec/lib/roo/excelx_spec.rb", "spec/lib/roo/google_spec.rb", "spec/lib/roo/libreoffice_spec.rb", "spec/lib/roo/openoffice_spec.rb", "spec/lib/roo/spreadsheet_spec.rb", "spec/spec_helper.rb", "test/all_ss.rb", "test/files/1900_base.xls", "test/files/1900_base.xlsx", "test/files/1904_base.xls", "test/files/1904_base.xlsx", "test/files/Bibelbund.csv", "test/files/Bibelbund.ods", "test/files/Bibelbund.xls", "test/files/Bibelbund.xlsx", "test/files/Bibelbund.xml", "test/files/Bibelbund1.ods", "test/files/Pfand_from_windows_phone.xlsx", "test/files/bad_excel_date.xls", "test/files/bbu.ods", "test/files/bbu.xls", "test/files/bbu.xlsx", "test/files/bbu.xml", "test/files/bode-v1.ods.zip", "test/files/bode-v1.xls.zip", "test/files/boolean.csv", "test/files/boolean.ods", "test/files/boolean.xls", "test/files/boolean.xlsx", "test/files/boolean.xml", "test/files/borders.ods", "test/files/borders.xls", "test/files/borders.xlsx", "test/files/borders.xml", "test/files/bug-numbered-sheet-names.xlsx", "test/files/bug-row-column-fixnum-float.xls", "test/files/bug-row-column-fixnum-float.xml", "test/files/comments.ods", "test/files/comments.xls", "test/files/comments.xlsx", "test/files/csvtypes.csv", "test/files/datetime.ods", "test/files/datetime.xls", "test/files/datetime.xlsx", "test/files/datetime.xml", "test/files/datetime_floatconv.xls", "test/files/datetime_floatconv.xml", "test/files/dreimalvier.ods", "test/files/emptysheets.ods", "test/files/emptysheets.xls", "test/files/emptysheets.xlsx", "test/files/emptysheets.xml", "test/files/excel2003.xml", "test/files/false_encoding.xls", "test/files/false_encoding.xml", "test/files/file_item_error.xlsx", "test/files/formula.ods", "test/files/formula.xls", "test/files/formula.xlsx", "test/files/formula.xml", "test/files/formula_parse_error.xls", "test/files/formula_parse_error.xml", "test/files/formula_string_error.xlsx", "test/files/html-escape.ods", "test/files/link.xls", "test/files/link.xlsx", "test/files/matrix.ods", "test/files/matrix.xls", "test/files/named_cells.ods", "test/files/named_cells.xls", "test/files/named_cells.xlsx", "test/files/no_spreadsheet_file.txt", "test/files/numbers1.csv", "test/files/numbers1.ods", "test/files/numbers1.xls", "test/files/numbers1.xlsx", "test/files/numbers1.xml", "test/files/numeric-link.xlsx", "test/files/only_one_sheet.ods", "test/files/only_one_sheet.xls", "test/files/only_one_sheet.xlsx", "test/files/only_one_sheet.xml", "test/files/paragraph.ods", "test/files/paragraph.xls", "test/files/paragraph.xlsx", "test/files/paragraph.xml", "test/files/prova.xls", "test/files/ric.ods", "test/files/simple_spreadsheet.ods", "test/files/simple_spreadsheet.xls", "test/files/simple_spreadsheet.xlsx", "test/files/simple_spreadsheet.xml", "test/files/simple_spreadsheet_from_italo.ods", "test/files/simple_spreadsheet_from_italo.xls", "test/files/simple_spreadsheet_from_italo.xml", "test/files/so_datetime.csv", "test/files/style.ods", "test/files/style.xls", "test/files/style.xlsx", "test/files/style.xml", "test/files/time-test.csv", "test/files/time-test.ods", "test/files/time-test.xls", "test/files/time-test.xlsx", "test/files/time-test.xml", "test/files/type_excel.ods", "test/files/type_excel.xlsx", "test/files/type_excelx.ods", "test/files/type_excelx.xls", "test/files/type_openoffice.xls", "test/files/type_openoffice.xlsx", "test/files/whitespace.ods", "test/files/whitespace.xls", "test/files/whitespace.xlsx", "test/files/whitespace.xml", "test/rm_sub_test.rb", "test/rm_test.rb", "test/test_generic_spreadsheet.rb", "test/test_helper.rb", "test/test_roo.rb"]
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.files.reject! { |fn| fn.include?('test/files') }
|
18
|
+
spec.require_paths = ['lib']
|
184
19
|
|
185
|
-
|
186
|
-
|
20
|
+
spec.add_dependency 'nokogiri', '~> 1'
|
21
|
+
spec.add_dependency 'rubyzip', '~> 1.1', '< 2.0.0'
|
187
22
|
|
188
|
-
|
189
|
-
|
190
|
-
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
191
|
-
s.add_runtime_dependency(%q<rubyzip>, [">= 0"])
|
192
|
-
s.add_development_dependency(%q<google_drive>, [">= 0"])
|
193
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
194
|
-
else
|
195
|
-
s.add_dependency(%q<spreadsheet>, ["> 0.6.4"])
|
196
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
197
|
-
s.add_dependency(%q<rubyzip>, [">= 0"])
|
198
|
-
s.add_dependency(%q<google_drive>, [">= 0"])
|
199
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
200
|
-
end
|
201
|
-
else
|
202
|
-
s.add_dependency(%q<spreadsheet>, ["> 0.6.4"])
|
203
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
204
|
-
s.add_dependency(%q<rubyzip>, [">= 0"])
|
205
|
-
s.add_dependency(%q<google_drive>, [">= 0"])
|
206
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
207
|
-
end
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.1'
|
24
|
+
spec.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3'
|
208
25
|
end
|
209
|
-
|
data/spec/lib/roo/base_spec.rb
CHANGED
data/spec/lib/roo/csv_spec.rb
CHANGED
@@ -11,11 +11,25 @@ describe Roo::CSV do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '#parse' do
|
14
|
-
subject
|
14
|
+
subject do
|
15
15
|
csv.parse(options)
|
16
|
-
|
16
|
+
end
|
17
17
|
context 'with headers: true' do
|
18
|
-
let(:options) { {headers: true} }
|
18
|
+
let(:options) { { headers: true } }
|
19
|
+
|
20
|
+
it "doesn't blow up" do
|
21
|
+
expect { subject }.to_not raise_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#parse_with_clean_option' do
|
27
|
+
subject do
|
28
|
+
csv.parse(options)
|
29
|
+
end
|
30
|
+
context 'with clean: true' do
|
31
|
+
let(:options) { {clean: true} }
|
32
|
+
let(:path) { 'test/files/parse_with_clean_option.csv' }
|
19
33
|
|
20
34
|
it "doesn't blow up" do
|
21
35
|
expect { subject }.to_not raise_error
|
@@ -25,30 +39,24 @@ describe Roo::CSV do
|
|
25
39
|
|
26
40
|
describe '#csv_options' do
|
27
41
|
context 'when created with the csv_options option' do
|
28
|
-
let(:options)
|
42
|
+
let(:options) do
|
29
43
|
{
|
30
44
|
col_sep: '\t',
|
31
45
|
quote_char: "'"
|
32
46
|
}
|
33
|
-
|
47
|
+
end
|
34
48
|
|
35
49
|
it 'returns the csv options' do
|
36
50
|
csv = Roo::CSV.new(path, csv_options: options)
|
37
|
-
csv.csv_options.
|
51
|
+
expect(csv.csv_options).to eq(options)
|
38
52
|
end
|
39
53
|
end
|
40
54
|
|
41
55
|
context 'when created without the csv_options option' do
|
42
56
|
it 'returns a hash' do
|
43
57
|
csv = Roo::CSV.new(path)
|
44
|
-
csv.csv_options.
|
58
|
+
expect(csv.csv_options).to eq({})
|
45
59
|
end
|
46
60
|
end
|
47
61
|
end
|
48
62
|
end
|
49
|
-
|
50
|
-
describe Roo::Csv do
|
51
|
-
it 'is an alias of LibreOffice' do
|
52
|
-
expect(Roo::Csv).to eq(Roo::CSV)
|
53
|
-
end
|
54
|
-
end
|
@@ -11,8 +11,8 @@ describe Roo::Excelx::Format do
|
|
11
11
|
'0%' => :percentage,
|
12
12
|
'0.00%' => :percentage,
|
13
13
|
'0.00E+00' => :float,
|
14
|
-
'# ?/?' => :float,
|
15
|
-
'# ??/??' => :float,
|
14
|
+
'# ?/?' => :float, # ??? TODO:
|
15
|
+
'# ??/??' => :float, # ??? TODO:
|
16
16
|
'mm-dd-yy' => :date,
|
17
17
|
'd-mmm-yy' => :date,
|
18
18
|
'd-mmm' => :date,
|
@@ -33,17 +33,18 @@ describe Roo::Excelx::Format do
|
|
33
33
|
'##0.0E+0' => :float,
|
34
34
|
'@' => :float,
|
35
35
|
#-- zusaetzliche Formate, die nicht standardmaessig definiert sind:
|
36
|
-
|
36
|
+
'yyyy\\-mm\\-dd' => :date,
|
37
37
|
'dd/mm/yy' => :date,
|
38
38
|
'hh:mm:ss' => :time,
|
39
|
-
|
39
|
+
'dd/mm/yy\\ hh:mm' => :datetime,
|
40
40
|
'dd/mmm/yy\\ hh:mm' => :datetime,
|
41
41
|
'dd/mmm/yy' => :date, # 2011-05-21
|
42
42
|
'yyyy-mm-dd' => :date, # 2011-09-16
|
43
|
-
'yyyy-mm-dd;@' => :date
|
43
|
+
'yyyy-mm-dd;@' => :date,
|
44
|
+
'#0_);[Red]\(0\)' => :float
|
44
45
|
}.each do |format, type|
|
45
46
|
it "translates #{format} to #{type}" do
|
46
|
-
Roo::Excelx::Format.to_type(format).
|
47
|
+
expect(Roo::Excelx::Format.to_type(format)).to eq(type)
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|