spreadsheet 0.8.8 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 0.8.9 / 24.08.2013
2
+
3
+ Author: Doug Renn <renn@nestegg.com>
4
+ Date: Fri Aug 23 17:10:24 2013 -0600
5
+
6
+ * Work around to handle number formats that are being mistaken time formats
7
+
1
8
  === 0.8.8 / 02.08.2013
2
9
 
3
10
  Author: Nathan Colgate <nathancolgate@gmail.com>
data/lib/spreadsheet.rb CHANGED
@@ -43,7 +43,7 @@ module Spreadsheet
43
43
 
44
44
  ##
45
45
  # The version of Spreadsheet you are using.
46
- VERSION = '0.8.8'
46
+ VERSION = '0.8.9'
47
47
 
48
48
  ##
49
49
  # Default client Encoding. Change this value if your application uses a
@@ -104,7 +104,8 @@ module Spreadsheet
104
104
  :date => Regexp.new(client("[YMD]", 'UTF-8')),
105
105
  :date_or_time => Regexp.new(client("[hmsYMD]", 'UTF-8')),
106
106
  :datetime => Regexp.new(client("([YMD].*[HS])|([HS].*[YMD])", 'UTF-8')),
107
- :time => Regexp.new(client("[hms]", 'UTF-8'))
107
+ :time => Regexp.new(client("[hms]", 'UTF-8')),
108
+ :number => Regexp.new(client("[\#]", 'UTF-8'))
108
109
  }
109
110
  # Temp code to prevent merged formats in non-merged cells.
110
111
  @used_merge = 0
@@ -178,22 +179,27 @@ module Spreadsheet
178
179
  ##
179
180
  # Is the cell formatted as a Date?
180
181
  def date?
181
- !!@regexes[:date].match(@number_format.to_s)
182
+ !number? && !!@regexes[:date].match(@number_format.to_s)
182
183
  end
183
184
  ##
184
185
  # Is the cell formatted as a Date or Time?
185
186
  def date_or_time?
186
- !!@regexes[:date_or_time].match(@number_format.to_s)
187
+ !number? && !!@regexes[:date_or_time].match(@number_format.to_s)
187
188
  end
188
189
  ##
189
190
  # Is the cell formatted as a DateTime?
190
191
  def datetime?
191
- !!@regexes[:datetime].match(@number_format.to_s)
192
+ !number? && !!@regexes[:datetime].match(@number_format.to_s)
192
193
  end
193
194
  ##
194
195
  # Is the cell formatted as a Time?
195
196
  def time?
196
- !!@regexes[:time].match(@number_format.to_s)
197
+ !number? && !!@regexes[:time].match(@number_format.to_s)
198
+ end
199
+ ##
200
+ # Is the cell formatted as a number?
201
+ def number?
202
+ !!@regexes[:number].match(@number_format.to_s)
197
203
  end
198
204
  end
199
205
  end
data/test/format.rb CHANGED
@@ -19,6 +19,8 @@ module Spreadsheet
19
19
  assert_equal true, @format.date?
20
20
  @format.number_format = "YMD"
21
21
  assert_equal true, @format.date?
22
+ @format.number_format = "\\$#,##0.00_);[RED]\"($\"#,##0.00\\)"
23
+ assert_equal false, @format.date?
22
24
  end
23
25
  def test_date_or_time?
24
26
  assert_equal false, @format.date_or_time?
@@ -28,6 +30,8 @@ module Spreadsheet
28
30
  assert_equal true, @format.date_or_time?
29
31
  @format.number_format = "hmsYMD"
30
32
  assert_equal true, @format.date_or_time?
33
+ @format.number_format = "\\$#,##0.00_);[RED]\"($\"#,##0.00\\)"
34
+ assert_equal false, @format.date?
31
35
  end
32
36
  def test_datetime?
33
37
  assert_equal false, @format.datetime?
@@ -39,6 +43,8 @@ module Spreadsheet
39
43
  assert_equal false, @format.datetime?
40
44
  @format.number_format = "HSYMD"
41
45
  assert_equal true, @format.datetime?
46
+ @format.number_format = "\\$#,##0.00_);[RED]\"($\"#,##0.00\\)"
47
+ assert_equal false, @format.date?
42
48
  end
43
49
  def test_time?
44
50
  assert_equal false, @format.time?
@@ -52,6 +58,8 @@ module Spreadsheet
52
58
  assert_equal true, @format.time?
53
59
  @format.number_format = "hms"
54
60
  assert_equal true, @format.time?
61
+ @format.number_format = "\\$#,##0.00_);[RED]\"($\"#,##0.00\\)"
62
+ assert_equal false, @format.date?
55
63
  end
56
64
  def test_borders?
57
65
  assert_equal [:none, :none, :none, :none], @format.border
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreadsheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.8.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-02 00:00:00.000000000 Z
12
+ date: 2013-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-ole