roo 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ require 'roo/excelx/cell/base'
2
+ require 'roo/excelx/cell/datetime'
3
+ require 'roo/excelx/cell/time'
4
+ require 'roo/link'
5
+
6
+ class TestRooExcelxCellTime < Minitest::Test
7
+ def time
8
+ Roo::Excelx::Cell::Time
9
+ end
10
+
11
+ def base_date
12
+ Date.new(1899, 12, 30)
13
+ end
14
+
15
+ def test_formatted_value
16
+ value = '0.0751' # 6488.64 seconds, or 1:48:08.64
17
+ [
18
+ ['h:mm', '1:48'],
19
+ ['h:mm:ss', '1:48:09'],
20
+ ['mm:ss', '48:09'],
21
+ ['[h]:mm:ss', '[1]:48:09'],
22
+ ['mmss.0', '4809.0'] # Cell::Time always get rounded to the nearest second.
23
+ ].each do |style_format, result|
24
+ cell = time.new(value, nil, [:numeric_or_formula, style_format], 6, nil, base_date, nil)
25
+ assert_equal result, cell.formatted_value, "Style=#{style_format} is not properly formatted"
26
+ end
27
+ end
28
+
29
+ def test_value
30
+ cell = time.new('0.0751', nil, [:numeric_or_formula, 'h:mm'], 6, nil, base_date, nil)
31
+ assert_kind_of Fixnum, cell.value
32
+ end
33
+ end
data/test/test_roo.rb CHANGED
@@ -249,9 +249,9 @@ class TestRoo < Minitest::Test
249
249
  assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
250
250
 
251
251
  # Cells values in row 3:
252
- assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
253
- assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
254
- assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
252
+ assert_equal "1:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
253
+ assert_equal "3:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
254
+ assert_equal "1:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
255
255
 
256
256
  # Cells values in row 4:
257
257
  assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
@@ -1161,8 +1161,14 @@ Sheet 3:
1161
1161
  def test_cell_boolean
1162
1162
  with_each_spreadsheet(:name=>'boolean', :format=>[:openoffice, :excelx]) do |oo|
1163
1163
  if oo.class == Roo::Excelx
1164
- assert_equal "TRUE", oo.cell(1,1), "failure in "+oo.class.to_s
1165
- assert_equal "FALSE", oo.cell(2,1), "failure in "+oo.class.to_s
1164
+ assert_equal true, oo.cell(1, 1), "failure in #{oo.class}"
1165
+ assert_equal false, oo.cell(2, 1), "failure in #{oo.class}"
1166
+
1167
+ cell = oo.sheet_for(oo.default_sheet).cells[[1, 1,]]
1168
+ assert_equal 'TRUE', cell.formatted_value
1169
+
1170
+ cell = oo.sheet_for(oo.default_sheet).cells[[2, 1,]]
1171
+ assert_equal 'FALSE', cell.formatted_value
1166
1172
  else
1167
1173
  assert_equal "true", oo.cell(1,1), "failure in "+oo.class.to_s
1168
1174
  assert_equal "false", oo.cell(2,1), "failure in "+oo.class.to_s
@@ -1307,12 +1313,12 @@ Sheet 3:
1307
1313
  assert_equal 13, oo.d4 # cell(4,'D')
1308
1314
  assert_equal 14, oo.e4 # cell(4,'E')
1309
1315
  assert_equal 'ABC', oo.c6('Sheet5')
1316
+ assert_equal 41, oo.a12
1310
1317
 
1311
- #assert_raises(ArgumentError) {
1312
- assert_raises(NoMethodError) {
1318
+ assert_raises(NoMethodError) do
1313
1319
  # a42a is not a valid cell name, should raise ArgumentError
1314
1320
  assert_equal 9999, oo.a42a
1315
- }
1321
+ end
1316
1322
  end
1317
1323
  end
1318
1324
 
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Preymesser
8
8
  - Hugh McGowan
9
9
  - Ben Woosley
10
10
  - Oleksandr Simonov
11
+ - Steven Daniels
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2015-08-01 00:00:00.000000000 Z
15
+ date: 2015-10-31 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: nokogiri
@@ -110,11 +111,23 @@ files:
110
111
  - lib/roo/base.rb
111
112
  - lib/roo/constants.rb
112
113
  - lib/roo/csv.rb
114
+ - lib/roo/errors.rb
113
115
  - lib/roo/excelx.rb
114
116
  - lib/roo/excelx/cell.rb
117
+ - lib/roo/excelx/cell/base.rb
118
+ - lib/roo/excelx/cell/boolean.rb
119
+ - lib/roo/excelx/cell/date.rb
120
+ - lib/roo/excelx/cell/datetime.rb
121
+ - lib/roo/excelx/cell/empty.rb
122
+ - lib/roo/excelx/cell/number.rb
123
+ - lib/roo/excelx/cell/string.rb
124
+ - lib/roo/excelx/cell/time.rb
115
125
  - lib/roo/excelx/comments.rb
126
+ - lib/roo/excelx/coordinate.rb
116
127
  - lib/roo/excelx/extractor.rb
128
+ - lib/roo/excelx/format.rb
117
129
  - lib/roo/excelx/relationships.rb
130
+ - lib/roo/excelx/shared.rb
118
131
  - lib/roo/excelx/shared_strings.rb
119
132
  - lib/roo/excelx/sheet.rb
120
133
  - lib/roo/excelx/sheet_doc.rb
@@ -142,6 +155,14 @@ files:
142
155
  - spec/lib/roo/utils_spec.rb
143
156
  - spec/spec_helper.rb
144
157
  - test/all_ss.rb
158
+ - test/excelx/cell/test_base.rb
159
+ - test/excelx/cell/test_boolean.rb
160
+ - test/excelx/cell/test_date.rb
161
+ - test/excelx/cell/test_datetime.rb
162
+ - test/excelx/cell/test_empty.rb
163
+ - test/excelx/cell/test_number.rb
164
+ - test/excelx/cell/test_string.rb
165
+ - test/excelx/cell/test_time.rb
145
166
  - test/test_helper.rb
146
167
  - test/test_roo.rb
147
168
  homepage: http://github.com/roo-rb/roo