roo 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.9.3 2008-03-25
2
+ * 1 bugfix
3
+ * no more tmp directories if an invalid spreadsheet file was openend
1
4
  == 0.9.2 2008-03-24
2
5
  * 1 enhancement
3
6
  * new celltype :time
data/Manifest.txt CHANGED
@@ -23,6 +23,7 @@ test/Bibelbund.xls
23
23
  test/Bibelbund.csv
24
24
  test/bbu.xls
25
25
  test/bbu.ods
26
+ test/no_spreadsheet_file.txt
26
27
  test/simple_spreadsheet.ods
27
28
  test/simple_spreadsheet.xls
28
29
  test/simple_spreadsheet_from_italo.ods
data/lib/roo/excel.rb CHANGED
@@ -31,19 +31,22 @@ class Excel < GenericSpreadsheet
31
31
  warn "are you sure, this is an excel file?"
32
32
  end
33
33
  @filename = filename
34
- unless File.file?(@filename)
35
- raise IOError, "file #{@filename} does not exist"
36
- end
37
- @workbook = Spreadsheet::ParseExcel.parse(filename)
38
- @default_sheet = nil
39
- # no need to set default_sheet if there is only one sheet in the document
40
- if self.sheets.size == 1
41
- @default_sheet = self.sheets.first
42
- end
43
- # @first_row = @last_row = @first_column = @last_column = nil
44
- #if ENV["roo_local"] != "thomas-p"
45
- FileUtils::rm_r(@tmpdir)
34
+ begin
35
+ unless File.file?(@filename)
36
+ raise IOError, "file #{@filename} does not exist"
37
+ end
38
+ @workbook = Spreadsheet::ParseExcel.parse(filename)
39
+ @default_sheet = nil
40
+ # no need to set default_sheet if there is only one sheet in the document
41
+ if self.sheets.size == 1
42
+ @default_sheet = self.sheets.first
43
+ end
44
+ # @first_row = @last_row = @first_column = @last_column = nil
45
+ #if ENV["roo_local"] != "thomas-p"
46
+ ensure
47
+ FileUtils::rm_r(@tmpdir)
46
48
  #end
49
+ end
47
50
  @first_row = Hash.new
48
51
  @last_row = Hash.new
49
52
  @first_column = Hash.new
@@ -28,18 +28,21 @@ class Openoffice < GenericSpreadsheet
28
28
  @cells_read = Hash.new
29
29
  #TODO: @cells_read[:default] = false
30
30
  @filename = filename
31
- unless File.file?(@filename)
32
- raise IOError, "file #{@filename} does not exist"
31
+ begin
32
+ unless File.file?(@filename)
33
+ raise IOError, "file #{@filename} does not exist"
34
+ end
35
+ @@nr += 1
36
+ @file_nr = @@nr
37
+ extract_content
38
+ file = File.new(File.join(@tmpdir, @file_nr.to_s+"_roo_content.xml"))
39
+ @doc = REXML::Document.new file
40
+ file.close
41
+ ensure
42
+ #if ENV["roo_local"] != "thomas-p"
43
+ FileUtils::rm_r(@tmpdir)
44
+ #end
33
45
  end
34
- @@nr += 1
35
- @file_nr = @@nr
36
- extract_content
37
- file = File.new(File.join(@tmpdir, @file_nr.to_s+"_roo_content.xml"))
38
- @doc = REXML::Document.new file
39
- file.close
40
- #if ENV["roo_local"] != "thomas-p"
41
- FileUtils::rm_r(@tmpdir)
42
- #end
43
46
  @default_sheet = nil
44
47
  # no need to set default_sheet if there is only one sheet in the document
45
48
  if self.sheets.size == 1
data/lib/roo/version.rb CHANGED
@@ -2,7 +2,7 @@ module Roo #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1 @@
1
+ this is intionally not a spreadsheet file
data/test/test_roo.rb CHANGED
@@ -1773,7 +1773,7 @@ class TestRoo < Test::Unit::TestCase
1773
1773
  def test_huge_document_to_csv_google
1774
1774
  # maybe a better example... TODO:
1775
1775
  after Date.new(2008,1,30) do
