roo 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a61e2a1f190d2a30554f2bed45557c31573761e
4
- data.tar.gz: 3bebd2370044ab8c20911368291932337201bb73
3
+ metadata.gz: f9b79f7270fb925c4aa402c0bd1bcccfc422ac92
4
+ data.tar.gz: f5ed3e4155c09890a710265c3a31e308ec4660fa
5
5
  SHA512:
6
- metadata.gz: e57f90c7aad4b738399b3b3ff0e00b06cbe5fd9fd7ae68c8540f6086521d925db17a8219cacceb656012c3e2f10d814218d95a7ac2c188958c83c4c9425e5f4b
7
- data.tar.gz: f1fe2348405fcd5097465d761ba60b321cfd52d45957eef61fecf8d6a43a7afd59afeb11e873318f6188dd0b117219b93b87e9ec3d99e9421a2f9defbb195cb2
6
+ metadata.gz: bb21c71a0343bcce335b4ddc7b5b0caec8ba69d5059e09868e76a7494338fd11bd8d6dae0c0697dbc2ccef4564f7fa19ae56cc09b1c6bca22a6670b7ee1ada6c
7
+ data.tar.gz: 4563b478a1a0c71fbd7087097917b4eacc0a744d8f3d806ce02f8836b767f34a16c40e3207695180ff1a9882f74a6c9c6b354f84547fee5e91a0bf08959ff04a
@@ -1,3 +1,10 @@
1
+ ## [2.3.0] - 2015-12-10
2
+ ### Changed
3
+ - Excelx::Cell::Number will return a String instead of an Integer or Float if the cell has an error like #DIV/0, etc. [#273](https://github.com/roo-rb/roo/pull/273)
4
+
5
+ ### Fixed
6
+ - Excelx::Cell::Number now handles cell errors. [#273](https://github.com/roo-rb/roo/pull/273)
7
+
1
8
  ## [2.2.0] - 2015-10-31
2
9
  ### Added
3
10
  - Added support for returning Integers values to Roo::OpenOffice [#258](https://github.com/roo-rb/roo/pull/258)
@@ -2,6 +2,8 @@ module Roo
2
2
  class Excelx
3
3
  class Cell
4
4
  class Number < Cell::Base
5
+ ERROR_VALUES = %w(#N/A #REF! #NAME? #DIV/0! #NULL! #VALUE! #NUM!)
6
+
5
7
  attr_reader :value, :formula, :format, :cell_value, :link, :coordinate
6
8
 
7
9
  def initialize(value, formula, excelx_type, style, link, coordinate)
@@ -14,6 +16,8 @@ module Roo
14
16
  end
15
17
 
16
18
  def create_numeric(number)
19
+ return number if ERROR_VALUES.include?(number)
20
+
17
21
  case @format
18
22
  when /%/
19
23
  Float(number)
@@ -25,6 +29,8 @@ module Roo
25
29
  end
26
30
 
27
31
  def formatted_value
32
+ return @cell_value if ERROR_VALUES.include?(@cell_value)
33
+
28
34
  formatter = formats[@format]
29
35
  if formatter.is_a? Proc
30
36
  formatter.call(@cell_value)
@@ -1,3 +1,3 @@
1
1
  module Roo
2
- VERSION = "2.2.0"
2
+ VERSION = '2.3.0'
3
3
  end
@@ -34,6 +34,14 @@ class TestRooExcelxCellNumber < Minitest::Test
34
34
  end
35
35
  end
36
36
 
37
+ def test_numbers_with_cell_errors
38
+ %w(#N/A #REF! #NAME? #DIV/0! #NULL! #VALUE! #NUM!).each do |error|
39
+ cell = Roo::Excelx::Cell::Number.new error, nil, ['General'], nil, nil, nil
40
+ assert_equal error, cell.value
41
+ assert_equal error, cell.formatted_value
42
+ end
43
+ end
44
+
37
45
  def test_formats
38
46
  [
39
47
  ['General', '1042'],
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.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Preymesser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-10-31 00:00:00.000000000 Z
15
+ date: 2015-12-10 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: nokogiri