roo 1.9.5 → 1.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -1
- data/Rakefile +2 -0
- data/bin/roo +27 -2
- data/datetime.csv +7 -0
- data/lib/.roo.rb.swp +0 -0
- data/lib/roo.rb +1 -1
- data/lib/roo/.generic_spreadsheet.rb.swp +0 -0
- data/lib/roo/excel.rb +16 -14
- data/lib/roo/excelx.rb +10 -6
- data/lib/roo/generic_spreadsheet.rb +50 -17
- data/lib/roo/openoffice.rb +23 -26
- data/test/so_datetime.csv +7 -0
- data/test/test_roo.rb +92 -35
- metadata +40 -16
- data/lib/roo/.generic_spreadsheet.rb.rb.swp +0 -0
data/History.txt
CHANGED
@@ -1,8 +1,18 @@
|
|
1
|
+
== 1.9.6 2011-08-03
|
2
|
+
* 1 enhancement
|
3
|
+
* new class Libreoffice (Libreoffice should do exactly the same as the Openoffice
|
4
|
+
class. It's just another name. Technically, Libreoffice is inherited from
|
5
|
+
the Openoffice class with no new methods.
|
6
|
+
* 3 bugfixes
|
7
|
+
* Openoffice: file type check, deletion of temporary files not in ensure clause
|
8
|
+
* Cell type :datetime was not handled in the to_csv method
|
9
|
+
* Better deletion of temporary directories if something went wrong
|
10
|
+
|
1
11
|
== 1.9.5 2011-06-25
|
2
12
|
|
3
13
|
* 1 enhancement
|
4
14
|
* Method #formulas moved to generic-spreadsheet class (the Excel version is
|
5
|
-
overwritten because the spreadsheet gem currently does not support
|
15
|
+
overwritten because the spreadsheet gem currently does not support
|
6
16
|
formulas.
|
7
17
|
* 3 bugfixes
|
8
18
|
* Openoffice/Excelx/Google: #formulas of an empty sheet should not result
|
data/Rakefile
CHANGED
@@ -26,6 +26,8 @@ Bones {
|
|
26
26
|
#depend_on 'febeling-rubyzip','>= 0.9.2' # meine aktuelle Version
|
27
27
|
#TODO: warum brauchen wir das? es lief doch auch vorher ohne dieses spezielle gem
|
28
28
|
depend_on 'google-spreadsheet-ruby'
|
29
|
+
depend_on 'choice'
|
30
|
+
depend_on 'todonotes'
|
29
31
|
}
|
30
32
|
|
31
33
|
# EOF
|
data/bin/roo
CHANGED
@@ -2,7 +2,32 @@
|
|
2
2
|
|
3
3
|
require File.expand_path(
|
4
4
|
File.join(File.dirname(__FILE__), %w[.. lib roo]))
|
5
|
+
require 'rubygems'
|
6
|
+
require 'choice'
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
+
Choice.options do
|
9
|
+
header ''
|
10
|
+
header 'Options:'
|
11
|
+
option :help do
|
12
|
+
long '--help'
|
13
|
+
desc 'Show this message'
|
14
|
+
end
|
15
|
+
option :version do
|
16
|
+
short '-v'
|
17
|
+
long '--version'
|
18
|
+
desc 'Show version'
|
19
|
+
action do
|
20
|
+
puts "Roo v#{Roo::VERSION}"
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
end
|
24
|
+
option :info do
|
25
|
+
short '-i'
|
26
|
+
long '--info <spreadsheetfile>'
|
27
|
+
desc 'Show information about a spreadsheet file'
|
28
|
+
action do
|
29
|
+
puts '#'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
8
33
|
# EOF
|
data/datetime.csv
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
1961-11-21,,
|
2
|
+
,,
|
3
|
+
1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00
|
4
|
+
1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00
|
5
|
+
1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00
|
6
|
+
1961-11-21,1961-11-21,1961-11-21
|
7
|
+
1961-11-21,1961-11-21,1961-11-21
|
data/lib/.roo.rb.swp
ADDED
Binary file
|
data/lib/roo.rb
CHANGED
Binary file
|
data/lib/roo/excel.rb
CHANGED
@@ -100,7 +100,9 @@ class Excel < GenericSpreadsheet
|
|
100
100
|
def initialize(filename, packed = nil, file_warning = :error)
|
101
101
|
super()
|
102
102
|
@file_warning = file_warning
|
103
|
-
|
103
|
+
file_type_check(filename,'.xls','an Excel',packed)
|
104
|
+
# @tmpdir = "oo_"+$$.to_s
|
105
|
+
@tmpdir = GenericSpreadsheet.next_tmpdir
|
104
106
|
@tmpdir = File.join(ENV['ROO_TMP'], @tmpdir) if ENV['ROO_TMP']
|
105
107
|
unless File.exists?(@tmpdir)
|
106
108
|
FileUtils::mkdir(@tmpdir)
|
@@ -108,15 +110,16 @@ class Excel < GenericSpreadsheet
|
|
108
110
|
filename = open_from_uri(filename) if filename[0,7] == "http://"
|
109
111
|
filename = open_from_stream(filename[7..-1]) if filename[0,7] == "stream:"
|
110
112
|
filename = unzip(filename) if packed and packed == :zip
|
111
|
-
begin
|
112
|
-
|
113
|
-
file_type_check(filename,'.xls','an Excel')
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
113
|
+
#begin
|
114
|
+
#begin
|
115
|
+
# file_type_check(filename,'.xls','an Excel')
|
116
|
+
#rescue TypeError
|
117
|
+
# #FileUtils::rm_r @tmpdir
|
118
|
+
# raise
|
119
|
+
#end
|
118
120
|
@filename = filename
|
119
121
|
unless File.file?(@filename)
|
122
|
+
FileUtils::rm_r(@tmpdir)
|
120
123
|
raise IOError, "file #{@filename} does not exist"
|
121
124
|
end
|
122
125
|
begin
|
@@ -126,18 +129,17 @@ class Excel < GenericSpreadsheet
|
|
126
129
|
raise # nach aussen weiterhin sichtbar
|
127
130
|
end
|
128
131
|
@default_sheet = self.sheets.first
|
129
|
-
ensure
|
132
|
+
#ensure
|
130
133
|
#if ENV["roo_local"] != "thomas-p"
|
131
134
|
# ich glaube ich darf hier noch nicht die temporaere
|
132
135
|
# Datei loeschen, weil
|
133
136
|
#to do
|
134
137
|
#"Loeschen temp. Directory anpassen"
|
135
138
|
#end
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
end
|
139
|
+
#end
|
140
|
+
#if fremdrechner?
|
141
|
+
FileUtils::rm_r(@tmpdir)
|
142
|
+
#end
|
141
143
|
@cell = Hash.new
|
142
144
|
@cell_type = Hash.new
|
143
145
|
@formula = Hash.new
|
data/lib/roo/excelx.rb
CHANGED
@@ -87,18 +87,21 @@ class Excelx < GenericSpreadsheet
|
|
87
87
|
def initialize(filename, packed=nil, file_warning = :error) #, create = false)
|
88
88
|
super()
|
89
89
|
@file_warning = file_warning
|
90
|
-
|
90
|
+
file_type_check(filename,'.xlsx','an Excel-xlsx',packed)
|
91
|
+
#@tmpdir = "oo_"+$$.to_s
|
92
|
+
@tmpdir = GenericSpreadsheet.next_tmpdir
|
91
93
|
@tmpdir = File.join(ENV['ROO_TMP'], @tmpdir) if ENV['ROO_TMP']
|
92
94
|
unless File.exists?(@tmpdir)
|
93
95
|
FileUtils::mkdir(@tmpdir)
|
94
96
|
end
|
95
97
|
filename = open_from_uri(filename) if filename[0,7] == "http://"
|
96
98
|
filename = unzip(filename) if packed and packed == :zip
|
97
|
-
begin
|
98
|
-
file_type_check(filename,'.xlsx','an Excel-xlsx')
|
99
|
+
#begin
|
100
|
+
#file_type_check(filename,'.xlsx','an Excel-xlsx')
|
99
101
|
@cells_read = Hash.new
|
100
102
|
@filename = filename
|
101
103
|
unless File.file?(@filename)
|
104
|
+
FileUtils::rm_r(@tmpdir)
|
102
105
|
raise IOError, "file #{@filename} does not exist"
|
103
106
|
end
|
104
107
|
@@nr += 1
|
@@ -134,11 +137,12 @@ class Excelx < GenericSpreadsheet
|
|
134
137
|
@sheet_doc[i] = Nokogiri::XML(file)
|
135
138
|
file.close
|
136
139
|
end
|
137
|
-
ensure
|
140
|
+
#ensure
|
138
141
|
#if ENV["roo_local"] != "thomas-p"
|
139
|
-
FileUtils::rm_r(@tmpdir)
|
142
|
+
#FileUtils::rm_r(@tmpdir)
|
140
143
|
#end
|
141
|
-
end
|
144
|
+
#end
|
145
|
+
FileUtils::rm_r(@tmpdir)
|
142
146
|
@default_sheet = self.sheets.first
|
143
147
|
@cell = Hash.new
|
144
148
|
@cell_type = Hash.new
|
@@ -6,6 +6,8 @@ class GenericSpreadsheet
|
|
6
6
|
|
7
7
|
attr_reader :default_sheet
|
8
8
|
|
9
|
+
@@class_counter = 0
|
10
|
+
|
9
11
|
# sets the line with attribute names (default: 1)
|
10
12
|
attr_accessor :header_line
|
11
13
|
|
@@ -27,13 +29,22 @@ class GenericSpreadsheet
|
|
27
29
|
! eigener
|
28
30
|
end
|
29
31
|
|
32
|
+
def self.next_tmpdir
|
33
|
+
@@class_counter += 1
|
34
|
+
# tmpdir = "oo_"+$$.to_s+"_"+sprintf("%04d",@@class_counter)
|
35
|
+
tmpdir = "oo_"+$$.to_s+"_"+sprintf("%010d",rand(10_000_000_000))
|
36
|
+
# p "@tmpdir = #{tmpdir}"; sleep 5
|
37
|
+
tmpdir
|
38
|
+
end
|
39
|
+
|
40
|
+
|
30
41
|
public
|
31
42
|
|
32
43
|
# sets the working sheet in the document
|
33
44
|
# 'sheet' can be a number (1 = first sheet) or the name of a sheet.
|
34
45
|
def default_sheet=(sheet)
|
35
46
|
if sheet.kind_of? Fixnum
|
36
|
-
if sheet
|
47
|
+
if sheet > 0 and sheet <= sheets.length
|
37
48
|
sheet = self.sheets[sheet-1]
|
38
49
|
else
|
39
50
|
raise RangeError
|
@@ -444,12 +455,18 @@ class GenericSpreadsheet
|
|
444
455
|
|
445
456
|
protected
|
446
457
|
|
447
|
-
def file_type_check(filename, ext, name)
|
458
|
+
def file_type_check(filename, ext, name, packed=nil)
|
448
459
|
new_expression = {
|
449
460
|
'.ods' => 'Openoffice.new',
|
450
461
|
'.xls' => 'Excel.new',
|
451
462
|
'.xlsx' => 'Excelx.new',
|
452
463
|
}
|
464
|
+
if packed == :zip
|
465
|
+
# lalala.ods.zip => lalala.ods
|
466
|
+
# hier wird KEIN unzip gemacht, sondern nur der Name der Datei
|
467
|
+
# getestet, falls es eine gepackte Datei ist.
|
468
|
+
filename = File.basename(filename,File.extname(filename))
|
469
|
+
end
|
453
470
|
case ext
|
454
471
|
when '.ods', '.xls', '.xlsx'
|
455
472
|
correct_class = "use #{new_expression[ext]} to handle #{ext} spreadsheet files"
|
@@ -483,7 +500,7 @@ class GenericSpreadsheet
|
|
483
500
|
[r,c]
|
484
501
|
end
|
485
502
|
|
486
|
-
#
|
503
|
+
# see: key_to_num
|
487
504
|
def key_to_string(arr)
|
488
505
|
"#{arr[0]},#{arr[1]}"
|
489
506
|
end
|
@@ -582,10 +599,10 @@ class GenericSpreadsheet
|
|
582
599
|
ret=nil
|
583
600
|
if zip.file.file? path
|
584
601
|
# extract and return filename
|
585
|
-
@tmpdir = "oo_"+$$.to_s
|
586
|
-
unless File.exists?(@tmpdir)
|
587
|
-
FileUtils::mkdir(@tmpdir)
|
588
|
-
|
602
|
+
#2011-08-01 @tmpdir = "oo_"+$$.to_s
|
603
|
+
#2011-08-01 unless File.exists?(@tmpdir)
|
604
|
+
#2011-08-01 FileUtils::mkdir(@tmpdir)
|
605
|
+
#2011-08-01end
|
589
606
|
file = File.open(File.join(@tmpdir, path),"wb")
|
590
607
|
file.write(zip.read(path))
|
591
608
|
file.close
|
@@ -601,6 +618,8 @@ class GenericSpreadsheet
|
|
601
618
|
ret
|
602
619
|
end
|
603
620
|
|
621
|
+
# Write all cells to the csv file. File can be a filename or nil. If the this
|
622
|
+
# parameter is nil the output goes to STDOUT
|
604
623
|
def write_csv_content(file=nil,sheet=nil)
|
605
624
|
file = STDOUT unless file
|
606
625
|
if first_row(sheet) # sheet is not empty
|
@@ -617,20 +636,25 @@ class GenericSpreadsheet
|
|
617
636
|
end
|
618
637
|
end
|
619
638
|
|
620
|
-
|
639
|
+
# The content of a cell in the csv output
|
640
|
+
def one_cell_output(onecelltype, onecell, empty)
|
621
641
|
str = ""
|
622
642
|
if empty
|
623
643
|
str += ''
|
624
644
|
else
|
625
645
|
case onecelltype
|
626
646
|
when :string
|
627
|
-
if onecell == ""
|
628
|
-
|
629
|
-
else
|
647
|
+
#if onecell == ""
|
648
|
+
# str << ''
|
649
|
+
#else
|
650
|
+
# one = onecell.gsub(/"/,'""')
|
651
|
+
# str << ('"'+one+'"')
|
652
|
+
#end
|
653
|
+
unless onecell.empty?
|
630
654
|
one = onecell.gsub(/"/,'""')
|
631
655
|
str << ('"'+one+'"')
|
632
|
-
|
633
|
-
when :float
|
656
|
+
end
|
657
|
+
when :float, :percentage
|
634
658
|
if onecell == onecell.to_i
|
635
659
|
str << onecell.to_i.to_s
|
636
660
|
else
|
@@ -638,12 +662,16 @@ class GenericSpreadsheet
|
|
638
662
|
end
|
639
663
|
when :formula
|
640
664
|
if onecell.class == String
|
641
|
-
if onecell == ""
|
642
|
-
|
643
|
-
else
|
665
|
+
# if onecell == ""
|
666
|
+
# str << ''
|
667
|
+
# else
|
668
|
+
# one = onecell.gsub(/"/,'""')
|
669
|
+
# str << '"'+one+'"'
|
670
|
+
# end
|
671
|
+
unless onecell.empty?
|
644
672
|
one = onecell.gsub(/"/,'""')
|
645
673
|
str << '"'+one+'"'
|
646
|
-
|
674
|
+
end
|
647
675
|
elsif onecell.class == Float
|
648
676
|
if onecell == onecell.to_i
|
649
677
|
str << onecell.to_i.to_s
|
@@ -657,6 +685,11 @@ class GenericSpreadsheet
|
|
657
685
|
str << onecell.to_s
|
658
686
|
when :time
|
659
687
|
str << GenericSpreadsheet.integer_to_timestring(onecell)
|
688
|
+
when :datetime
|
689
|
+
# date,rest = onecell.to_s.split('T')
|
690
|
+
# time = rest.split('+').first
|
691
|
+
# str << date + ' ' + time
|
692
|
+
str << onecell.to_s
|
660
693
|
else
|
661
694
|
raise "unhandled celltype "+onecelltype.to_s
|
662
695
|
end
|
data/lib/roo/openoffice.rb
CHANGED
@@ -15,7 +15,8 @@ class Openoffice < GenericSpreadsheet
|
|
15
15
|
def initialize(filename, packed=nil, file_warning=:error, tmpdir=nil) #, create = false)
|
16
16
|
@file_warning = file_warning
|
17
17
|
super()
|
18
|
-
|
18
|
+
file_type_check(filename,'.ods','an openoffice', packed)
|
19
|
+
@tmpdir = GenericSpreadsheet.next_tmpdir
|
19
20
|
@tmpdir = File.join(ENV['ROO_TMP'], @tmpdir) if ENV['ROO_TMP']
|
20
21
|
@tmpdir = File.join(tmpdir, @tmpdir) if tmpdir
|
21
22
|
unless File.exists?(@tmpdir)
|
@@ -23,33 +24,25 @@ class Openoffice < GenericSpreadsheet
|
|
23
24
|
end
|
24
25
|
filename = open_from_uri(filename) if filename[0,7] == "http://"
|
25
26
|
filename = unzip(filename) if packed and packed == :zip
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
#if create and ! File.exists?(filename)
|
34
|
-
# self.create_openoffice(filename)
|
35
|
-
#end
|
36
|
-
@cells_read = Hash.new
|
37
|
-
#TODO: @cells_read[:default] = false
|
38
|
-
@filename = filename
|
39
|
-
unless File.file?(@filename)
|
40
|
-
raise IOError, "file #{@filename} does not exist"
|
41
|
-
end
|
42
|
-
@@nr += 1
|
43
|
-
@file_nr = @@nr
|
44
|
-
extract_content
|
45
|
-
file = File.new(File.join(@tmpdir, @file_nr.to_s+"_roo_content.xml"))
|
46
|
-
@doc = Nokogiri::XML(file)
|
47
|
-
file.close
|
48
|
-
ensure
|
49
|
-
unless Dir.glob(@tmpdir).empty?
|
27
|
+
#if create and ! File.exists?(filename)
|
28
|
+
# self.create_openoffice(filename)
|
29
|
+
#end
|
30
|
+
@cells_read = Hash.new
|
31
|
+
#TODO: @cells_read[:default] = false
|
32
|
+
@filename = filename
|
33
|
+
unless File.file?(@filename)
|
50
34
|
FileUtils::rm_r(@tmpdir)
|
51
|
-
|
35
|
+
raise IOError, "file #{@filename} does not exist"
|
52
36
|
end
|
37
|
+
@@nr += 1
|
38
|
+
@file_nr = @@nr
|
39
|
+
extract_content
|
40
|
+
file = File.new(File.join(@tmpdir, @file_nr.to_s+"_roo_content.xml"))
|
41
|
+
@doc = Nokogiri::XML(file)
|
42
|
+
file.close
|
43
|
+
#unless Dir.glob(@tmpdir).empty?
|
44
|
+
FileUtils::rm_r(@tmpdir)
|
45
|
+
#end
|
53
46
|
@default_sheet = self.sheets.first
|
54
47
|
@cell = Hash.new
|
55
48
|
@cell_type = Hash.new
|
@@ -501,3 +494,7 @@ class Openoffice < GenericSpreadsheet
|
|
501
494
|
end
|
502
495
|
|
503
496
|
end # class
|
497
|
+
|
498
|
+
# Libreoffice is just an alias for Openoffice class
|
499
|
+
class Libreoffice < Openoffice
|
500
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
1961-11-21,,
|
2
|
+
,,
|
3
|
+
1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00
|
4
|
+
1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00
|
5
|
+
1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00,1961-11-21T12:17:18+00:00
|
6
|
+
1961-11-21,1961-11-21,1961-11-21
|
7
|
+
1961-11-21,1961-11-21,1961-11-21
|
data/test/test_roo.rb
CHANGED
@@ -9,6 +9,8 @@
|
|
9
9
|
# (like 'diff') must be changed (or commented out ;-)) if you want to run
|
10
10
|
# the tests under another OS
|
11
11
|
#
|
12
|
+
require 'rubygems'
|
13
|
+
require 'todonotes'
|
12
14
|
require 'tmpdir'
|
13
15
|
require './lib/roo'
|
14
16
|
#TODO
|
@@ -32,7 +34,7 @@ $log = Logger.new(File.join(ENV['HOME'],"roo.log"))
|
|
32
34
|
#$log.level = Logger::WARN
|
33
35
|
$log.level = Logger::DEBUG
|
34
36
|
|
35
|
-
DISPLAY_LOG =
|
37
|
+
DISPLAY_LOG = false
|
36
38
|
DB_LOG = false
|
37
39
|
if DB_LOG
|
38
40
|
require 'activerecord'
|
@@ -134,6 +136,13 @@ class Test::Unit::TestCase
|
|
134
136
|
:duration => t2-t1
|
135
137
|
)
|
136
138
|
end
|
139
|
+
if Dir.glob("oo_*") != []
|
140
|
+
puts "nicht alle temp. Dateien geloescht"
|
141
|
+
puts Dir.glob("oo_*")
|
142
|
+
print "? "
|
143
|
+
STDOUT.flush
|
144
|
+
a = gets
|
145
|
+
end
|
137
146
|
end
|
138
147
|
end
|
139
148
|
|
@@ -158,6 +167,7 @@ class TestRoo < Test::Unit::TestCase
|
|
158
167
|
EXCEL = true # do Excel Tests? (.xls files)
|
159
168
|
GOOGLE = false # do Google-Spreadsheet Tests?
|
160
169
|
EXCELX = true # do Excelx Tests? (.xlsx files)
|
170
|
+
LIBREOFFICE = true # do Libreoffice tests? (.ods files)
|
161
171
|
|
162
172
|
ONLINE = false
|
163
173
|
LONG_RUN = false
|
@@ -182,7 +192,7 @@ class TestRoo < Test::Unit::TestCase
|
|
182
192
|
options[:format] = [options[:format]]
|
183
193
|
end
|
184
194
|
options[:format].each do |formatname|
|
185
|
-
unless [:openoffice,:excel,:excelx,:google].include?(formatname)
|
195
|
+
unless [:openoffice,:excel,:excelx,:google,:libreoffice].include?(formatname)
|
186
196
|
raise "invalid spreadsheet type #{formatname}"
|
187
197
|
end
|
188
198
|
end
|
@@ -194,6 +204,7 @@ class TestRoo < Test::Unit::TestCase
|
|
194
204
|
yield Roo::Spreadsheet.open(File.join(TESTDIR, options[:name] + '.xlsx')) if EXCELX && options[:format].include?(:excelx)
|
195
205
|
yield Roo::Spreadsheet.open(File.join(TESTDIR, options[:name] + '.ods')) if OPENOFFICE && options[:format].include?(:openoffice)
|
196
206
|
yield Roo::Spreadsheet.open(key_of(options[:name]) || options[:name]) if GOOGLE && options[:format].include?(:google)
|
207
|
+
yield Roo::Spreadsheet.open(File.join(TESTDIR, options[:name] + '.ods')) if LIBREOFFICE && options[:format].include?(:libreoffice)
|
197
208
|
end
|
198
209
|
# Using Date.strptime so check that it's using the method
|
199
210
|
# with the value set in date_format
|
@@ -317,6 +328,14 @@ class TestRoo < Test::Unit::TestCase
|
|
317
328
|
end
|
318
329
|
end
|
319
330
|
|
331
|
+
def test_libre_office
|
332
|
+
if LIBREOFFICE
|
333
|
+
oo = Libreoffice.new("test/numbers1.ods")
|
334
|
+
oo.default_sheet = oo.sheets.first
|
335
|
+
assert_equal 41, oo.cell('a',12)
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
320
339
|
#TODO: inkonsequente Lieferung Fixnum/Float
|
321
340
|
def test_rows
|
322
341
|
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
@@ -721,6 +740,13 @@ class TestRoo < Test::Unit::TestCase
|
|
721
740
|
end
|
722
741
|
|
723
742
|
def test_excel_zipped
|
743
|
+
after Date.new(2011,8,30) do
|
744
|
+
to do
|
745
|
+
'hier wieder das Problem, dass ausgepacktes xls File
|
746
|
+
unter Windows nicht geloescht werden kann, weil
|
747
|
+
das spreadsheet gem die Datei nicht schliesst.
|
748
|
+
Fehler von spreadsheet gem'
|
749
|
+
end
|
724
750
|
if EXCEL
|
725
751
|
begin
|
726
752
|
oo = Excel.new(File.join(TESTDIR,"bode-v1.xls.zip"), :zip)
|
@@ -728,6 +754,7 @@ class TestRoo < Test::Unit::TestCase
|
|
728
754
|
assert_equal 'ist "e" im Nenner von H(s)', oo.cell('b', 5)
|
729
755
|
end
|
730
756
|
end
|
757
|
+
end
|
731
758
|
end
|
732
759
|
|
733
760
|
def test_openoffice_zipped
|
@@ -1406,21 +1433,33 @@ Sheet 3:
|
|
1406
1433
|
end
|
1407
1434
|
|
1408
1435
|
def test_no_remaining_tmp_files_openoffice
|
1436
|
+
after Date.new(2011,8,30) do
|
1437
|
+
# alles noch mal ueberarbeiten
|
1438
|
+
# temp. Directories sollten in diesem Fall ueberhaupt nicht
|
1439
|
+
# angelegt werden
|
1409
1440
|
if OPENOFFICE
|
1410
|
-
prev = Dir.glob(TMP_PREFIX)
|
1411
1441
|
assert_raise(Zip::ZipError) { #TODO: besseres Fehlerkriterium bei
|
1412
1442
|
# oo = Openoffice.new(File.join(TESTDIR,"no_spreadsheet_file.txt"))
|
1413
1443
|
# es soll absichtlich ein Abbruch provoziert werden, deshalb :ignore
|
1444
|
+
begin
|
1414
1445
|
oo = Openoffice.new(File.join(TESTDIR,"no_spreadsheet_file.txt"),
|
1415
1446
|
false,
|
1416
1447
|
:ignore)
|
1448
|
+
rescue Zip::ZipError
|
1449
|
+
@tmp = Dir.glob(oo.tmpdir)
|
1450
|
+
raise
|
1451
|
+
end
|
1417
1452
|
}
|
1418
|
-
|
1419
|
-
assert (now-prev).empty?, "temporay directory was not deleted"
|
1453
|
+
assert @tmp.empty?, "temporay directory was not deleted"
|
1420
1454
|
end
|
1455
|
+
end
|
1421
1456
|
end
|
1422
1457
|
|
1423
1458
|
def test_no_remaining_tmp_files_excel
|
1459
|
+
after Date.new(2011,8,30) do
|
1460
|
+
# alles noch mal ueberarbeiten
|
1461
|
+
# temp. Directories sollten in diesem Fall ueberhaupt nicht
|
1462
|
+
# angelegt werden
|
1424
1463
|
if EXCEL
|
1425
1464
|
prev = Dir.glob(TMP_PREFIX)
|
1426
1465
|
assert_raise(Ole::Storage::FormatError) {
|
@@ -1431,9 +1470,14 @@ Sheet 3:
|
|
1431
1470
|
now = Dir.glob(TMP_PREFIX)
|
1432
1471
|
assert (now-prev).empty?, "temporary directory not removed"
|
1433
1472
|
end
|
1473
|
+
end
|
1434
1474
|
end
|
1435
1475
|
|
1436
1476
|
def test_no_remaining_tmp_files_excelx
|
1477
|
+
after Date.new(2011,8,30) do
|
1478
|
+
# alles noch mal ueberarbeiten
|
1479
|
+
# temp. Directories sollten in diesem Fall ueberhaupt nicht
|
1480
|
+
# angelegt werden
|
1437
1481
|
if EXCELX
|
1438
1482
|
prev = Dir.glob(TMP_PREFIX)
|
1439
1483
|
assert_raise(Zip::ZipError) { #TODO: besseres Fehlerkriterium bei
|
@@ -1448,6 +1492,7 @@ Sheet 3:
|
|
1448
1492
|
now = Dir.glob(TMP_PREFIX)
|
1449
1493
|
assert (now-prev).empty?
|
1450
1494
|
end
|
1495
|
+
end
|
1451
1496
|
end
|
1452
1497
|
|
1453
1498
|
def test_no_remaining_tmp_files_google
|
@@ -1529,7 +1574,6 @@ Sheet 3:
|
|
1529
1574
|
end
|
1530
1575
|
|
1531
1576
|
def test_file_warning_default
|
1532
|
-
after Date.new(2011,7,18) do
|
1533
1577
|
if OPENOFFICE
|
1534
1578
|
prev = Dir.glob(TMP_PREFIX)
|
1535
1579
|
assert_raises(TypeError, "test/numbers1.xls is not an openoffice spreadsheet") { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls")) }
|
@@ -1551,37 +1595,46 @@ Sheet 3:
|
|
1551
1595
|
now = Dir.glob(TMP_PREFIX)
|
1552
1596
|
assert (now-prev).empty?
|
1553
1597
|
end
|
1554
|
-
end
|
1555
1598
|
end
|
1556
1599
|
|
1557
1600
|
def test_file_warning_error
|
1558
|
-
after Date.new(2011,7,22) do
|
1559
1601
|
if OPENOFFICE
|
1560
|
-
|
1602
|
+
prev = Dir.glob(TMP_PREFIX)
|
1561
1603
|
assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls"),false,:error) }
|
1604
|
+
now = Dir.glob(TMP_PREFIX)
|
1605
|
+
assert (now-prev).empty?
|
1606
|
+
|
1607
|
+
prev = Dir.glob(TMP_PREFIX)
|
1562
1608
|
assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx"),false,:error) }
|
1563
|
-
|
1609
|
+
now = Dir.glob(TMP_PREFIX)
|
1564
1610
|
assert (now-prev).empty?
|
1565
1611
|
end
|
1566
1612
|
if EXCEL
|
1567
|
-
|
1613
|
+
prev = Dir.glob(TMP_PREFIX)
|
1568
1614
|
assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false,:error) }
|
1615
|
+
now = Dir.glob(TMP_PREFIX)
|
1616
|
+
assert (now-prev).empty?, "temporary directory was not deleted"
|
1617
|
+
|
1618
|
+
prev = Dir.glob(TMP_PREFIX)
|
1569
1619
|
assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false,:error) }
|
1570
|
-
|
1620
|
+
now = Dir.glob(TMP_PREFIX)
|
1571
1621
|
assert (now-prev).empty?, "temporary directory was not deleted"
|
1572
1622
|
end
|
1573
1623
|
if EXCELX
|
1574
|
-
|
1624
|
+
prev = Dir.glob(TMP_PREFIX)
|
1575
1625
|
assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.ods"),false,:error) }
|
1626
|
+
now = Dir.glob(TMP_PREFIX)
|
1627
|
+
assert (now-prev).empty?, "temporary directory was not deleted"
|
1628
|
+
|
1629
|
+
prev = Dir.glob(TMP_PREFIX)
|
1576
1630
|
assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.xls"),false,:error) }
|
1577
|
-
|
1631
|
+
now = Dir.glob(TMP_PREFIX)
|
1578
1632
|
assert (now-prev).empty?, "temporary directory was not deleted"
|
1579
1633
|
end
|
1580
|
-
end
|
1581
1634
|
end
|
1582
1635
|
|
1583
1636
|
def test_file_warning_warning
|
1584
|
-
after Date.new(2011,
|
1637
|
+
after Date.new(2011,9,2) do
|
1585
1638
|
if OPENOFFICE
|
1586
1639
|
assert_nothing_raised(TypeError) {
|
1587
1640
|
assert_raises(Zip::ZipError) {
|
@@ -1627,7 +1680,6 @@ Sheet 3:
|
|
1627
1680
|
end
|
1628
1681
|
|
1629
1682
|
def test_file_warning_ignore
|
1630
|
-
after Date.new(2011,7,22) do
|
1631
1683
|
if OPENOFFICE
|
1632
1684
|
# Files, die eigentlich Openoffice-
|
1633
1685
|
# Files sind, aber die falsche Endung haben.
|
@@ -1694,7 +1746,6 @@ Sheet 3:
|
|
1694
1746
|
assert Dir.glob(TMP_PREFIX).empty?
|
1695
1747
|
end
|
1696
1748
|
=end
|
1697
|
-
end
|
1698
1749
|
end
|
1699
1750
|
|
1700
1751
|
def test_bug_last_row_excel
|
@@ -2053,17 +2104,15 @@ Sheet 3:
|
|
2053
2104
|
|
2054
2105
|
|
2055
2106
|
def test_bug_excel_last_row_255
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
assert_equal 1537, oo.last_row
|
2064
|
-
end
|
2107
|
+
if LONG_RUN
|
2108
|
+
local_only do
|
2109
|
+
oo = Excel.new(File.join('..','confidential','ScienceStaff.xls'))
|
2110
|
+
oo.default_sheet = oo.sheets.first
|
2111
|
+
assert_equal "COMSCI", oo.cell(255,1)
|
2112
|
+
assert_equal "lala", oo.cell(256,1)
|
2113
|
+
assert_equal 1537, oo.last_row
|
2065
2114
|
end
|
2066
|
-
|
2115
|
+
end
|
2067
2116
|
end
|
2068
2117
|
|
2069
2118
|
def test_bug_excel_last_row_255_modified
|
@@ -2115,7 +2164,7 @@ Sheet 3:
|
|
2115
2164
|
end end
|
2116
2165
|
|
2117
2166
|
def test_bug_date_mileszs
|
2118
|
-
after Date.new(2011,
|
2167
|
+
after Date.new(2011,8,28) do
|
2119
2168
|
# to do
|
2120
2169
|
# "An richtige Stelle kopieren. Ist das Dokument vertraulich?"
|
2121
2170
|
# 'ist auf dem Netbook nicht vorhanden'
|
@@ -2175,12 +2224,12 @@ where the expected result is
|
|
2175
2224
|
end
|
2176
2225
|
|
2177
2226
|
def test_bug_guest_list_2011_05_05
|
2178
|
-
|
2227
|
+
after Date.new(2011,8,28) do
|
2179
2228
|
oo = Excel.new(File.join("..","confidential","guest_list_addresses.xls"))
|
2180
2229
|
oo.default_sheet = oo.sheets.first
|
2181
2230
|
assert_equal "lalala", oo.cell('a',1) # anderer Inhalt im Spreadsheet
|
2182
2231
|
assert_equal :string, oo.celltype('a',1)
|
2183
|
-
|
2232
|
+
end
|
2184
2233
|
end
|
2185
2234
|
|
2186
2235
|
def test_bug_guest_list_2011_05_05_spreadsheet
|
@@ -2209,7 +2258,7 @@ where the expected result is
|
|
2209
2258
|
end
|
2210
2259
|
|
2211
2260
|
def test_bug_string_as_a_date_2011_05_21_spreadsheet_only
|
2212
|
-
|
2261
|
+
after Date.new(2011,8,28) do
|
2213
2262
|
# to do
|
2214
2263
|
# 'wieder entfernen'
|
2215
2264
|
# end
|
@@ -2223,11 +2272,11 @@ where the expected result is
|
|
2223
2272
|
end
|
2224
2273
|
|
2225
2274
|
end
|
2226
|
-
|
2275
|
+
end
|
2227
2276
|
end
|
2228
2277
|
|
2229
2278
|
def test_bug_string_as_a_date_2011_05_21
|
2230
|
-
|
2279
|
+
after Date.new(2011,8,28) do
|
2231
2280
|
#oo = Excel.new(File.join(TESTDIR,'2011-05-21_sample_type_problem.xls'))
|
2232
2281
|
oo = Excel.new(File.join('..','confidential','2011-05-21_sample_type_problem.xls'))
|
2233
2282
|
oo.default_sheet = oo.sheets.first
|
@@ -2237,7 +2286,7 @@ where the expected result is
|
|
2237
2286
|
assert_equal 76, oo.g5
|
2238
2287
|
assert_equal 77, oo.g6
|
2239
2288
|
assert_equal 78, oo.g7
|
2240
|
-
|
2289
|
+
end
|
2241
2290
|
end
|
2242
2291
|
|
2243
2292
|
def test_bug_string_as_a_date_2011_05_21_saved_as_ods
|
@@ -2294,4 +2343,12 @@ where the expected result is
|
|
2294
2343
|
end
|
2295
2344
|
end
|
2296
2345
|
|
2346
|
+
# 2011-08-03
|
2347
|
+
def test_bug_datetime_to_csv
|
2348
|
+
with_each_spreadsheet(:name=>'datetime') do |oo|
|
2349
|
+
assert oo.to_csv("datetime.csv")
|
2350
|
+
assert File.exists?("datetime.csv")
|
2351
|
+
assert_equal "", `diff test/so_datetime.csv datetime.csv`
|
2352
|
+
end
|
2353
|
+
end
|
2297
2354
|
end # class
|
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: 1.9.
|
4
|
+
version: 1.9.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-08-03 00:00:00.000000000Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: spreadsheet
|
17
|
-
requirement: &
|
16
|
+
requirement: &25564452 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ! '>'
|
@@ -22,21 +21,21 @@ dependencies:
|
|
22
21
|
version: 0.6.4
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *25564452
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: nokogiri
|
28
|
-
requirement: &
|
27
|
+
requirement: &25564128 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
29
|
requirements:
|
31
30
|
- - ! '>='
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
32
|
+
version: 1.5.0
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
35
|
+
version_requirements: *25564128
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: google-spreadsheet-ruby
|
39
|
-
requirement: &
|
38
|
+
requirement: &25563816 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
40
|
requirements:
|
42
41
|
- - ! '>='
|
@@ -44,10 +43,32 @@ dependencies:
|
|
44
43
|
version: 0.1.5
|
45
44
|
type: :runtime
|
46
45
|
prerelease: false
|
47
|
-
version_requirements: *
|
46
|
+
version_requirements: *25563816
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: choice
|
49
|
+
requirement: &25563468 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.4
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *25563468
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: todonotes
|
60
|
+
requirement: &25563144 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.1.0
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *25563144
|
48
69
|
- !ruby/object:Gem::Dependency
|
49
70
|
name: bones
|
50
|
-
requirement: &
|
71
|
+
requirement: &25562808 !ruby/object:Gem::Requirement
|
51
72
|
none: false
|
52
73
|
requirements:
|
53
74
|
- - ! '>='
|
@@ -55,7 +76,7 @@ dependencies:
|
|
55
76
|
version: 3.7.0
|
56
77
|
type: :development
|
57
78
|
prerelease: false
|
58
|
-
version_requirements: *
|
79
|
+
version_requirements: *25562808
|
59
80
|
description: ! 'Roo can access the contents of various spreadsheet files. It can handle
|
60
81
|
|
61
82
|
* Openoffice
|
@@ -75,7 +96,8 @@ extra_rdoc_files:
|
|
75
96
|
- PostInstall.txt
|
76
97
|
- README.txt
|
77
98
|
- bin/roo
|
78
|
-
- lib
|
99
|
+
- lib/.roo.rb.swp
|
100
|
+
- lib/roo/.generic_spreadsheet.rb.swp
|
79
101
|
- test/no_spreadsheet_file.txt
|
80
102
|
files:
|
81
103
|
- History.txt
|
@@ -87,8 +109,10 @@ files:
|
|
87
109
|
- a.xls
|
88
110
|
- bin/roo
|
89
111
|
- csv8532
|
112
|
+
- datetime.csv
|
113
|
+
- lib/.roo.rb.swp
|
90
114
|
- lib/roo.rb
|
91
|
-
- lib/roo/.generic_spreadsheet.rb.
|
115
|
+
- lib/roo/.generic_spreadsheet.rb.swp
|
92
116
|
- lib/roo/excel.rb
|
93
117
|
- lib/roo/excelx.rb
|
94
118
|
- lib/roo/generic_spreadsheet.rb
|
@@ -149,6 +173,7 @@ files:
|
|
149
173
|
- test/simple_spreadsheet.xlsx
|
150
174
|
- test/simple_spreadsheet_from_italo.ods
|
151
175
|
- test/simple_spreadsheet_from_italo.xls
|
176
|
+
- test/so_datetime.csv
|
152
177
|
- test/style.ods
|
153
178
|
- test/style.xls
|
154
179
|
- test/style.xlsx
|
@@ -168,7 +193,6 @@ files:
|
|
168
193
|
- test/whitespace.xls
|
169
194
|
- test/whitespace.xlsx
|
170
195
|
- tmp.xls
|
171
|
-
has_rdoc: true
|
172
196
|
homepage: http://roo.rubyforge.org/
|
173
197
|
licenses: []
|
174
198
|
post_install_message:
|
@@ -191,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
215
|
version: '0'
|
192
216
|
requirements: []
|
193
217
|
rubyforge_project: roo
|
194
|
-
rubygems_version: 1.
|
218
|
+
rubygems_version: 1.8.6
|
195
219
|
signing_key:
|
196
220
|
specification_version: 3
|
197
221
|
summary: Roo can access the contents of various spreadsheet files.
|
Binary file
|