roo 2.6.0 → 2.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +17 -0
- data/.github/issue_template.md +16 -0
- data/.github/pull_request_template.md +14 -0
- data/.rubocop.yml +186 -0
- data/.travis.yml +14 -11
- data/CHANGELOG.md +64 -2
- data/Gemfile +2 -4
- data/LICENSE +2 -0
- data/README.md +36 -10
- data/lib/roo/base.rb +82 -225
- data/lib/roo/constants.rb +5 -3
- data/lib/roo/csv.rb +100 -97
- data/lib/roo/excelx/cell/base.rb +26 -12
- data/lib/roo/excelx/cell/boolean.rb +9 -6
- data/lib/roo/excelx/cell/date.rb +7 -7
- data/lib/roo/excelx/cell/datetime.rb +50 -44
- data/lib/roo/excelx/cell/empty.rb +3 -2
- data/lib/roo/excelx/cell/number.rb +44 -47
- data/lib/roo/excelx/cell/string.rb +3 -3
- data/lib/roo/excelx/cell/time.rb +17 -16
- data/lib/roo/excelx/cell.rb +10 -6
- data/lib/roo/excelx/comments.rb +3 -3
- data/lib/roo/excelx/coordinate.rb +11 -4
- data/lib/roo/excelx/extractor.rb +21 -3
- data/lib/roo/excelx/format.rb +38 -31
- data/lib/roo/excelx/images.rb +26 -0
- data/lib/roo/excelx/relationships.rb +12 -4
- data/lib/roo/excelx/shared.rb +10 -3
- data/lib/roo/excelx/shared_strings.rb +9 -15
- data/lib/roo/excelx/sheet.rb +49 -10
- data/lib/roo/excelx/sheet_doc.rb +89 -48
- data/lib/roo/excelx/styles.rb +3 -3
- data/lib/roo/excelx/workbook.rb +7 -3
- data/lib/roo/excelx.rb +50 -19
- 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/helpers/default_attr_reader.rb +20 -0
- data/lib/roo/helpers/weak_instance_cache.rb +41 -0
- data/lib/roo/open_office.rb +17 -9
- data/lib/roo/spreadsheet.rb +1 -1
- data/lib/roo/tempdir.rb +5 -10
- data/lib/roo/utils.rb +70 -20
- data/lib/roo/version.rb +1 -1
- data/lib/roo.rb +4 -1
- data/roo.gemspec +14 -11
- data/spec/lib/roo/base_spec.rb +45 -3
- data/spec/lib/roo/excelx/relationships_spec.rb +43 -0
- data/spec/lib/roo/excelx/sheet_doc_spec.rb +11 -0
- data/spec/lib/roo/excelx_spec.rb +150 -31
- data/spec/lib/roo/strict_spec.rb +43 -0
- data/spec/lib/roo/utils_spec.rb +25 -3
- data/spec/lib/roo/weak_instance_cache_spec.rb +92 -0
- data/spec/lib/roo_spec.rb +0 -0
- data/spec/spec_helper.rb +2 -6
- data/test/excelx/cell/test_attr_reader_default.rb +72 -0
- data/test/excelx/cell/test_base.rb +5 -0
- data/test/excelx/cell/test_datetime.rb +6 -6
- data/test/excelx/cell/test_empty.rb +11 -0
- data/test/excelx/cell/test_number.rb +9 -0
- data/test/excelx/cell/test_string.rb +20 -0
- data/test/excelx/cell/test_time.rb +5 -5
- data/test/excelx/test_coordinate.rb +51 -0
- data/test/formatters/test_csv.rb +136 -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 +88 -0
- data/test/roo/test_excelx.rb +330 -0
- data/test/roo/test_libre_office.rb +9 -0
- data/test/roo/test_open_office.rb +289 -0
- data/test/test_helper.rb +129 -14
- data/test/test_roo.rb +32 -1787
- metadata +81 -29
- data/.github/ISSUE_TEMPLATE +0 -10
- data/Gemfile_ruby2 +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1e41bf12228c4a168e8df0a0cbf5b94eceaa89a1f5d174f3a3588a1a965d49f4
|
4
|
+
data.tar.gz: 69d749c2667ba4efbdcd7257550ba380d6ba0250633d439ae738673e6d2b5924
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14c8d1e69b31e1be16c8845c686e596c108e9c4251e4d5ee75471dd8ea325c2aacdcf1fa4b10f6262cd840bd063de5b11432439a9bce1b82b4c350566981bb48
|
7
|
+
data.tar.gz: 7a01fefbe77485af0252384dcd20770e0c993c29b916be55736a86fcdc8de710d99709fb09d95f4d628a2b3819069c3aba5df28f3488a5f519753b854c82cd48
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Thanks for filing an issue. Following these instructions will help us solve your problem sooner.
|
2
|
+
|
3
|
+
### Steps to reproduce
|
4
|
+
|
5
|
+
1. Create an executable test case for this issue ([sample test case](https://gist.github.com/tgturner/e4b7f491639b8a6dd883fe2ace408652))
|
6
|
+
2. You can share your executable test case as a [gist](https://gist.github.com), or simply paste the content into the issue description.
|
7
|
+
- You can execute the test case by running `ruby the_file.rb` in your terminal. If all goes well, you should see your test case failing.
|
8
|
+
3. Please provide a stripped down version of the offending spreadsheet.
|
9
|
+
|
10
|
+
### Issue
|
11
|
+
Describe the issue
|
12
|
+
|
13
|
+
### System configuration
|
14
|
+
**Roo version**:
|
15
|
+
|
16
|
+
**Ruby version**:
|
@@ -0,0 +1,14 @@
|
|
1
|
+
### Summary
|
2
|
+
|
3
|
+
Provide a general description of the code changes in your pull
|
4
|
+
request... were there any bugs you had fixed? If so, mention them. If
|
5
|
+
these bugs have open GitHub issues, be sure to tag them here as well,
|
6
|
+
to keep the conversation linked together.
|
7
|
+
|
8
|
+
### Other Information
|
9
|
+
|
10
|
+
If there's anything else that's important and relevant to your pull
|
11
|
+
request, mention that information here. This could include
|
12
|
+
benchmarks, or other information.
|
13
|
+
|
14
|
+
Thanks for contributing to Roo!
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
4
|
+
# to ignore them, so only the ones explicitly set in this file are enabled.
|
5
|
+
DisabledByDefault: true
|
6
|
+
|
7
|
+
Performance:
|
8
|
+
Exclude:
|
9
|
+
- '**/test/**/*'
|
10
|
+
- '**/spec/**/*'
|
11
|
+
|
12
|
+
# Prefer &&/|| over and/or.
|
13
|
+
Style/AndOr:
|
14
|
+
Enabled: true
|
15
|
+
|
16
|
+
# Do not use braces for hash literals when they are the last argument of a
|
17
|
+
# method call.
|
18
|
+
Style/BracesAroundHashParameters:
|
19
|
+
Enabled: true
|
20
|
+
EnforcedStyle: context_dependent
|
21
|
+
|
22
|
+
# Align `when` with `case`.
|
23
|
+
Layout/CaseIndentation:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
# Align comments with method definitions.
|
27
|
+
Layout/CommentIndentation:
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
Layout/ElseAlignment:
|
31
|
+
Enabled: true
|
32
|
+
|
33
|
+
# Align `end` with the matching keyword or starting expression except for
|
34
|
+
# assignments, where it should be aligned with the LHS.
|
35
|
+
Layout/EndAlignment:
|
36
|
+
Enabled: true
|
37
|
+
EnforcedStyleAlignWith: variable
|
38
|
+
AutoCorrect: true
|
39
|
+
|
40
|
+
Layout/EmptyLineAfterMagicComment:
|
41
|
+
Enabled: true
|
42
|
+
|
43
|
+
Layout/EmptyLinesAroundBlockBody:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
# In a regular class definition, no empty lines around the body.
|
47
|
+
Layout/EmptyLinesAroundClassBody:
|
48
|
+
Enabled: true
|
49
|
+
|
50
|
+
# In a regular method definition, no empty lines around the body.
|
51
|
+
Layout/EmptyLinesAroundMethodBody:
|
52
|
+
Enabled: true
|
53
|
+
|
54
|
+
# In a regular module definition, no empty lines around the body.
|
55
|
+
Layout/EmptyLinesAroundModuleBody:
|
56
|
+
Enabled: true
|
57
|
+
|
58
|
+
Layout/FirstParameterIndentation:
|
59
|
+
Enabled: true
|
60
|
+
|
61
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
62
|
+
Style/HashSyntax:
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
66
|
+
# extra level of indentation.
|
67
|
+
Layout/IndentationConsistency:
|
68
|
+
Enabled: true
|
69
|
+
|
70
|
+
# Two spaces, no tabs (for indentation).
|
71
|
+
Layout/IndentationWidth:
|
72
|
+
Enabled: true
|
73
|
+
|
74
|
+
Layout/LeadingCommentSpace:
|
75
|
+
Enabled: true
|
76
|
+
|
77
|
+
Layout/SpaceAfterColon:
|
78
|
+
Enabled: true
|
79
|
+
|
80
|
+
Layout/SpaceAfterComma:
|
81
|
+
Enabled: true
|
82
|
+
|
83
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
84
|
+
Enabled: true
|
85
|
+
|
86
|
+
Layout/SpaceAroundKeyword:
|
87
|
+
Enabled: true
|
88
|
+
|
89
|
+
Layout/SpaceAroundOperators:
|
90
|
+
Enabled: true
|
91
|
+
|
92
|
+
Layout/SpaceBeforeComma:
|
93
|
+
Enabled: true
|
94
|
+
|
95
|
+
Layout/SpaceBeforeFirstArg:
|
96
|
+
Enabled: true
|
97
|
+
|
98
|
+
Style/DefWithParentheses:
|
99
|
+
Enabled: true
|
100
|
+
|
101
|
+
# Defining a method with parameters needs parentheses.
|
102
|
+
Style/MethodDefParentheses:
|
103
|
+
Enabled: true
|
104
|
+
|
105
|
+
Style/FrozenStringLiteralComment:
|
106
|
+
Enabled: true
|
107
|
+
EnforcedStyle: always
|
108
|
+
|
109
|
+
# Use `foo {}` not `foo{}`.
|
110
|
+
Layout/SpaceBeforeBlockBraces:
|
111
|
+
Enabled: true
|
112
|
+
|
113
|
+
# Use `foo { bar }` not `foo {bar}`.
|
114
|
+
Layout/SpaceInsideBlockBraces:
|
115
|
+
Enabled: true
|
116
|
+
|
117
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
118
|
+
Layout/SpaceInsideHashLiteralBraces:
|
119
|
+
Enabled: true
|
120
|
+
|
121
|
+
Layout/SpaceInsideParens:
|
122
|
+
Enabled: true
|
123
|
+
|
124
|
+
# Check quotes usage according to lint rule below.
|
125
|
+
Style/StringLiterals:
|
126
|
+
Enabled: true
|
127
|
+
EnforcedStyle: double_quotes
|
128
|
+
|
129
|
+
# Detect hard tabs, no hard tabs.
|
130
|
+
Layout/Tab:
|
131
|
+
Enabled: true
|
132
|
+
|
133
|
+
# Blank lines should not have any spaces.
|
134
|
+
Layout/TrailingBlankLines:
|
135
|
+
Enabled: true
|
136
|
+
|
137
|
+
# No trailing whitespace.
|
138
|
+
Layout/TrailingWhitespace:
|
139
|
+
Enabled: true
|
140
|
+
|
141
|
+
# Use quotes for string literals when they are enough.
|
142
|
+
Style/UnneededPercentQ:
|
143
|
+
Enabled: true
|
144
|
+
|
145
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
146
|
+
Lint/RequireParentheses:
|
147
|
+
Enabled: true
|
148
|
+
|
149
|
+
Lint/StringConversionInInterpolation:
|
150
|
+
Enabled: true
|
151
|
+
|
152
|
+
Lint/UriEscapeUnescape:
|
153
|
+
Enabled: true
|
154
|
+
|
155
|
+
Style/ParenthesesAroundCondition:
|
156
|
+
Enabled: true
|
157
|
+
|
158
|
+
Style/RedundantReturn:
|
159
|
+
Enabled: true
|
160
|
+
AllowMultipleReturnValues: true
|
161
|
+
|
162
|
+
Style/Semicolon:
|
163
|
+
Enabled: true
|
164
|
+
AllowAsExpressionSeparator: true
|
165
|
+
|
166
|
+
# Prefer Foo.method over Foo::method
|
167
|
+
Style/ColonMethodCall:
|
168
|
+
Enabled: true
|
169
|
+
|
170
|
+
Style/TrivialAccessors:
|
171
|
+
Enabled: true
|
172
|
+
|
173
|
+
Performance/FlatMap:
|
174
|
+
Enabled: true
|
175
|
+
|
176
|
+
Performance/RedundantMerge:
|
177
|
+
Enabled: true
|
178
|
+
|
179
|
+
Performance/StartWith:
|
180
|
+
Enabled: true
|
181
|
+
|
182
|
+
Performance/EndWith:
|
183
|
+
Enabled: true
|
184
|
+
|
185
|
+
Performance/RegexpMatch:
|
186
|
+
Enabled: true
|
data/.travis.yml
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
3
|
+
- 2.3
|
4
|
+
- 2.4
|
5
|
+
- 2.5
|
6
|
+
- 2.6
|
6
7
|
- ruby-head
|
7
|
-
- jruby-
|
8
|
-
|
8
|
+
- jruby-9.1.6.0
|
9
|
+
env:
|
10
|
+
- LONG_RUN=true
|
9
11
|
matrix:
|
10
12
|
include:
|
11
|
-
- rvm: 2.
|
12
|
-
|
13
|
-
- rvm:
|
14
|
-
|
13
|
+
- rvm: 2.6
|
14
|
+
env: RUBYOPT=--jit LONG_RUN=true
|
15
|
+
- rvm: ruby-head
|
16
|
+
env: RUBYOPT=--jit LONG_RUN=true
|
15
17
|
allow_failures:
|
16
18
|
- rvm: ruby-head
|
17
|
-
- rvm:
|
18
|
-
|
19
|
+
- rvm: ruby-head
|
20
|
+
env: RUBYOPT=--jit LONG_RUN=true
|
21
|
+
- rvm: jruby-9.1.6.0
|
19
22
|
bundler_args: --without local_development
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,66 @@
|
|
1
|
-
##
|
1
|
+
## Unreleased
|
2
|
+
|
3
|
+
## [2.8.3] 2020-02-03
|
4
|
+
### Changed/Added
|
5
|
+
- Updated rubyzip version. Now minimal version is 1.3.0 [515](https://github.com/roo-rb/roo/pull/515) - [CVE-2019-16892](https://github.com/rubyzip/rubyzip/pull/403)
|
6
|
+
|
7
|
+
## [2.8.2] 2019-02-01
|
8
|
+
### Changed/Added
|
9
|
+
- Support range cell for Excelx's links [490](https://github.com/roo-rb/roo/pull/490)
|
10
|
+
- Skip `extract_hyperlinks` if not required [488](https://github.com/roo-rb/roo/pull/488)
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- Fixed error for invalid link [492](https://github.com/roo-rb/roo/pull/492)
|
14
|
+
|
15
|
+
## [2.8.1] 2019-01-21
|
16
|
+
### Fixed
|
17
|
+
- Fixed error if excelx's cell have empty children [487](https://github.com/roo-rb/roo/pull/487)
|
18
|
+
|
19
|
+
## [2.8.0] 2019-01-18
|
20
|
+
### Fixed
|
21
|
+
- Fixed inconsistent column length for CSV [375](https://github.com/roo-rb/roo/pull/375)
|
22
|
+
- Fixed formatted_value with `%` for Excelx [416](https://github.com/roo-rb/roo/pull/416)
|
23
|
+
- Improved Memory consumption and performance [434](https://github.com/roo-rb/roo/pull/434) [449](https://github.com/roo-rb/roo/pull/449) [454](https://github.com/roo-rb/roo/pull/454) [456](https://github.com/roo-rb/roo/pull/456) [458](https://github.com/roo-rb/roo/pull/458) [462](https://github.com/roo-rb/roo/pull/462) [466](https://github.com/roo-rb/roo/pull/466)
|
24
|
+
- Accept both Transitional and Strict Type for Excelx's worksheets [441](https://github.com/roo-rb/roo/pull/441)
|
25
|
+
- Fixed ruby warnings [442](https://github.com/roo-rb/roo/pull/442) [476](https://github.com/roo-rb/roo/pull/476)
|
26
|
+
- Restore support for URL as file identifier for CSV [462](https://github.com/roo-rb/roo/pull/462)
|
27
|
+
- Fixed missing location for Excelx's links [482](https://github.com/roo-rb/roo/pull/482)
|
28
|
+
|
29
|
+
### Changed / Added
|
30
|
+
- Drop support for ruby 2.2.x and lower
|
31
|
+
- Updated rubyzip version for fixing security issue. Now minimal version is 1.2.1
|
32
|
+
- Roo::Excelx::Coordinate now inherits Array [458](https://github.com/roo-rb/roo/pull/458)
|
33
|
+
- Improved Roo::HeaderRowNotFoundError exception's message [461](https://github.com/roo-rb/roo/pull/461)
|
34
|
+
- Added `empty_cell` option which by default disable allocation for Roo::Excelx::Cell::Empty [464](https://github.com/roo-rb/roo/pull/464)
|
35
|
+
- Added support for variable number of decimals for Excelx's formatted_value [387](https://github.com/roo-rb/roo/pull/387)
|
36
|
+
- Added `disable_html_injection` option to disable html injection for shared string in `Roo::Excelx` [392](https://github.com/roo-rb/roo/pull/392)
|
37
|
+
- Added image extraction for Excelx [414](https://github.com/roo-rb/roo/pull/414) [397](https://github.com/roo-rb/roo/pull/397)
|
38
|
+
- Added support for `1e6` as scientific notation for Excelx [433](https://github.com/roo-rb/roo/pull/433)
|
39
|
+
- Added support for Integer as 0 based index for Excelx's `sheet_for` [455](https://github.com/roo-rb/roo/pull/455)
|
40
|
+
- Extended `no_hyperlinks` option for non streaming Excelx methods [459](https://github.com/roo-rb/roo/pull/459)
|
41
|
+
- Added `empty_cell` option to disable Roo::Excelx::Cell::Empty allocation for Excelx [464](https://github.com/roo-rb/roo/pull/464)
|
42
|
+
- Added support for Integer with leading zero for Roo:Excelx [479](https://github.com/roo-rb/roo/pull/479)
|
43
|
+
- Refactored Excelx code [453](https://github.com/roo-rb/roo/pull/453) [477](https://github.com/roo-rb/roo/pull/477) [483](https://github.com/roo-rb/roo/pull/483) [484](https://github.com/roo-rb/roo/pull/484)
|
44
|
+
|
45
|
+
### Deprecations
|
46
|
+
- Roo::Excelx::Sheet#present_cells is deprecated [454](https://github.com/roo-rb/roo/pull/454)
|
47
|
+
- Roo::Utils.split_coordinate is deprecated [458](https://github.com/roo-rb/roo/pull/458)
|
48
|
+
- Roo::Excelx::Cell::Base#link is deprecated [457](https://github.com/roo-rb/roo/pull/457)
|
49
|
+
|
50
|
+
## [2.7.1] 2017-01-03
|
51
|
+
### Fixed
|
52
|
+
- Fixed regression where a CSV's encoding was being ignored [372](https://github.com/roo-rb/roo/pull/372)
|
53
|
+
|
54
|
+
## [2.7.0] 2016-12-31
|
55
|
+
### Fixed
|
56
|
+
- Added rack server for testing Roo's download capabilities [365](https://github.com/roo-rb/roo/pull/365)
|
57
|
+
- Refactored tests into different formats [365](https://github.com/roo-rb/roo/pull/365)
|
58
|
+
- Fixed OpenOffice for JRuby [362](https://github.com/roo-rb/roo/pull/362)
|
59
|
+
- Added '0.000000' => '%.6f' number format [354](https://github.com/roo-rb/roo/pull/354)
|
60
|
+
- Add additional formula cell types for to_csv [367][https://github.com/roo-rb/roo/pull/367]
|
61
|
+
|
62
|
+
### Added
|
63
|
+
- Extracted formatters from Roo::Base#to_* methods [364](https://github.com/roo-rb/roo/pull/364)
|
2
64
|
|
3
65
|
## [2.6.0] 2016-12-28
|
4
66
|
### Fixed
|
@@ -33,7 +95,7 @@
|
|
33
95
|
- Discard hyperlinks lookups to allow streaming parsing without loading whole files
|
34
96
|
|
35
97
|
## [2.4.0] 2016-05-14
|
36
|
-
### Fixed
|
98
|
+
### Fixed
|
37
99
|
- Fixed opening spreadsheets with charts [315](https://github.com/roo-rb/roo/pull/315)
|
38
100
|
- Fixed memory issues for Roo::Utils.number_to_letter [308](https://github.com/roo-rb/roo/pull/308)
|
39
101
|
- Fixed Roo::Excelx::Cell::Number to recognize floating point numbers [306](https://github.com/roo-rb/roo/pull/306)
|
data/Gemfile
CHANGED
@@ -4,13 +4,12 @@ gemspec
|
|
4
4
|
|
5
5
|
group :test do
|
6
6
|
# additional testing libs
|
7
|
-
gem 'webmock'
|
8
7
|
gem 'shoulda'
|
9
8
|
gem 'activesupport', '< 5.1'
|
10
9
|
gem 'rspec', '>= 3.0.0'
|
11
|
-
gem 'vcr'
|
12
10
|
gem 'simplecov', '>= 0.9.0', require: false
|
13
11
|
gem 'coveralls', require: false
|
12
|
+
gem "minitest-reporters"
|
14
13
|
end
|
15
14
|
|
16
15
|
group :local_development do
|
@@ -18,8 +17,7 @@ group :local_development do
|
|
18
17
|
gem 'guard-rspec', '>= 4.3.1', require: false
|
19
18
|
gem 'guard-minitest', require: false
|
20
19
|
gem 'guard-bundler', require: false
|
21
|
-
gem 'guard-preek', require: false
|
22
20
|
gem 'guard-rubocop', require: false
|
23
|
-
gem
|
21
|
+
gem "rb-readline"
|
24
22
|
gem 'pry'
|
25
23
|
end
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Roo
|
2
2
|
|
3
|
-
[![Build Status](https://img.shields.io/travis/roo-rb/roo.svg?style=flat-square)](https://travis-ci.org/roo-rb/roo) [![
|
3
|
+
[![Build Status](https://img.shields.io/travis/roo-rb/roo.svg?style=flat-square)](https://travis-ci.org/roo-rb/roo) [![Maintainability](https://api.codeclimate.com/v1/badges/be8d7bf34e2aeaf67c62/maintainability)](https://codeclimate.com/github/roo-rb/roo/maintainability) [![Coverage Status](https://img.shields.io/coveralls/roo-rb/roo.svg?style=flat-square)](https://coveralls.io/r/roo-rb/roo) [![Gem Version](https://img.shields.io/gem/v/roo.svg?style=flat-square)](https://rubygems.org/gems/roo)
|
4
4
|
|
5
5
|
Roo implements read access for all common spreadsheet types. It can handle:
|
6
6
|
* Excel 2007 - 2013 formats (xlsx, xlsm)
|
@@ -18,7 +18,7 @@ Install as a gem
|
|
18
18
|
Or add it to your Gemfile
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
gem "roo", "~> 2.
|
21
|
+
gem "roo", "~> 2.8.0"
|
22
22
|
```
|
23
23
|
## Usage
|
24
24
|
|
@@ -89,13 +89,13 @@ sheet.last_column
|
|
89
89
|
You can access the top-left cell in the following ways
|
90
90
|
|
91
91
|
```ruby
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
sheet.cell(1,1)
|
93
|
+
sheet.cell('A',1)
|
94
|
+
sheet.cell(1,'A')
|
95
|
+
sheet.a1
|
96
96
|
|
97
97
|
# Access the second sheet's top-left cell.
|
98
|
-
|
98
|
+
sheet.cell(1,'A',sheet.sheets[1])
|
99
99
|
```
|
100
100
|
|
101
101
|
#### Querying a spreadsheet
|
@@ -117,6 +117,12 @@ sheet.parse(id: /UPC|SKU/, qty: /ATS*\sATP\s*QTY\z/)
|
|
117
117
|
# => [{:id => 727880013358, :qty => 12}, ...]
|
118
118
|
```
|
119
119
|
|
120
|
+
Use the ``:headers`` option to include the header row in the parsed content.
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
sheet.parse(headers: true)
|
124
|
+
```
|
125
|
+
|
120
126
|
Use the ``:header_search`` option to locate the header row and assign the header names.
|
121
127
|
|
122
128
|
```ruby
|
@@ -129,6 +135,16 @@ Use the ``:clean`` option to strip out control characters and surrounding white
|
|
129
135
|
sheet.parse(clean: true)
|
130
136
|
```
|
131
137
|
|
138
|
+
#### Options
|
139
|
+
|
140
|
+
When opening the file you can add a hash of options.
|
141
|
+
|
142
|
+
##### expand_merged_ranges
|
143
|
+
If you open a document with merged cells and do not want to end up with nil values for the rows after the first one.
|
144
|
+
```ruby
|
145
|
+
xlsx = Roo::Excelx.new('./roo_error.xlsx', {:expand_merged_ranges => true})
|
146
|
+
```
|
147
|
+
|
132
148
|
### Exporting spreadsheets
|
133
149
|
Roo has the ability to export sheets using the following formats. It
|
134
150
|
will only export the ``default_sheet``.
|
@@ -230,7 +246,7 @@ ods.formula('A', 2)
|
|
230
246
|
|
231
247
|
```ruby
|
232
248
|
# Load a CSV file
|
233
|
-
|
249
|
+
csv = Roo::CSV.new("mycsv.csv")
|
234
250
|
```
|
235
251
|
|
236
252
|
Because Roo uses the [standard CSV library](), you can use options available to that library to parse csv files. You can pass options using the ``csv_options`` key.
|
@@ -240,10 +256,10 @@ For instance, you can load tab-delimited files (``.tsv``), and you can use a par
|
|
240
256
|
|
241
257
|
```ruby
|
242
258
|
# Load a tab-delimited csv
|
243
|
-
|
259
|
+
csv = Roo::CSV.new("mytsv.tsv", csv_options: {col_sep: "\t"})
|
244
260
|
|
245
261
|
# Load a csv with an explicit encoding
|
246
|
-
|
262
|
+
csv = Roo::CSV.new("mycsv.csv", csv_options: {encoding: Encoding::ISO_8859_1})
|
247
263
|
```
|
248
264
|
|
249
265
|
## Upgrading from Roo 1.13.x
|
@@ -262,6 +278,16 @@ Roo's public methods have stayed relatively consistent between 1.13.x and 2.0.0,
|
|
262
278
|
5. Push to the branch (`git push origin my-new-feature`)
|
263
279
|
6. Create a new Pull Request
|
264
280
|
|
281
|
+
### Testing
|
282
|
+
Roo uses Minitest and RSpec. The best of both worlds! Run `bundle exec rake` to
|
283
|
+
run the tests/examples.
|
284
|
+
|
285
|
+
You can run the tests/examples with Rspec like reporters by running
|
286
|
+
`USE_REPORTERS=true bundle exec rake`
|
287
|
+
|
288
|
+
Roo also has a few tests that take a long time (5+ seconds). To run these, use
|
289
|
+
`LONG_RUN=true bundle exec rake`
|
290
|
+
|
265
291
|
### Issues
|
266
292
|
|
267
293
|
If you find an issue, please create a gist and refer to it in an issue ([sample gist](https://gist.github.com/stevendaniels/98a05849036e99bb8b3c)). Here are some instructions for creating such a gist.
|