1776
- if GOOGLE
1776
+ if GOOGLE and LONG_RUN
1777
1777
  assert_nothing_raised(Timeout::Error) {
1778
1778
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
1779
1779
  File.delete("/tmp/numbers1.csv") if File.exists?("/tmp/numbers1.csv")
@@ -1837,7 +1837,7 @@ class TestRoo < Test::Unit::TestCase
1837
1837
 
1838
1838
  def test_to_csv_google
1839
1839
  # maybe a better example... TODO:
1840
- after Date.new(2008,1,30) do
1840
+ after Date.new(2008,3,30) do
1841
1841
  if GOOGLE
1842
1842
  #assert_nothing_raised(Timeout::Error) {
1843
1843
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
@@ -2972,4 +2972,34 @@ Sheet 3:
2972
2972
  end
2973
2973
  end
2974
2974
 
2975
+ def test_no_remaining_tmp_files_openoffice
2976
+ if OPENOFFICE
2977
+ assert_raise(Zip::ZipError) { #TODO: besseres Fehlerkriterium bei
2978
+ oo = Openoffice.new(File.join("test","no_spreadsheet_file.txt"))
2979
+ }
2980
+ a=Dir.glob("oo_*")
2981
+ assert_equal [], a
2982
+ end
2983
+ end
2984
+
2985
+ def test_no_remaining_tmp_files_excel
2986
+ if EXCEL
2987
+ assert_raise(OLE::UnknownFormatError) {
2988
+ oo = Excel.new(File.join("test","no_spreadsheet_file.txt"))
2989
+ }
2990
+ a=Dir.glob("oo_*")
2991
+ assert_equal [], a
2992
+ end
2993
+ end
2994
+
2995
+ def test_no_remaining_tmp_files_google
2996
+ if GOOGLE
2997
+ assert_nothing_raised() {
2998
+ oo = Google.new(key_of("no_spreadsheet_file.txt"))
2999
+ }
3000
+ a=Dir.glob("oo_*")
3001
+ assert_equal [], a
3002
+ end
3003
+ end
3004
+
2975
3005
  end # class
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.2</a>
36
+ <a href="http://rubyforge.org/projects/roo" class="numbers">0.9.3</a>
37
37
  </div>
38
38
  <h2>What</h2>
39
39
 
@@ -428,6 +428,12 @@ Only the Openoffice- and Excel-parts of this gem are currently working &#8211; t
428
428
  <p>Google spreadsheet can now be used.</p>
429
429
 
430
430
 
431
+ <h2>Tests and test data</h2>
432
+
433
+
434
+ <p>There are many test files within the test directory. If you don&#8217;t want to run unit tests and don&#8217;t want the test data you can completely delete the &#8216;test&#8217; directory within the hierarchy of this gem.</p>
435
+
436
+
431
437
  <h2>Feature Requests / Bugs</h2>
432
438
 
433
439
 
@@ -481,7 +487,7 @@ Only the Openoffice- and Excel-parts of this gem are currently working &#8211; t
481
487
  <li>Thanks to davecahill for a bug-fix patch within the google part</li>
482
488
  </ul>
483
489
  <p class="coda">
484
- <a href="mailto:thopre@gmail.com">Thomas Preymesser</a>, 24th March 2008<br>
490
+ <a href="mailto:thopre@gmail.com">Thomas Preymesser</a>, 25th March 2008<br>
485
491
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
486
492
  </p>
487
493
  </div>
data/website/index.txt CHANGED
@@ -294,6 +294,10 @@ Only the Openoffice- and Excel-parts of this gem are currently working - the Goo
294
294
 
295
295
  Google spreadsheet can now be used.
296
296
 
297
+ h2. Tests and test data
298
+
299
+ There are many test files within the test directory. If you don't want to run unit tests and don't want the test data you can completely delete the 'test' directory within the hierarchy of this gem.
300
+
297
301
  h2. Feature Requests / Bugs
298
302
 
299
303
  Submit Feature Requests and bugs here: "http://rubyforge.org/tracker/?group_id=3729":http://rubyforge.org/tracker/?group_id=3729
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.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Preymesser
@@ -59,6 +59,7 @@ extra_rdoc_files:
59
59
  - License.txt
60
60
  - Manifest.txt
61
61
  - README.txt
62
+ - test/no_spreadsheet_file.txt
62
63
  - website/index.txt
63
64
  files:
64
65
  - History.txt
@@ -86,6 +87,7 @@ files:
86
87
  - test/Bibelbund.csv
87
88
  - test/bbu.xls
88
89
  - test/bbu.ods
90
+ - test/no_spreadsheet_file.txt
89
91
  - test/simple_spreadsheet.ods
90
92
  - test/simple_spreadsheet.xls
91
93
  - test/simple_spreadsheet_from_italo.ods