roo 2.0.1 → 2.1.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/.travis.yml +1 -0
- data/CHANGELOG.md +16 -1
- data/README.md +8 -11
- data/lib/roo/base.rb +84 -84
- data/lib/roo/constants.rb +5 -0
- data/lib/roo/excelx/shared_strings.rb +10 -0
- data/lib/roo/excelx.rb +12 -13
- data/lib/roo/libre_office.rb +1 -2
- data/lib/roo/open_office.rb +454 -521
- data/lib/roo/spreadsheet.rb +3 -1
- data/lib/roo/version.rb +1 -1
- data/lib/roo.rb +5 -3
- data/spec/helpers.rb +5 -0
- data/spec/lib/roo/base_spec.rb +212 -0
- data/spec/lib/roo/excelx_spec.rb +13 -0
- data/spec/lib/roo/spreadsheet_spec.rb +20 -0
- data/spec/spec_helper.rb +6 -1
- data/test/all_ss.rb +12 -11
- data/test/test_helper.rb +0 -4
- data/test/test_roo.rb +2091 -2088
- metadata +5 -3
- data/test/test_generic_spreadsheet.rb +0 -237
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Preymesser
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-08-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: nokogiri
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- examples/write_me.rb
|
109
109
|
- lib/roo.rb
|
110
110
|
- lib/roo/base.rb
|
111
|
+
- lib/roo/constants.rb
|
111
112
|
- lib/roo/csv.rb
|
112
113
|
- lib/roo/excelx.rb
|
113
114
|
- lib/roo/excelx/cell.rb
|
@@ -130,6 +131,7 @@ files:
|
|
130
131
|
- spec/fixtures/vcr_cassettes/google_drive.yml
|
131
132
|
- spec/fixtures/vcr_cassettes/google_drive_access_token.yml
|
132
133
|
- spec/fixtures/vcr_cassettes/google_drive_set.yml
|
134
|
+
- spec/helpers.rb
|
133
135
|
- spec/lib/roo/base_spec.rb
|
134
136
|
- spec/lib/roo/csv_spec.rb
|
135
137
|
- spec/lib/roo/excelx/format_spec.rb
|
@@ -140,7 +142,6 @@ files:
|
|
140
142
|
- spec/lib/roo/utils_spec.rb
|
141
143
|
- spec/spec_helper.rb
|
142
144
|
- test/all_ss.rb
|
143
|
-
- test/test_generic_spreadsheet.rb
|
144
145
|
- test/test_helper.rb
|
145
146
|
- test/test_roo.rb
|
146
147
|
homepage: http://github.com/roo-rb/roo
|
@@ -168,3 +169,4 @@ signing_key:
|
|
168
169
|
specification_version: 4
|
169
170
|
summary: Roo can access the contents of various spreadsheet files.
|
170
171
|
test_files: []
|
172
|
+
has_rdoc:
|
@@ -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
|