roo 2.10.0 → 2.10.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/CHANGELOG.md +3 -1
- data/README.md +21 -6
- data/lib/roo/base.rb +4 -4
- data/lib/roo/excelx/cell/number.rb +1 -1
- data/lib/roo/tempdir.rb +4 -1
- data/lib/roo/version.rb +1 -1
- data/spec/lib/roo/base_spec.rb +16 -4
- data/test/excelx/cell/test_number.rb +5 -0
- data/test/helpers/test_accessing_files.rb +21 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd6f8267a04fcec20134f5170360fdd0259369b0c8b319100d0304c95964a6f5
|
4
|
+
data.tar.gz: 6e33716242265c9c02a7cc42b22690f03114cf12bcbbe846055040fede3cd790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65dd59afe1dfda800c7e88547f305dbd1eb295c5715fd23dc5123618307205ae1a0c0740511739d2880b4d91cabca10fad152d522cca96a2694f8e3c1cccbd39
|
7
|
+
data.tar.gz: 9d239b22ee226fc3466d2445127dc2c4fc50c488249171b0b86dc17a4a41779e543e83ed3def1fe9fae26ddc67608a81733483e3757b32156d822abdbf2bc974
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
##
|
1
|
+
## [2.10.1] 2024-01-17
|
2
2
|
|
3
3
|
### Changed/Added
|
4
|
+
- Prevent warnings on Ruby 3.1 if finalizer is called twice [586](https://github.com/roo-rb/roo/pull/586)
|
5
|
+
- Fix Roo::Base#each_with_pagename degraded at [576](https://github.com/roo-rb/roo/pull/576) [583](https://github.com/roo-rb/roo/pull/583)
|
4
6
|
|
5
7
|
## [2.10.0] 2023-02-07
|
6
8
|
|
data/README.md
CHANGED
@@ -22,22 +22,37 @@ gem "roo", "~> 2.10.0"
|
|
22
22
|
```
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
Opening a spreadsheet
|
25
|
+
### Opening a spreadsheet
|
26
26
|
|
27
|
+
You can use the `Roo::Spreadsheet` class so `roo` automatically detects which [parser class](https://github.com/roo-rb/roo/blob/master/lib/roo.rb#L17) to use for you.
|
27
28
|
```ruby
|
28
29
|
require 'roo'
|
29
30
|
|
30
|
-
|
31
|
-
xlsx = Roo::
|
31
|
+
file_name = './new_prices.xlsx'
|
32
|
+
xlsx = Roo::Spreadsheet.open(file_name)
|
33
|
+
xlsx.info
|
34
|
+
# => Returns basic info about the spreadsheet file
|
35
|
+
```
|
32
36
|
|
33
|
-
|
34
|
-
|
37
|
+
``Roo::Spreadsheet.open`` can accept both string paths and ``File`` instances. Also, you can provide the extension of the file as an option:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
require 'roo'
|
35
41
|
|
42
|
+
file_name = './rails_temp_upload'
|
43
|
+
xlsx = Roo::Spreadsheet.open(file_name, extension: :xlsx)
|
36
44
|
xlsx.info
|
37
45
|
# => Returns basic info about the spreadsheet file
|
38
46
|
```
|
39
47
|
|
40
|
-
|
48
|
+
On the other hand, if you know what the file extension is, you can use the specific parser class instead:
|
49
|
+
```ruby
|
50
|
+
require 'roo'
|
51
|
+
|
52
|
+
xlsx = Roo::Excelx.new("./new_prices.xlsx")
|
53
|
+
xlsx.info
|
54
|
+
# => Returns basic info about the spreadsheet file
|
55
|
+
```
|
41
56
|
|
42
57
|
### Working with sheets
|
43
58
|
|
data/lib/roo/base.rb
CHANGED
@@ -250,10 +250,10 @@ class Roo::Base
|
|
250
250
|
|
251
251
|
# iterate through all worksheets of a document
|
252
252
|
def each_with_pagename
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
253
|
+
return to_enum(:each_with_pagename) { sheets.size } unless block_given?
|
254
|
+
|
255
|
+
sheets.each do |s|
|
256
|
+
yield sheet(s, true)
|
257
257
|
end
|
258
258
|
end
|
259
259
|
|
data/lib/roo/tempdir.rb
CHANGED
@@ -4,7 +4,10 @@ module Roo
|
|
4
4
|
if @tempdirs && (dirs_to_remove = @tempdirs[object_id])
|
5
5
|
@tempdirs.delete(object_id)
|
6
6
|
dirs_to_remove.each do |dir|
|
7
|
-
|
7
|
+
# Pass force=true to avoid an exception (and thus warnings in Ruby 3.1) if dir has
|
8
|
+
# already been removed. This can occur when the finalizer is called both in a forked
|
9
|
+
# child process and in the parent.
|
10
|
+
::FileUtils.remove_entry(dir, true)
|
8
11
|
end
|
9
12
|
end
|
10
13
|
end
|
data/lib/roo/version.rb
CHANGED
data/spec/lib/roo/base_spec.rb
CHANGED
@@ -183,10 +183,22 @@ describe Roo::Base do
|
|
183
183
|
end
|
184
184
|
|
185
185
|
describe '#each_with_pagename' do
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
186
|
+
context 'when block given' do
|
187
|
+
it 'iterate with sheet and sheet_name' do
|
188
|
+
sheet_names = []
|
189
|
+
spreadsheet.each_with_pagename do |sheet_name, sheet|
|
190
|
+
sheet_names << sheet_name
|
191
|
+
end
|
192
|
+
expect(sheet_names).to eq ['my_sheet', 'blank sheet']
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'when called without block' do
|
197
|
+
it 'should return an enumerator with all the rows' do
|
198
|
+
each_with_pagename = spreadsheet.each_with_pagename
|
199
|
+
expect(each_with_pagename).to be_a(Enumerator)
|
200
|
+
expect(each_with_pagename.to_a.last).to eq([spreadsheet.default_sheet, spreadsheet])
|
201
|
+
end
|
190
202
|
end
|
191
203
|
end
|
192
204
|
|
@@ -35,6 +35,11 @@ class TestRooExcelxCellNumber < Minitest::Test
|
|
35
35
|
assert_kind_of(Float, cell.value)
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_rounded_percent_formatted_value
|
39
|
+
cell = Roo::Excelx::Cell::Number.new '0.569999999995', nil, ['0%'], nil, nil, nil
|
40
|
+
assert_equal('57%', cell.formatted_value)
|
41
|
+
end
|
42
|
+
|
38
43
|
def test_formats_with_negative_numbers
|
39
44
|
[
|
40
45
|
['#,##0 ;(#,##0)', '(1,042)'],
|
@@ -36,6 +36,27 @@ module TestAccesingFiles
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
def test_finalize_twice
|
40
|
+
skip if defined? JRUBY_VERSION
|
41
|
+
|
42
|
+
instance = Class.new { include Roo::Tempdir }.new
|
43
|
+
|
44
|
+
tempdir = instance.make_tempdir(instance, "my_temp_prefix", nil)
|
45
|
+
assert File.exist?(tempdir), "Expected #{tempdir} to initially exist"
|
46
|
+
|
47
|
+
pid = Process.fork do
|
48
|
+
# Inside the forked process finalize does not affect the parent process's state, but does
|
49
|
+
# delete the tempfile on disk
|
50
|
+
instance.finalize_tempdirs(instance.object_id)
|
51
|
+
end
|
52
|
+
|
53
|
+
Process.wait(pid)
|
54
|
+
refute File.exist?(tempdir), "Expected #{tempdir} to have been cleaned up by child process"
|
55
|
+
|
56
|
+
instance.finalize_tempdirs(instance.object_id)
|
57
|
+
refute File.exist?(tempdir), "Expected #{tempdir} to still have been cleaned up"
|
58
|
+
end
|
59
|
+
|
39
60
|
def test_cleanup_on_error
|
40
61
|
# NOTE: This test was occasionally failing because when it started running
|
41
62
|
# other tests would have already added folders to the temp directory,
|
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.10.
|
4
|
+
version: 2.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Preymesser
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2024-01-18 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: nokogiri
|
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
256
|
- !ruby/object:Gem::Version
|
257
257
|
version: '0'
|
258
258
|
requirements: []
|
259
|
-
rubygems_version: 3.
|
259
|
+
rubygems_version: 3.3.26
|
260
260
|
signing_key:
|
261
261
|
specification_version: 4
|
262
262
|
summary: Roo can access the contents of various spreadsheet files.
|