roo 2.0.1 → 2.7.1
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 +4 -4
- data/.codeclimate.yml +17 -0
- data/.github/ISSUE_TEMPLATE +10 -0
- data/.gitignore +4 -0
- data/.travis.yml +10 -6
- data/CHANGELOG.md +116 -1
- data/Gemfile +3 -4
- data/Gemfile_ruby2 +30 -0
- data/Guardfile +1 -2
- data/README.md +56 -22
- data/Rakefile +1 -1
- data/lib/roo/base.rb +108 -245
- data/lib/roo/constants.rb +5 -0
- data/lib/roo/csv.rb +94 -87
- 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 +33 -4
- data/lib/roo/excelx/comments.rb +33 -0
- data/lib/roo/excelx/coordinate.rb +12 -0
- data/lib/roo/excelx/extractor.rb +3 -4
- data/lib/roo/excelx/format.rb +64 -0
- data/lib/roo/excelx/shared.rb +32 -0
- data/lib/roo/excelx/shared_strings.rb +124 -4
- data/lib/roo/excelx/sheet.rb +12 -7
- data/lib/roo/excelx/sheet_doc.rb +108 -97
- data/lib/roo/excelx/styles.rb +1 -1
- data/lib/roo/excelx.rb +61 -103
- 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 +1 -2
- data/lib/roo/link.rb +21 -2
- data/lib/roo/open_office.rb +468 -523
- data/lib/roo/spreadsheet.rb +3 -1
- data/lib/roo/tempdir.rb +21 -0
- data/lib/roo/utils.rb +7 -7
- data/lib/roo/version.rb +1 -1
- data/lib/roo.rb +8 -3
- data/roo.gemspec +2 -1
- data/spec/helpers.rb +5 -0
- data/spec/lib/roo/base_spec.rb +229 -0
- data/spec/lib/roo/csv_spec.rb +19 -0
- data/spec/lib/roo/excelx_spec.rb +97 -11
- data/spec/lib/roo/openoffice_spec.rb +18 -1
- data/spec/lib/roo/spreadsheet_spec.rb +20 -0
- data/spec/lib/roo/utils_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -5
- 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 +78 -0
- data/test/formatters/test_yaml.rb +20 -0
- 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 +60 -0
- data/test/roo/test_excelx.rb +325 -0
- data/test/roo/test_libre_office.rb +9 -0
- data/test/roo/test_open_office.rb +289 -0
- data/test/test_helper.rb +116 -18
- data/test/test_roo.rb +362 -2088
- metadata +70 -4
- data/test/test_generic_spreadsheet.rb +0 -237
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Preymesser
|
8
8
|
- Hugh McGowan
|
9
9
|
- Ben Woosley
|
10
10
|
- Oleksandr Simonov
|
11
|
+
- Steven Daniels
|
11
12
|
autorequire:
|
12
13
|
bindir: bin
|
13
14
|
cert_chain: []
|
14
|
-
date:
|
15
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
17
18
|
name: nokogiri
|
@@ -81,6 +82,26 @@ dependencies:
|
|
81
82
|
- - ">="
|
82
83
|
- !ruby/object:Gem::Version
|
83
84
|
version: 5.4.3
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rack
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '1.6'
|
92
|
+
- - "<"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 2.0.0
|
95
|
+
type: :development
|
96
|
+
prerelease: false
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.6'
|
102
|
+
- - "<"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.0.0
|
84
105
|
description: |-
|
85
106
|
Roo can access the contents of various spreadsheet files. It can handle
|
86
107
|
* OpenOffice
|
@@ -94,11 +115,14 @@ executables: []
|
|
94
115
|
extensions: []
|
95
116
|
extra_rdoc_files: []
|
96
117
|
files:
|
118
|
+
- ".codeclimate.yml"
|
119
|
+
- ".github/ISSUE_TEMPLATE"
|
97
120
|
- ".gitignore"
|
98
121
|
- ".simplecov"
|
99
122
|
- ".travis.yml"
|
100
123
|
- CHANGELOG.md
|
101
124
|
- Gemfile
|
125
|
+
- Gemfile_ruby2
|
102
126
|
- Guardfile
|
103
127
|
- LICENSE
|
104
128
|
- README.md
|
@@ -108,28 +132,48 @@ files:
|
|
108
132
|
- examples/write_me.rb
|
109
133
|
- lib/roo.rb
|
110
134
|
- lib/roo/base.rb
|
135
|
+
- lib/roo/constants.rb
|
111
136
|
- lib/roo/csv.rb
|
137
|
+
- lib/roo/errors.rb
|
112
138
|
- lib/roo/excelx.rb
|
113
139
|
- lib/roo/excelx/cell.rb
|
140
|
+
- lib/roo/excelx/cell/base.rb
|
141
|
+
- lib/roo/excelx/cell/boolean.rb
|
142
|
+
- lib/roo/excelx/cell/date.rb
|
143
|
+
- lib/roo/excelx/cell/datetime.rb
|
144
|
+
- lib/roo/excelx/cell/empty.rb
|
145
|
+
- lib/roo/excelx/cell/number.rb
|
146
|
+
- lib/roo/excelx/cell/string.rb
|
147
|
+
- lib/roo/excelx/cell/time.rb
|
114
148
|
- lib/roo/excelx/comments.rb
|
149
|
+
- lib/roo/excelx/coordinate.rb
|
115
150
|
- lib/roo/excelx/extractor.rb
|
151
|
+
- lib/roo/excelx/format.rb
|
116
152
|
- lib/roo/excelx/relationships.rb
|
153
|
+
- lib/roo/excelx/shared.rb
|
117
154
|
- lib/roo/excelx/shared_strings.rb
|
118
155
|
- lib/roo/excelx/sheet.rb
|
119
156
|
- lib/roo/excelx/sheet_doc.rb
|
120
157
|
- lib/roo/excelx/styles.rb
|
121
158
|
- lib/roo/excelx/workbook.rb
|
122
159
|
- lib/roo/font.rb
|
160
|
+
- lib/roo/formatters/base.rb
|
161
|
+
- lib/roo/formatters/csv.rb
|
162
|
+
- lib/roo/formatters/matrix.rb
|
163
|
+
- lib/roo/formatters/xml.rb
|
164
|
+
- lib/roo/formatters/yaml.rb
|
123
165
|
- lib/roo/libre_office.rb
|
124
166
|
- lib/roo/link.rb
|
125
167
|
- lib/roo/open_office.rb
|
126
168
|
- lib/roo/spreadsheet.rb
|
169
|
+
- lib/roo/tempdir.rb
|
127
170
|
- lib/roo/utils.rb
|
128
171
|
- lib/roo/version.rb
|
129
172
|
- roo.gemspec
|
130
173
|
- spec/fixtures/vcr_cassettes/google_drive.yml
|
131
174
|
- spec/fixtures/vcr_cassettes/google_drive_access_token.yml
|
132
175
|
- spec/fixtures/vcr_cassettes/google_drive_set.yml
|
176
|
+
- spec/helpers.rb
|
133
177
|
- spec/lib/roo/base_spec.rb
|
134
178
|
- spec/lib/roo/csv_spec.rb
|
135
179
|
- spec/lib/roo/excelx/format_spec.rb
|
@@ -140,7 +184,29 @@ files:
|
|
140
184
|
- spec/lib/roo/utils_spec.rb
|
141
185
|
- spec/spec_helper.rb
|
142
186
|
- test/all_ss.rb
|
143
|
-
- test/
|
187
|
+
- test/excelx/cell/test_base.rb
|
188
|
+
- test/excelx/cell/test_boolean.rb
|
189
|
+
- test/excelx/cell/test_date.rb
|
190
|
+
- test/excelx/cell/test_datetime.rb
|
191
|
+
- test/excelx/cell/test_empty.rb
|
192
|
+
- test/excelx/cell/test_number.rb
|
193
|
+
- test/excelx/cell/test_string.rb
|
194
|
+
- test/excelx/cell/test_time.rb
|
195
|
+
- test/formatters/test_csv.rb
|
196
|
+
- test/formatters/test_matrix.rb
|
197
|
+
- test/formatters/test_xml.rb
|
198
|
+
- test/formatters/test_yaml.rb
|
199
|
+
- test/helpers/test_accessing_files.rb
|
200
|
+
- test/helpers/test_comments.rb
|
201
|
+
- test/helpers/test_formulas.rb
|
202
|
+
- test/helpers/test_labels.rb
|
203
|
+
- test/helpers/test_sheets.rb
|
204
|
+
- test/helpers/test_styles.rb
|
205
|
+
- test/roo/test_base.rb
|
206
|
+
- test/roo/test_csv.rb
|
207
|
+
- test/roo/test_excelx.rb
|
208
|
+
- test/roo/test_libre_office.rb
|
209
|
+
- test/roo/test_open_office.rb
|
144
210
|
- test/test_helper.rb
|
145
211
|
- test/test_roo.rb
|
146
212
|
homepage: http://github.com/roo-rb/roo
|
@@ -163,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
229
|
version: '0'
|
164
230
|
requirements: []
|
165
231
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
232
|
+
rubygems_version: 2.5.1
|
167
233
|
signing_key:
|
168
234
|
specification_version: 4
|
169
235
|
summary: Roo can access the contents of various spreadsheet files.
|
@@ -1,237 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.dirname(__FILE__) + '/test_helper'
|
3
|
-
|
4
|
-
class TestBase < Minitest::Test
|
5
|
-
def setup
|
6
|
-
@klass = Class.new(Roo::Base) do
|
7
|
-
def initialize(filename = 'some_file')
|
8
|
-
super
|
9
|
-
@filename = filename
|
10
|
-
end
|
11
|
-
|
12
|
-
def read_cells(sheet = nil)
|
13
|
-
@cells_read[sheet] = true
|
14
|
-
end
|
15
|
-
|
16
|
-
def cell(row, col, sheet = nil)
|
17
|
-
sheet ||= default_sheet
|
18
|
-
@cell[sheet][[row, col]]
|
19
|
-
end
|
20
|
-
|
21
|
-
def celltype(row, col, sheet = nil)
|
22
|
-
sheet ||= default_sheet
|
23
|
-
@cell_type[sheet][[row, col]]
|
24
|
-
end
|
25
|
-
|
26
|
-
def sheets
|
27
|
-
['my_sheet', 'blank sheet']
|
28
|
-
end
|
29
|
-
end
|
30
|
-
@oo = @klass.new
|
31
|
-
setup_test_sheet(@oo)
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'private method Roo::Base.uri?(filename)' do
|
35
|
-
should 'return true when passed a filename starts with http(s)://' do
|
36
|
-
assert_equal true, @oo.send(:uri?, 'http://example.com/')
|
37
|
-
assert_equal true, @oo.send(:uri?, 'https://example.com/')
|
38
|
-
end
|
39
|
-
|
40
|
-
should 'return false when passed a filename which does not start with http(s)://' do
|
41
|
-
assert_equal false, @oo.send(:uri?, 'example.com')
|
42
|
-
end
|
43
|
-
|
44
|
-
should 'return false when passed non-String object such as Tempfile' do
|
45
|
-
assert_equal false, @oo.send(:uri?, Tempfile.new('test'))
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_setting_invalid_type_does_not_update_cell
|
50
|
-
@oo.set(1, 1, 1)
|
51
|
-
assert_raises(ArgumentError) { @oo.set(1, 1, :invalid_type) }
|
52
|
-
assert_equal 1, @oo.cell(1, 1)
|
53
|
-
assert_equal :float, @oo.celltype(1, 1)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_first_row
|
57
|
-
assert_equal 5, @oo.first_row
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_last_row
|
61
|
-
assert_equal 16, @oo.last_row
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_first_column
|
65
|
-
assert_equal 1, @oo.first_column
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_first_column_as_letter
|
69
|
-
assert_equal 'A', @oo.first_column_as_letter
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_last_column
|
73
|
-
assert_equal 7, @oo.last_column
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_last_column_as_letter
|
77
|
-
assert_equal 'G', @oo.last_column_as_letter
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_rows
|
81
|
-
assert_equal [41.0, 42.0, 43.0, 44.0, 45.0, nil, nil], @oo.row(12)
|
82
|
-
assert_equal [nil, '"Hello world!"', 'dreiundvierzig', 'vierundvierzig', 'fuenfundvierzig', nil, nil], @oo.row(16)
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_empty_eh
|
86
|
-
assert @oo.empty?(1, 1)
|
87
|
-
assert !@oo.empty?(8, 3)
|
88
|
-
assert @oo.empty?('A', 11)
|
89
|
-
assert !@oo.empty?('A', 12)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_reload
|
93
|
-
@oo.reload
|
94
|
-
assert @oo.instance_variable_get(:@cell).empty?
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_each
|
98
|
-
oo_each = @oo.each
|
99
|
-
assert_instance_of Enumerator, oo_each
|
100
|
-
assert_equal [nil, '"Hello world!"', 'dreiundvierzig', 'vierundvierzig', 'fuenfundvierzig', nil, nil], oo_each.to_a.last
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_to_yaml
|
104
|
-
assert_equal "--- \n" + yaml_entry(5, 1, 'date', '1961-11-21'), @oo.to_yaml({}, 5, 1, 5, 1)
|
105
|
-
assert_equal "--- \n" + yaml_entry(8, 3, 'string', 'thisisc8'), @oo.to_yaml({}, 8, 3, 8, 3)
|
106
|
-
assert_equal "--- \n" + yaml_entry(12, 3, 'float', 43.0), @oo.to_yaml({}, 12, 3, 12, 3)
|
107
|
-
assert_equal \
|
108
|
-
"--- \n" + yaml_entry(12, 3, 'float', 43.0) +
|
109
|
-
yaml_entry(12, 4, 'float', 44.0) +
|
110
|
-
yaml_entry(12, 5, 'float', 45.0), @oo.to_yaml({}, 12, 3, 12)
|
111
|
-
assert_equal \
|
112
|
-
"--- \n" + yaml_entry(12, 3, 'float', 43.0) +
|
113
|
-
yaml_entry(12, 4, 'float', 44.0) +
|
114
|
-
yaml_entry(12, 5, 'float', 45.0) +
|
115
|
-
yaml_entry(15, 3, 'float', 43.0) +
|
116
|
-
yaml_entry(15, 4, 'float', 44.0) +
|
117
|
-
yaml_entry(15, 5, 'float', 45.0) +
|
118
|
-
yaml_entry(16, 3, 'string', 'dreiundvierzig') +
|
119
|
-
yaml_entry(16, 4, 'string', 'vierundvierzig') +
|
120
|
-
yaml_entry(16, 5, 'string', 'fuenfundvierzig'), @oo.to_yaml({}, 12, 3)
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_to_csv
|
124
|
-
assert_equal expected_csv, @oo.to_csv
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_to_csv_with_separator
|
128
|
-
assert_equal expected_csv_with_semicolons, @oo.to_csv(nil, ';')
|
129
|
-
end
|
130
|
-
|
131
|
-
protected
|
132
|
-
|
133
|
-
def setup_test_sheet(workbook = nil)
|
134
|
-
workbook ||= @oo
|
135
|
-
set_sheet_values(workbook)
|
136
|
-
set_sheet_types(workbook)
|
137
|
-
set_cells_read(workbook)
|
138
|
-
end
|
139
|
-
|
140
|
-
def set_sheet_values(workbook)
|
141
|
-
workbook.instance_variable_get(:@cell)[workbook.default_sheet] = {
|
142
|
-
[5, 1] => Date.civil(1961, 11, 21).to_s,
|
143
|
-
|
144
|
-
[8, 3] => 'thisisc8',
|
145
|
-
[8, 7] => 'thisisg8',
|
146
|
-
|
147
|
-
[12, 1] => 41.0,
|
148
|
-
[12, 2] => 42.0,
|
149
|
-
[12, 3] => 43.0,
|
150
|
-
[12, 4] => 44.0,
|
151
|
-
[12, 5] => 45.0,
|
152
|
-
|
153
|
-
[15, 3] => 43.0,
|
154
|
-
[15, 4] => 44.0,
|
155
|
-
[15, 5] => 45.0,
|
156
|
-
|
157
|
-
[16, 2] => '"Hello world!"',
|
158
|
-
[16, 3] => 'dreiundvierzig',
|
159
|
-
[16, 4] => 'vierundvierzig',
|
160
|
-
[16, 5] => 'fuenfundvierzig'
|
161
|
-
}
|
162
|
-
end
|
163
|
-
|
164
|
-
def set_sheet_types(workbook)
|
165
|
-
workbook.instance_variable_get(:@cell_type)[workbook.default_sheet] = {
|
166
|
-
[5, 1] => :date,
|
167
|
-
|
168
|
-
[8, 3] => :string,
|
169
|
-
[8, 7] => :string,
|
170
|
-
|
171
|
-
[12, 1] => :float,
|
172
|
-
[12, 2] => :float,
|
173
|
-
[12, 3] => :float,
|
174
|
-
[12, 4] => :float,
|
175
|
-
[12, 5] => :float,
|
176
|
-
|
177
|
-
[15, 3] => :float,
|
178
|
-
[15, 4] => :float,
|
179
|
-
[15, 5] => :float,
|
180
|
-
|
181
|
-
[16, 2] => :string,
|
182
|
-
[16, 3] => :string,
|
183
|
-
[16, 4] => :string,
|
184
|
-
[16, 5] => :string
|
185
|
-
}
|
186
|
-
end
|
187
|
-
|
188
|
-
def set_first_row(workbook)
|
189
|
-
row_hash = workbook.instance_variable_get(:@first_row)
|
190
|
-
row_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map { |k, _v| k[0] }.min
|
191
|
-
end
|
192
|
-
|
193
|
-
def set_last_row(workbook)
|
194
|
-
row_hash = workbook.instance_variable_get(:@last_row)
|
195
|
-
row_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map { |k, _v| k[0] }.max
|
196
|
-
end
|
197
|
-
|
198
|
-
def set_first_col(workbook)
|
199
|
-
col_hash = workbook.instance_variable_get(:@first_column)
|
200
|
-
col_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map { |k, _v| k[1] }.min
|
201
|
-
end
|
202
|
-
|
203
|
-
def set_last_col(workbook)
|
204
|
-
col_hash = workbook.instance_variable_get(:@last_column)
|
205
|
-
col_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map { |k, _v| k[1] }.max
|
206
|
-
end
|
207
|
-
|
208
|
-
def set_cells_read(workbook)
|
209
|
-
read_hash = workbook.instance_variable_get(:@cells_read)
|
210
|
-
read_hash[workbook.default_sheet] = true
|
211
|
-
end
|
212
|
-
|
213
|
-
def expected_csv
|
214
|
-
<<EOS
|
215
|
-
,,,,,,
|
216
|
-
,,,,,,
|
217
|
-
,,,,,,
|
218
|
-
,,,,,,
|
219
|
-
1961-11-21,,,,,,
|
220
|
-
,,,,,,
|
221
|
-
,,,,,,
|
222
|
-
,,"thisisc8",,,,"thisisg8"
|
223
|
-
,,,,,,
|
224
|
-
,,,,,,
|
225
|
-
,,,,,,
|
226
|
-
41,42,43,44,45,,
|
227
|
-
,,,,,,
|
228
|
-
,,,,,,
|
229
|
-
,,43,44,45,,
|
230
|
-
,"""Hello world!""","dreiundvierzig","vierundvierzig","fuenfundvierzig",,
|
231
|
-
EOS
|
232
|
-
end
|
233
|
-
|
234
|
-
def expected_csv_with_semicolons
|
235
|
-
expected_csv.gsub(/\,/, ';')
|
236
|
-
end
|
237
|
-
end
|