roo 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +3 -0
- data/lib/roo/excel.rb +21 -4
- data/lib/roo/generic_spreadsheet.rb +19 -3
- data/lib/roo/google.rb +17 -84
- data/lib/roo/openoffice.rb +11 -0
- data/lib/roo/version.rb +1 -1
- data/test/numbers1.csv +2 -2
- data/test/numbers1_excel.csv +2 -2
- data/test/test_roo.rb +122 -12
- data/test/time-test.csv +2 -0
- data/test/time-test.ods +0 -0
- data/test/time-test.xls +0 -0
- data/website/index.html +4 -2
- data/website/index.txt +2 -0
- metadata +5 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -29,6 +29,9 @@ test/simple_spreadsheet_from_italo.ods
|
|
29
29
|
test/simple_spreadsheet_from_italo.xls
|
30
30
|
test/test_helper.rb
|
31
31
|
test/test_roo.rb
|
32
|
+
test/time-test.ods
|
33
|
+
test/time-test.xls
|
34
|
+
test/time-test.csv
|
32
35
|
test/numbers1.csv
|
33
36
|
test/numbers1_excel.csv
|
34
37
|
test/numbers1.ods
|
data/lib/roo/excel.rb
CHANGED
@@ -102,7 +102,7 @@ class Excel < GenericSpreadsheet
|
|
102
102
|
worksheet = @workbook.worksheet(sheet_no(sheet))
|
103
103
|
skip = 0
|
104
104
|
line = 1
|
105
|
-
worksheet.each(skip) { |row_par|
|
105
|
+
worksheet.each(skip) { |row_par| #TODO: nicht jedesmal durch alle Zeilen gehen, sonder aus interner Repraesentation holen?
|
106
106
|
if line == row
|
107
107
|
if row_par == nil
|
108
108
|
return nil
|
@@ -112,7 +112,20 @@ class Excel < GenericSpreadsheet
|
|
112
112
|
case cell.type
|
113
113
|
when :numeric then return cell.to_f
|
114
114
|
when :text then return cell.to_s('utf-8')
|
115
|
-
|
115
|
+
# when :date then return cell.date
|
116
|
+
when :date
|
117
|
+
if cell.to_s.to_f < 1.0
|
118
|
+
f = cell.to_s.to_f*24.0*60.0*60.0
|
119
|
+
secs = f.round
|
120
|
+
h = (secs / 3600.0).floor
|
121
|
+
secs = secs - 3600*h
|
122
|
+
m = (secs / 60.0).floor
|
123
|
+
secs = secs - 60*m
|
124
|
+
s = secs
|
125
|
+
return h*3600+m*60+s
|
126
|
+
else
|
127
|
+
return cell.date
|
128
|
+
end
|
116
129
|
else
|
117
130
|
return nil # cell.to_s('utf-8')
|
118
131
|
end
|
@@ -121,7 +134,7 @@ class Excel < GenericSpreadsheet
|
|
121
134
|
}
|
122
135
|
end
|
123
136
|
|
124
|
-
# returns the type of a cell: :float, :string, :date
|
137
|
+
# returns the type of a cell: :float, :string, :date, :time
|
125
138
|
def celltype(row,col,sheet=nil)
|
126
139
|
sheet = @default_sheet unless sheet
|
127
140
|
row,col = normalize(row,col)
|
@@ -140,7 +153,11 @@ class Excel < GenericSpreadsheet
|
|
140
153
|
when :text
|
141
154
|
return :string
|
142
155
|
when :date
|
143
|
-
|
156
|
+
if cell.to_s.to_f < 1.0
|
157
|
+
return :time
|
158
|
+
else
|
159
|
+
return :date
|
160
|
+
end
|
144
161
|
else
|
145
162
|
return cell.type.to_sym
|
146
163
|
end
|
@@ -121,7 +121,11 @@ class GenericSpreadsheet
|
|
121
121
|
result << " row: #{row} \n"
|
122
122
|
result << " col: #{col} \n"
|
123
123
|
result << " celltype: #{self.celltype(row,col,sheet)} \n"
|
124
|
-
|
124
|
+
if self.celltype(row,col,sheet) == :time
|
125
|
+
result << " value: #{GenericSpreadsheet.integer_to_timestring( self.cell(row,col,sheet))} \n"
|
126
|
+
else
|
127
|
+
result << " value: #{self.cell(row,col,sheet)} \n"
|
128
|
+
end
|
125
129
|
end
|
126
130
|
end
|
127
131
|
end
|
@@ -442,7 +446,6 @@ class GenericSpreadsheet
|
|
442
446
|
end
|
443
447
|
end
|
444
448
|
|
445
|
-
#TODO: refactor to Generic...
|
446
449
|
def one_cell_output(onecelltype,onecell,empty)
|
447
450
|
str = ""
|
448
451
|
if empty
|
@@ -480,7 +483,11 @@ class GenericSpreadsheet
|
|
480
483
|
raise "unhandled onecell-class "+onecell.class.to_s
|
481
484
|
end
|
482
485
|
when :date
|
483
|
-
str << '"'+onecell.to_s+'"'
|
486
|
+
# str << '"'+onecell.to_s+'"'
|
487
|
+
str << onecell.to_s
|
488
|
+
# str << onecell.strftime("%d.%m.%y")
|
489
|
+
when :time
|
490
|
+
str << GenericSpreadsheet.integer_to_timestring(onecell)
|
484
491
|
else
|
485
492
|
raise "unhandled celltype "+onecelltype.to_s
|
486
493
|
end
|
@@ -489,4 +496,13 @@ class GenericSpreadsheet
|
|
489
496
|
str
|
490
497
|
end
|
491
498
|
|
499
|
+
private
|
500
|
+
def GenericSpreadsheet.integer_to_timestring(content)
|
501
|
+
h = (content/3600.0).floor
|
502
|
+
content = content - h*3600
|
503
|
+
m = (content/60.0).floor
|
504
|
+
content = content - m*60
|
505
|
+
s = content
|
506
|
+
sprintf("%02d:%02d:%02d",h,m,s)
|
507
|
+
end
|
492
508
|
end
|
data/lib/roo/google.rb
CHANGED
@@ -129,6 +129,18 @@ class Google < GenericSpreadsheet
|
|
129
129
|
return string.strip =~ /^([0-9]+)\/([0-9]+)\/([0-9]+)$/
|
130
130
|
end
|
131
131
|
|
132
|
+
# is String a time with format HH:MM:SS?
|
133
|
+
def Google.time?(string)
|
134
|
+
return false if string.class == Float
|
135
|
+
return true if string.class == Date
|
136
|
+
return string.strip =~ /^([0-9]+):([0-9]+):([0-9]+)$/
|
137
|
+
end
|
138
|
+
|
139
|
+
def Google.timestring_to_seconds(value)
|
140
|
+
hms = value.split(':')
|
141
|
+
hms[0].to_i*3600 + hms[1].to_i*60 + hms[2].to_i
|
142
|
+
end
|
143
|
+
|
132
144
|
# Returns the content of a spreadsheet-cell.
|
133
145
|
# (1,1) is the upper left corner.
|
134
146
|
# (1,1), (1,'A'), ('A',1), ('a',1) all refers to the
|
@@ -163,6 +175,7 @@ class Google < GenericSpreadsheet
|
|
163
175
|
# * :string,
|
164
176
|
# * :date
|
165
177
|
# * :percentage
|
178
|
+
# * :time
|
166
179
|
def celltype(row, col, sheet=nil)
|
167
180
|
sheet = @default_sheet unless sheet
|
168
181
|
read_cells(sheet) unless @cells_read[sheet]
|
@@ -241,6 +254,7 @@ class Google < GenericSpreadsheet
|
|
241
254
|
return true unless value
|
242
255
|
return false if value.class == Date # a date is never empty
|
243
256
|
return false if value.class == Float
|
257
|
+
return false if celltype(row,col,sheet) == :time
|
244
258
|
value.empty?
|
245
259
|
end
|
246
260
|
|
@@ -315,90 +329,6 @@ class Google < GenericSpreadsheet
|
|
315
329
|
return @last_column[sheet]
|
316
330
|
end
|
317
331
|
|
318
|
-
# find a row either by row number or a condition
|
319
|
-
# Caution: this works only within the default sheet -> set default_sheet before you call this method
|
320
|
-
# (experimental. see examples in the test_roo.rb file)
|
321
|
-
#--
|
322
|
-
# -----------------------------------------------------
|
323
|
-
# !!!TODO: should be factored out to GenericSpreadsheet
|
324
|
-
# also in Openofiffe
|
325
|
-
# -----------------------------------------------------
|
326
|
-
#++
|
327
|
-
#def find(*args)
|
328
|
-
# result_array = false
|
329
|
-
# args.each {|arg,val|
|
330
|
-
# if arg.class == Hash
|
331
|
-
# arg.each { |hkey,hval|
|
332
|
-
# if hkey == :array and hval == true
|
333
|
-
# result_array = true
|
334
|
-
# end
|
335
|
-
# }
|
336
|
-
# end
|
337
|
-
# }
|
338
|
-
# column_with = {}
|
339
|
-
# 1.upto(last_column) do |col|
|
340
|
-
# column_with[cell(@header_line,col)] = col
|
341
|
-
# end
|
342
|
-
# result = Array.new
|
343
|
-
# #-- id
|
344
|
-
# if args[0].class == Fixnum
|
345
|
-
# rownum = args[0]
|
346
|
-
# tmp = {}
|
347
|
-
# 1.upto(self.row(rownum).size) {|j|
|
348
|
-
# x = ''
|
349
|
-
# column_with.each { |key,val|
|
350
|
-
# if val == j
|
351
|
-
# x = key
|
352
|
-
# end
|
353
|
-
# }
|
354
|
-
# tmp[x] = cell(rownum,j)
|
355
|
-
# }
|
356
|
-
# result = [ tmp ] # row(rownum)
|
357
|
-
# #-- :all
|
358
|
-
# elsif args[0] == :all
|
359
|
-
# if args[1].class == Hash
|
360
|
-
# args[1].each {|key,val|
|
361
|
-
# if key == :conditions
|
362
|
-
# column_with = {}
|
363
|
-
# 1.upto(last_column) do |col|
|
364
|
-
# column_with[cell(@header_line,col)] = col
|
365
|
-
# end
|
366
|
-
# conditions = val
|
367
|
-
# first_row.upto(last_row) do |i|
|
368
|
-
# # are all conditions met?
|
369
|
-
# found = 1
|
370
|
-
# conditions.each { |key,val|
|
371
|
-
# if cell(i,column_with[key]) == val
|
372
|
-
# found *= 1
|
373
|
-
# else
|
374
|
-
# found *= 0
|
375
|
-
# end
|
376
|
-
# }
|
377
|
-
# # p self.row(i) if found > 0
|
378
|
-
# if found > 0
|
379
|
-
# tmp = {}
|
380
|
-
# 1.upto(self.row(i).size) {|j|
|
381
|
-
# x = ''
|
382
|
-
# column_with.each { |key,val|
|
383
|
-
# if val == j
|
384
|
-
# x = key
|
385
|
-
# end
|
386
|
-
# }
|
387
|
-
# tmp[x] = cell(i,j)
|
388
|
-
# }
|
389
|
-
# if result_array
|
390
|
-
# result << self.row(i)
|
391
|
-
# else
|
392
|
-
# result << tmp
|
393
|
-
# end
|
394
|
-
# end
|
395
|
-
# end
|
396
|
-
# end # :conditions
|
397
|
-
# }
|
398
|
-
# end
|
399
|
-
# end
|
400
|
-
# result
|
401
|
-
#end
|
402
332
|
private
|
403
333
|
|
404
334
|
# read all cells in a sheet
|
@@ -430,6 +360,9 @@ class Google < GenericSpreadsheet
|
|
430
360
|
elsif numeric?(value) # or o.class ???
|
431
361
|
ty = :float
|
432
362
|
value = value.to_f
|
363
|
+
elsif Google.time?(value)
|
364
|
+
ty = :time
|
365
|
+
value = Google.timestring_to_seconds(value)
|
433
366
|
else
|
434
367
|
ty = :string
|
435
368
|
end
|
data/lib/roo/openoffice.rb
CHANGED
@@ -279,6 +279,9 @@ class Openoffice < GenericSpreadsheet
|
|
279
279
|
@cell[sheet][key] = tr.attributes['date-value']
|
280
280
|
when :percentage
|
281
281
|
@cell[sheet][key] = v.to_f
|
282
|
+
when :time
|
283
|
+
hms = v.split(':')
|
284
|
+
@cell[sheet][key] = hms[0].to_i*3600 + hms[1].to_i*60 + hms[2].to_i
|
282
285
|
else
|
283
286
|
@cell[sheet][key] = v
|
284
287
|
end
|
@@ -345,6 +348,13 @@ class Openoffice < GenericSpreadsheet
|
|
345
348
|
end # == 'p'
|
346
349
|
end
|
347
350
|
end
|
351
|
+
if vt == 'time'
|
352
|
+
tr.each_element do |str|
|
353
|
+
if str.name == 'p'
|
354
|
+
v = str.text
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
348
358
|
if skip
|
349
359
|
if v != nil or tr.attributes['date-value']
|
350
360
|
0.upto(skip.to_i-1) do |i|
|
@@ -442,6 +452,7 @@ class Openoffice < GenericSpreadsheet
|
|
442
452
|
"string" => :string,
|
443
453
|
"date" => :date,
|
444
454
|
"percentage" => :percentage,
|
455
|
+
"time" => :time,
|
445
456
|
}
|
446
457
|
|
447
458
|
def Openoffice.oo_type_2_roo_type(ootype)
|
data/lib/roo/version.rb
CHANGED
data/test/numbers1.csv
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
5,6,7,8,9,"test",11
|
3
3
|
,,,,,,
|
4
4
|
10,11,12,13,14,,
|
5
|
-
|
5
|
+
1961-11-21,,,,,,
|
6
6
|
"tata",,,,,,
|
7
7
|
,,,,,,
|
8
8
|
,,"thisisc8",,,,
|
@@ -15,4 +15,4 @@
|
|
15
15
|
41,42,43,44,45,,
|
16
16
|
"einundvierzig","zweiundvierzig","dreiundvierzig","vierundvierzig","fuenfundvierzig",,
|
17
17
|
,,,,,,
|
18
|
-
|
18
|
+
2007-05-31,"dies hier als Date-Objekt",,,,,
|
data/test/numbers1_excel.csv
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
5,6,7,8,9,"test",11
|
3
3
|
,,,,,,
|
4
4
|
10,11,12,13,14,,
|
5
|
-
|
5
|
+
1961-11-21,,,,,,
|
6
6
|
"tata",,,,,,
|
7
7
|
,,,,,,
|
8
8
|
,,"thisisc8",,,,
|
@@ -15,4 +15,4 @@
|
|
15
15
|
41,42,43,44,45,,
|
16
16
|
"einundvierzig","zweiundvierzig","dreiundvierzig","vierundvierzig","fuenfundvierzig",,
|
17
17
|
,,,,,,
|
18
|
-
|
18
|
+
2007-05-31,"dies hier als Date-Objekt",,,,,
|
data/test/test_roo.rb
CHANGED
@@ -56,6 +56,7 @@ class Test::Unit::TestCase
|
|
56
56
|
"only_one_sheet" => "o10837434939102457526.762705759906130135",
|
57
57
|
"write.me" => 'ptu6bbahNZpY0N0RrxQbWdw&hl',
|
58
58
|
'formula' => 'o10837434939102457526.3022866619437760118',
|
59
|
+
'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
|
59
60
|
}[spreadsheetname]
|
60
61
|
rescue
|
61
62
|
raise "unknown spreadsheetname: #{spreadsheetname}"
|
@@ -118,9 +119,9 @@ class TestRoo < Test::Unit::TestCase
|
|
118
119
|
EXCEL = true # do Excel Tests?
|
119
120
|
GOOGLE = true # do Google-Spreadsheet Tests?
|
120
121
|
GNUMERIC_ODS = false # do gnumeric with ods files Tests?
|
121
|
-
|
122
|
+
|
122
123
|
OPENOFFICEWRITE = false # experimental: write access with OO-Documents
|
123
|
-
ONLINE =
|
124
|
+
ONLINE = false
|
124
125
|
LONG_RUN = false
|
125
126
|
GLOBAL_TIMEOUT = 2*12*60 # seconds
|
126
127
|
|
@@ -463,7 +464,7 @@ class TestRoo < Test::Unit::TestCase
|
|
463
464
|
assert_equal "thisisd9", oo.cell('d',9)
|
464
465
|
assert_equal "thisisa11", oo.cell('a',11)
|
465
466
|
end
|
466
|
-
|
467
|
+
|
467
468
|
if GNUMERIC_ODS
|
468
469
|
oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
|
469
470
|
oo.default_sheet = oo.sheets.first
|
@@ -1295,7 +1296,7 @@ class TestRoo < Test::Unit::TestCase
|
|
1295
1296
|
# [8, 2, "=SUM([.$A$1:.B7])"],
|
1296
1297
|
# ], oo.formulas(oo.sheets.first)
|
1297
1298
|
# different format than in openoffice spreadsheets:
|
1298
|
-
#was:
|
1299
|
+
#was:
|
1299
1300
|
# assert_equal [[7, 1, "=SUM(R[-6]C[0]:R[-1]C[0])"],
|
1300
1301
|
# [7, 2, "=SUM(R1C1:R[-1]C[0])"],
|
1301
1302
|
# [7, 3, "=sheet2!R[-6]C[-2]"],
|
@@ -1797,8 +1798,8 @@ class TestRoo < Test::Unit::TestCase
|
|
1797
1798
|
File.delete_if_exist("/tmp/numbers1.csv")
|
1798
1799
|
oo = Openoffice.new(File.join("test","numbers1.ods"))
|
1799
1800
|
|
1800
|
-
|
1801
|
-
# bug?, 2008-01-15 from Troy Davis
|
1801
|
+
|
1802
|
+
# bug?, 2008-01-15 from Troy Davis
|
1802
1803
|
assert oo.to_csv("/tmp/numbers1.csv",oo.sheets.first)
|
1803
1804
|
assert File.exists?("/tmp/numbers1.csv")
|
1804
1805
|
assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
|
@@ -1820,7 +1821,7 @@ class TestRoo < Test::Unit::TestCase
|
|
1820
1821
|
File.delete_if_exist("/tmp/numbers1_excel.csv")
|
1821
1822
|
oo = Excel.new(File.join("test","numbers1.xls"))
|
1822
1823
|
|
1823
|
-
# bug?, 2008-01-15 from Troy Davis
|
1824
|
+
# bug?, 2008-01-15 from Troy Davis
|
1824
1825
|
assert oo.to_csv("/tmp/numbers1_excel.csv",oo.sheets.first)
|
1825
1826
|
assert File.exists?("/tmp/numbers1_excel.csv")
|
1826
1827
|
assert_equal "", `diff test/numbers1_excel.csv /tmp/numbers1_excel.csv`
|
@@ -1848,7 +1849,7 @@ class TestRoo < Test::Unit::TestCase
|
|
1848
1849
|
assert File.exists?("/tmp/numbers1.csv")
|
1849
1850
|
assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
|
1850
1851
|
|
1851
|
-
# bug?, 2008-01-15 from Troy Davis
|
1852
|
+
# bug?, 2008-01-15 from Troy Davis
|
1852
1853
|
assert oo.to_csv("/tmp/numbers1.csv",oo.sheets.first)
|
1853
1854
|
assert File.exists?("/tmp/numbers1.csv")
|
1854
1855
|
assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
|
@@ -2737,7 +2738,7 @@ class TestRoo < Test::Unit::TestCase
|
|
2737
2738
|
assert_equal "hello from the tests", oo.cell(1,1)
|
2738
2739
|
end
|
2739
2740
|
end
|
2740
|
-
|
2741
|
+
|
2741
2742
|
def test_bug_set_value_with_more_than_one_sheet_google
|
2742
2743
|
# write.me: http://spreadsheets.google.com/ccc?key=ptu6bbahNZpY0N0RrxQbWdw&hl=en_GB
|
2743
2744
|
if GOOGLE
|
@@ -2754,7 +2755,7 @@ class TestRoo < Test::Unit::TestCase
|
|
2754
2755
|
assert_equal content2, oo.cell(1,1)
|
2755
2756
|
end
|
2756
2757
|
end
|
2757
|
-
|
2758
|
+
|
2758
2759
|
def test_set_value_with_sheet_argument_google
|
2759
2760
|
if GOOGLE
|
2760
2761
|
random_row = rand(10)+1
|
@@ -2767,9 +2768,9 @@ class TestRoo < Test::Unit::TestCase
|
|
2767
2768
|
oo.set_value(random_row,random_column,content2,oo.sheets[1])
|
2768
2769
|
assert_equal content1, oo.cell(random_row,random_column,oo.sheets.first)
|
2769
2770
|
assert_equal content2, oo.cell(random_row,random_column,oo.sheets[1])
|
2770
|
-
end
|
2771
|
+
end
|
2771
2772
|
end
|
2772
|
-
|
2773
|
+
|
2773
2774
|
def test_set_value_for_non_existing_sheet_google
|
2774
2775
|
if GOOGLE
|
2775
2776
|
oo = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
|
@@ -2862,4 +2863,113 @@ Sheet 3:
|
|
2862
2863
|
# puts "GOOGLE = #{GOOGLE}"
|
2863
2864
|
# end
|
2864
2865
|
|
2866
|
+
def test_bug_time_nil_openoffice
|
2867
|
+
if OPENOFFICE
|
2868
|
+
oo = Openoffice.new(File.join("test","time-test.ods"))
|
2869
|
+
oo.default_sheet = oo.sheets.first
|
2870
|
+
assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
|
2871
|
+
assert_equal :time, oo.celltype('B',1)
|
2872
|
+
assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
|
2873
|
+
assert_equal :time, oo.celltype('C',1)
|
2874
|
+
|
2875
|
+
assert_equal 23*3600, oo.cell('D',1) # 23:00 (secs since midnight)
|
2876
|
+
assert_equal :time, oo.celltype('D',1)
|
2877
|
+
end
|
2878
|
+
end
|
2879
|
+
|
2880
|
+
def test_bug_time_nil_excel
|
2881
|
+
if EXCEL
|
2882
|
+
oo = Excel.new(File.join("test","time-test.xls"))
|
2883
|
+
oo.default_sheet = oo.sheets.first
|
2884
|
+
assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
|
2885
|
+
assert_equal :time, oo.celltype('B',1)
|
2886
|
+
assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
|
2887
|
+
assert_equal :time, oo.celltype('C',1)
|
2888
|
+
|
2889
|
+
assert_equal 23*3600, oo.cell('D',1) # 23:00 (secs since midnight)
|
2890
|
+
assert_equal :time, oo.celltype('D',1)
|
2891
|
+
end
|
2892
|
+
end
|
2893
|
+
|
2894
|
+
def test_bug_time_nil_google
|
2895
|
+
if GOOGLE
|
2896
|
+
oo = Google.new(key_of("time-test"))
|
2897
|
+
oo.default_sheet = oo.sheets.first
|
2898
|
+
assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
|
2899
|
+
assert_equal :time, oo.celltype('B',1)
|
2900
|
+
assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
|
2901
|
+
assert_equal :time, oo.celltype('C',1)
|
2902
|
+
|
2903
|
+
assert_equal 23*3600, oo.cell('D',1) # 23:00 (secs since midnight)
|
2904
|
+
assert_equal :time, oo.celltype('D',1)
|
2905
|
+
end
|
2906
|
+
end
|
2907
|
+
|
2908
|
+
def test_date_time_to_csv_openoffice
|
2909
|
+
if OPENOFFICE
|
2910
|
+
File.delete_if_exist("/tmp/time-test.csv")
|
2911
|
+
oo = Openoffice.new(File.join("test","time-test.ods"))
|
2912
|
+
oo.default_sheet = oo.sheets.first
|
2913
|
+
assert oo.to_csv("/tmp/time-test.csv")
|
2914
|
+
assert File.exists?("/tmp/time-test.csv")
|
2915
|
+
assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
|
2916
|
+
end # OPENOFFICE
|
2917
|
+
end
|
2918
|
+
|
2919
|
+
def test_date_time_to_csv_excel
|
2920
|
+
if EXCEL
|
2921
|
+
after Date.new(2008,3,30) do
|
2922
|
+
#ueberfluessige leere Zeilen werden am Ende noch angehaengt
|
2923
|
+
# last_row fehlerhaft?
|
2924
|
+
File.delete_if_exist("/tmp/time-test.csv")
|
2925
|
+
oo = Excel.new(File.join("test","time-test.xls"))
|
2926
|
+
oo.default_sheet = oo.sheets.first
|
2927
|
+
assert oo.to_csv("/tmp/time-test.csv")
|
2928
|
+
assert File.exists?("/tmp/time-test.csv")
|
2929
|
+
assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
|
2930
|
+
end
|
2931
|
+
end # EXCEL
|
2932
|
+
end
|
2933
|
+
|
2934
|
+
def test_date_time_to_csv_google
|
2935
|
+
if GOOGLE
|
2936
|
+
File.delete_if_exist("/tmp/time-test.csv")
|
2937
|
+
oo = Google.new(key_of("time-test"))
|
2938
|
+
oo.default_sheet = oo.sheets.first
|
2939
|
+
assert oo.to_csv("/tmp/time-test.csv")
|
2940
|
+
assert File.exists?("/tmp/time-test.csv")
|
2941
|
+
assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
|
2942
|
+
end # GOOGLE
|
2943
|
+
end
|
2944
|
+
|
2945
|
+
def test_date_time_yaml_openoffice
|
2946
|
+
if OPENOFFICE
|
2947
|
+
expected =
|
2948
|
+
"--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n"
|
2949
|
+
oo = Openoffice.new(File.join("test","time-test.ods"))
|
2950
|
+
oo.default_sheet = oo.sheets.first
|
2951
|
+
assert_equal expected, oo.to_yaml
|
2952
|
+
end
|
2953
|
+
end
|
2954
|
+
|
2955
|
+
def test_date_time_yaml_excel
|
2956
|
+
if EXCEL
|
2957
|
+
expected =
|
2958
|
+
"--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n"
|
2959
|
+
oo = Excel.new(File.join("test","time-test.xls"))
|
2960
|
+
oo.default_sheet = oo.sheets.first
|
2961
|
+
assert_equal expected, oo.to_yaml
|
2962
|
+
end
|
2963
|
+
end
|
2964
|
+
|
2965
|
+
def test_date_time_yaml_google
|
2966
|
+
if GOOGLE
|
2967
|
+
expected =
|
2968
|
+
"--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n"
|
2969
|
+
oo = Google.new(key_of("time-test"))
|
2970
|
+
oo.default_sheet = oo.sheets.first
|
2971
|
+
assert_equal expected, oo.to_yaml
|
2972
|
+
end
|
2973
|
+
end
|
2974
|
+
|
2865
2975
|
end # class
|
data/test/time-test.csv
ADDED
data/test/time-test.ods
ADDED
Binary file
|
data/test/time-test.xls
ADDED
Binary file
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>roo</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/roo"; return false'>
|
35
35
|
Get Version
|
36
|
-
<a href="http://rubyforge.org/projects/roo" class="numbers">0.9.
|
36
|
+
<a href="http://rubyforge.org/projects/roo" class="numbers">0.9.2</a>
|
37
37
|
</div>
|
38
38
|
<h2>What</h2>
|
39
39
|
|
@@ -158,6 +158,7 @@ returned:</p>
|
|
158
158
|
<li>:date</li>
|
159
159
|
<li>:percentage</li>
|
160
160
|
<li>:formula</li>
|
161
|
+
<li>:time</li>
|
161
162
|
</ul>
|
162
163
|
|
163
164
|
|
@@ -477,9 +478,10 @@ Only the Openoffice- and Excel-parts of this gem are currently working – t
|
|
477
478
|
<li><a href="http://rubyforge.org/users/nicwilliams/">Dr Nic Williams</a> for his wonderful gem ‘<a href="http://rubyforge.org/projects/newgem/">newgem</a>’ which makes it very convenient to create, manage and publish Ruby gems</li>
|
478
479
|
<li>for the Excel-part the <a href="http://rubyforge.org/projects/spreadsheet/">spreadsheet</a> gem is used. My functions are a convenient wrapper around the functions of this gem</li>
|
479
480
|
<li>Dirk Huth fürs Testen unter Windows</li>
|
481
|
+
<li>Thanks to davecahill for a bug-fix patch within the google part</li>
|
480
482
|
</ul>
|
481
483
|
<p class="coda">
|
482
|
-
<a href="mailto:thopre@gmail.com">Thomas Preymesser</a>,
|
484
|
+
<a href="mailto:thopre@gmail.com">Thomas Preymesser</a>, 24th March 2008<br>
|
483
485
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
484
486
|
</p>
|
485
487
|
</div>
|
data/website/index.txt
CHANGED
@@ -102,6 +102,7 @@ returned:
|
|
102
102
|
* :date
|
103
103
|
* :percentage
|
104
104
|
* :formula
|
105
|
+
* :time
|
105
106
|
|
106
107
|
h3. Write access
|
107
108
|
|
@@ -328,3 +329,4 @@ h2. Thanks
|
|
328
329
|
* "Dr Nic Williams":http://rubyforge.org/users/nicwilliams/ for his wonderful gem '"newgem":http://rubyforge.org/projects/newgem/' which makes it very convenient to create, manage and publish Ruby gems
|
329
330
|
* for the Excel-part the "spreadsheet":http://rubyforge.org/projects/spreadsheet/ gem is used. My functions are a convenient wrapper around the functions of this gem
|
330
331
|
* Dirk Huth fürs Testen unter Windows
|
332
|
+
* Thanks to davecahill for a bug-fix patch within the google part
|
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: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Preymesser
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-03-
|
12
|
+
date: 2008-03-25 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -92,6 +92,9 @@ files:
|
|
92
92
|
- test/simple_spreadsheet_from_italo.xls
|
93
93
|
- test/test_helper.rb
|
94
94
|
- test/test_roo.rb
|
95
|
+
- test/time-test.ods
|
96
|
+
- test/time-test.xls
|
97
|
+
- test/time-test.csv
|
95
98
|
- test/numbers1.csv
|
96
99
|
- test/numbers1_excel.csv
|
97
100
|
- test/numbers1.ods
|