roo 2.5.1 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +15 -4
- data/Gemfile +1 -1
- data/Gemfile_ruby2 +2 -0
- data/README.md +6 -5
- data/lib/roo/base.rb +6 -6
- data/lib/roo/csv.rb +8 -0
- data/lib/roo/errors.rb +2 -0
- data/lib/roo/excelx.rb +1 -1
- data/lib/roo/excelx/extractor.rb +3 -3
- data/lib/roo/excelx/styles.rb +1 -1
- data/lib/roo/version.rb +1 -1
- data/spec/lib/roo/csv_spec.rb +12 -0
- data/spec/lib/roo/excelx_spec.rb +10 -0
- data/spec/lib/roo/openoffice_spec.rb +2 -2
- data/test/excelx/cell/test_time.rb +1 -1
- data/test/test_roo.rb +13 -8
- metadata +21 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8604a4f1951ab6dfcd733de054d7bfb5a82a5fe0
|
4
|
+
data.tar.gz: 9d9a0f430db3eaf985772a6a934374d2a04ab822
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd5bb56cbd0744febca931b1032b14910f512e5f4d5513ec81cbd6de011a75f557fd8855fe53311ab83e77f67f8564c1c8b2774ee16d89b44687906b1ca77332
|
7
|
+
data.tar.gz: b3cef390c20fc5e5bf70d1896222352c04d8f4eac4af5e4a64e850fbb2abfbbf0e2ad5a92aa45568c229562fd5e6e8a82c6f28d8bb089722e7b5d0afd5bfda75
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## [2.6.0] 2016-12-28
|
4
|
+
### Fixed
|
5
|
+
- Fixed error if sheet name starts with a slash [348](https://github.com/roo-rb/roo/pull/348)
|
6
|
+
- Fixed loading to support files on ftp [355](https://github.com/roo-rb/roo/pull/355)
|
7
|
+
- Fixed Ruby 2.4.0 deprecation warnings [356](https://github.com/roo-rb/roo/pull/356)
|
8
|
+
- properly return date as string [359](https://github.com/roo-rb/roo/pull/359)
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- Cell values can be set in a CSV [350](https://github.com/roo-rb/roo/pull/350/)
|
12
|
+
- Raise an error Roo::Excelx::Extractor document is missing [358](https://github.com/roo-rb/roo/pull/358/)
|
13
|
+
|
3
14
|
## [2.5.1] 2016-08-26
|
4
15
|
### Fixed
|
5
16
|
- Fixed NameError. [337](https://github.com/roo-rb/roo/pull/337)
|
6
17
|
|
7
18
|
## [2.5.0] 2016-08-21
|
8
19
|
### Fixed
|
9
|
-
- Remove
|
20
|
+
- Remove temporary directories via finalizers on garbage collection. This cleans them up in all known cases, rather than just when the #close method is called. The #close method can be used to cleanup early. [329](https://github.com/roo-rb/roo/pull/329)
|
10
21
|
- Fixed README.md typo [318](https://github.com/roo-rb/roo/pull/318)
|
11
22
|
- Parse sheets in ODS files once to improve performance [320](https://github.com/roo-rb/roo/pull/320)
|
12
23
|
- Fix some Cell conversion issues [324](https://github.com/roo-rb/roo/pull/324) and [331](https://github.com/roo-rb/roo/pull/331)
|
@@ -16,10 +27,10 @@
|
|
16
27
|
### Deprecations
|
17
28
|
- Roo::Base::TEMP_PREFIX should be accessed via Roo::TEMP_PREFIX
|
18
29
|
- The private Roo::Base#make_tempdir is now available at the class level in
|
19
|
-
classes that use
|
30
|
+
classes that use temporary directories, added via Roo::Tempdir
|
20
31
|
=======
|
21
32
|
### Added
|
22
|
-
- Discard
|
33
|
+
- Discard hyperlinks lookups to allow streaming parsing without loading whole files
|
23
34
|
|
24
35
|
## [2.4.0] 2016-05-14
|
25
36
|
### Fixed
|
@@ -41,7 +52,7 @@
|
|
41
52
|
|
42
53
|
## [2.3.1] - 2016-01-08
|
43
54
|
### Fixed
|
44
|
-
- Properly parse
|
55
|
+
- Properly parse scientific-notation number like 1E-3 [#288](https://github.com/roo-rb/roo/pull/288)
|
45
56
|
- Include all tests in default rake run [#283](https://github.com/roo-rb/roo/pull/283)
|
46
57
|
- Fix zero-padded numbers for Excelx [#282](https://github.com/roo-rb/roo/pull/282)
|
47
58
|
|
data/Gemfile
CHANGED
data/Gemfile_ruby2
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Install as a gem
|
|
18
18
|
Or add it to your Gemfile
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
gem
|
21
|
+
gem "roo", "~> 2.6.0"
|
22
22
|
```
|
23
23
|
## Usage
|
24
24
|
|
@@ -256,10 +256,11 @@ Roo's public methods have stayed relatively consistent between 1.13.x and 2.0.0,
|
|
256
256
|
## Contributing
|
257
257
|
### Features
|
258
258
|
1. Fork it ( https://github.com/[my-github-username]/roo/fork )
|
259
|
-
2.
|
260
|
-
3.
|
261
|
-
4.
|
262
|
-
5.
|
259
|
+
2. Install it (`bundle install --with local_development`)
|
260
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
261
|
+
4. Commit your changes (`git commit -am 'My new feature'`)
|
262
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
263
|
+
6. Create a new Pull Request
|
263
264
|
|
264
265
|
### Issues
|
265
266
|
|
data/lib/roo/base.rb
CHANGED
@@ -183,7 +183,7 @@ class Roo::Base
|
|
183
183
|
options = (args.last.is_a?(Hash) ? args.pop : {})
|
184
184
|
|
185
185
|
case args[0]
|
186
|
-
when
|
186
|
+
when Integer
|
187
187
|
find_by_row(args[0])
|
188
188
|
when :all
|
189
189
|
find_by_conditions(options)
|
@@ -225,7 +225,7 @@ class Roo::Base
|
|
225
225
|
|
226
226
|
def cell_type_by_value(value)
|
227
227
|
case value
|
228
|
-
when
|
228
|
+
when Integer then :float
|
229
229
|
when String, Float then :string
|
230
230
|
else
|
231
231
|
fail ArgumentError, "Type for #{value} not set"
|
@@ -590,7 +590,7 @@ class Roo::Base
|
|
590
590
|
# converts cell coordinate to numeric values of row,col
|
591
591
|
def normalize(row, col)
|
592
592
|
if row.is_a?(::String)
|
593
|
-
if col.is_a?(::
|
593
|
+
if col.is_a?(::Integer)
|
594
594
|
# ('A',1):
|
595
595
|
# ('B', 5) -> (5, 2)
|
596
596
|
row, col = col, row
|
@@ -605,7 +605,7 @@ class Roo::Base
|
|
605
605
|
end
|
606
606
|
|
607
607
|
def uri?(filename)
|
608
|
-
filename.start_with?('http://', 'https://')
|
608
|
+
filename.start_with?('http://', 'https://', 'ftp://')
|
609
609
|
rescue
|
610
610
|
false
|
611
611
|
end
|
@@ -646,7 +646,7 @@ class Roo::Base
|
|
646
646
|
case sheet
|
647
647
|
when nil
|
648
648
|
fail ArgumentError, "Error: sheet 'nil' not valid"
|
649
|
-
when
|
649
|
+
when Integer
|
650
650
|
sheets.fetch(sheet - 1) do
|
651
651
|
fail RangeError, "sheet index #{sheet} not found"
|
652
652
|
end
|
@@ -714,7 +714,7 @@ class Roo::Base
|
|
714
714
|
case onecell
|
715
715
|
when String
|
716
716
|
%("#{onecell.gsub('"', '""')}") unless onecell.empty?
|
717
|
-
when
|
717
|
+
when Integer
|
718
718
|
onecell.to_s
|
719
719
|
when Float
|
720
720
|
if onecell == onecell.to_i
|
data/lib/roo/csv.rb
CHANGED
@@ -41,6 +41,14 @@ class Roo::CSV < Roo::Base
|
|
41
41
|
@options[:csv_options] || {}
|
42
42
|
end
|
43
43
|
|
44
|
+
def set_value(row, col, value, _sheet)
|
45
|
+
@cell[[row, col]] = value
|
46
|
+
end
|
47
|
+
|
48
|
+
def set_type(row, col, type, _sheet)
|
49
|
+
@cell_type[[row, col]] = type
|
50
|
+
end
|
51
|
+
|
44
52
|
private
|
45
53
|
|
46
54
|
TYPE_MAP = {
|
data/lib/roo/errors.rb
CHANGED
data/lib/roo/excelx.rb
CHANGED
@@ -363,7 +363,7 @@ module Roo
|
|
363
363
|
def extract_sheets_in_order(entries, sheet_ids, sheets, tmpdir)
|
364
364
|
(sheet_ids & sheets.keys).each_with_index do |id, i|
|
365
365
|
name = sheets[id]
|
366
|
-
entry = entries.find { |e| e.name =~ /#{name}$/ }
|
366
|
+
entry = entries.find { |e| "/#{e.name}" =~ /#{name}$/ }
|
367
367
|
path = "#{tmpdir}/roo_sheet#{i + 1}"
|
368
368
|
sheet_files << path
|
369
369
|
@sheet_files << path
|
data/lib/roo/excelx/extractor.rb
CHANGED
@@ -8,9 +8,9 @@ module Roo
|
|
8
8
|
private
|
9
9
|
|
10
10
|
def doc
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
raise FileNotFound, "#{@path} file not found" unless doc_exists?
|
12
|
+
|
13
|
+
::Roo::Utils.load_xml(@path).remove_namespaces!
|
14
14
|
end
|
15
15
|
|
16
16
|
def doc_exists?
|
data/lib/roo/excelx/styles.rb
CHANGED
data/lib/roo/version.rb
CHANGED
data/spec/lib/roo/csv_spec.rb
CHANGED
@@ -66,4 +66,16 @@ describe Roo::CSV do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
|
+
|
70
|
+
describe '#set_value' do
|
71
|
+
it 'returns the cell value' do
|
72
|
+
expect(csv.set_value('A', 1, 'some-value', nil)).to eq('some-value')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#set_type' do
|
77
|
+
it 'returns the cell type' do
|
78
|
+
expect(csv.set_type('A', 1, 'some-type', nil)).to eq('some-type')
|
79
|
+
end
|
80
|
+
end
|
69
81
|
end
|
data/spec/lib/roo/excelx_spec.rb
CHANGED
@@ -524,4 +524,14 @@ describe Roo::Excelx do
|
|
524
524
|
expect{ subject }.to_not raise_error
|
525
525
|
end
|
526
526
|
end
|
527
|
+
|
528
|
+
describe 'opening a file with white space in the styles.xml' do
|
529
|
+
let(:path) { 'test/files/style_nodes_with_white_spaces.xlsx' }
|
530
|
+
subject(:xlsx) do
|
531
|
+
Roo::Spreadsheet.open(path, expand_merged_ranges: true, extension: :xlsx)
|
532
|
+
end
|
533
|
+
it 'should properly recognize formats' do
|
534
|
+
expect(subject.sheet(0).excelx_format(2,1)).to eq 'm/d/yyyy" "h:mm:ss" "AM/PM'
|
535
|
+
end
|
536
|
+
end
|
527
537
|
end
|
@@ -13,10 +13,10 @@ describe Roo::OpenOffice do
|
|
13
13
|
context 'for float/integer values' do
|
14
14
|
context 'integer without point' do
|
15
15
|
it { expect(subject.cell(3,"A","Sheet4")).to eq(1234) }
|
16
|
-
it { expect(subject.cell(3,"A","Sheet4")).to be_a(
|
16
|
+
it { expect(subject.cell(3,"A","Sheet4")).to be_a(Integer) }
|
17
17
|
end
|
18
18
|
|
19
|
-
context 'float with point' do
|
19
|
+
context 'float with point' do
|
20
20
|
it { expect(subject.cell(3,"B","Sheet4")).to eq(1234.00) }
|
21
21
|
it { expect(subject.cell(3,"B","Sheet4")).to be_a(Float) }
|
22
22
|
end
|
data/test/test_roo.rb
CHANGED
@@ -1056,14 +1056,14 @@ Sheet 3:
|
|
1056
1056
|
def test_bug_to_xml_with_empty_sheets
|
1057
1057
|
with_each_spreadsheet(:name=>'emptysheets', :format=>[:openoffice, :excelx]) do |oo|
|
1058
1058
|
oo.sheets.each { |sheet|
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1059
|
+
assert_nil oo.first_row, "first_row not nil in sheet #{sheet}"
|
1060
|
+
assert_nil oo.last_row, "last_row not nil in sheet #{sheet}"
|
1061
|
+
assert_nil oo.first_column, "first_column not nil in sheet #{sheet}"
|
1062
|
+
assert_nil oo.last_column, "last_column not nil in sheet #{sheet}"
|
1063
|
+
assert_nil oo.first_row(sheet), "first_row not nil in sheet #{sheet}"
|
1064
|
+
assert_nil oo.last_row(sheet), "last_row not nil in sheet #{sheet}"
|
1065
|
+
assert_nil oo.first_column(sheet), "first_column not nil in sheet #{sheet}"
|
1066
|
+
assert_nil oo.last_column(sheet), "last_column not nil in sheet #{sheet}"
|
1067
1067
|
}
|
1068
1068
|
oo.to_xml
|
1069
1069
|
end
|
@@ -2109,4 +2109,9 @@ where the expected result is
|
|
2109
2109
|
with_each_spreadsheet(:name=>'non_existent_file', :ignore_errors=>true) do |oo|; end
|
2110
2110
|
assert_equal Dir.open(Dir.tmpdir).to_a, old_temp_files
|
2111
2111
|
end
|
2112
|
+
|
2113
|
+
def test_name_with_leading_slash
|
2114
|
+
xlsx = Roo::Excelx.new(File.join(TESTDIR,'name_with_leading_slash.xlsx'))
|
2115
|
+
assert_equal 1, xlsx.sheets.count
|
2116
|
+
end
|
2112
2117
|
end # class
|
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.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Preymesser
|
@@ -12,74 +12,74 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2016-
|
15
|
+
date: 2016-12-28 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: nokogiri
|
19
19
|
requirement: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: '1'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
|
-
- -
|
28
|
+
- - ~>
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '1'
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: rubyzip
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '1.1'
|
38
|
-
- -
|
38
|
+
- - <
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.0.0
|
41
41
|
type: :runtime
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.1'
|
48
|
-
- -
|
48
|
+
- - <
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: 2.0.0
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
name: rake
|
53
53
|
requirement: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- -
|
55
|
+
- - ~>
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '10.1'
|
58
58
|
type: :development
|
59
59
|
prerelease: false
|
60
60
|
version_requirements: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
|
-
- -
|
62
|
+
- - ~>
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '10.1'
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
66
|
name: minitest
|
67
67
|
requirement: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - ~>
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '5.4'
|
72
|
-
- -
|
72
|
+
- - '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 5.4.3
|
75
75
|
type: :development
|
76
76
|
prerelease: false
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ~>
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '5.4'
|
82
|
-
- -
|
82
|
+
- - '>='
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: 5.4.3
|
85
85
|
description: |-
|
@@ -95,10 +95,10 @@ executables: []
|
|
95
95
|
extensions: []
|
96
96
|
extra_rdoc_files: []
|
97
97
|
files:
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
98
|
+
- .github/ISSUE_TEMPLATE
|
99
|
+
- .gitignore
|
100
|
+
- .simplecov
|
101
|
+
- .travis.yml
|
102
102
|
- CHANGELOG.md
|
103
103
|
- Gemfile
|
104
104
|
- Gemfile_ruby2
|
@@ -178,19 +178,18 @@ require_paths:
|
|
178
178
|
- lib
|
179
179
|
required_ruby_version: !ruby/object:Gem::Requirement
|
180
180
|
requirements:
|
181
|
-
- -
|
181
|
+
- - '>='
|
182
182
|
- !ruby/object:Gem::Version
|
183
183
|
version: '0'
|
184
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
|
-
- -
|
186
|
+
- - '>='
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: '0'
|
189
189
|
requirements: []
|
190
190
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.
|
191
|
+
rubygems_version: 2.0.14
|
192
192
|
signing_key:
|
193
193
|
specification_version: 4
|
194
194
|
summary: Roo can access the contents of various spreadsheet files.
|
195
195
|
test_files: []
|
196
|
-
has_rdoc:
|