roo 1.9.2 → 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/roo.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  module Roo
3
3
 
4
4
  # :stopdoc:
5
- VERSION = '1.9.2'
5
+ VERSION = '1.9.3'
6
6
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
7
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
8
  # :startdoc:
@@ -163,13 +163,15 @@ class GenericSpreadsheet
163
163
  true
164
164
  end
165
165
 
166
- def to_matrix(sheet=nil)
166
+ def to_matrix(from_row=nil, from_column=nil, to_row=nil, to_column=nil,sheet=nil)
167
167
  sheet = @default_sheet unless sheet
168
168
  arr = []
169
169
  pos = 0
170
- first_row.upto(last_row) do |row|
170
+
171
+ (from_row||first_row(sheet)).upto(to_row||last_row(sheet)) do |row|
171
172
  line = []
172
- first_column.upto(last_column) do |col|
173
+ (from_column||first_column(sheet)).upto(to_column||last_column(sheet)) do |col|
174
+
173
175
  line << cell(row,col)
174
176
  end
175
177
  arr[pos] = line
data/test/matrix.ods CHANGED
Binary file
data/test/matrix.xls CHANGED
Binary file
data/test/test_roo.rb CHANGED
@@ -72,8 +72,9 @@ class Test::Unit::TestCase
72
72
  'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
73
73
  #'datetime' => "r2kQpXWr6xOSUpw9MyXavYg",
74
74
  'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
75
- 'whitespace' => "rZyQaoFebVGeHKzjG6e9gRQ"
76
- }[spreadsheetname]
75
+ 'whitespace' => "rZyQaoFebVGeHKzjG6e9gRQ",
76
+ 'matrix' => '0AkCuGANLc3jFdHY3cWtYUkM4bVdadjZ5VGpfTzFEUEE',
77
+ }[spreadsheetname]
77
78
  # 'numbers1' => "o10837434939102457526.4784396906364855777",
78
79
  # 'borders' => "o10837434939102457526.664868920231926255",
79
80
  # 'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
@@ -138,10 +139,10 @@ class TestRoo < Test::Unit::TestCase
138
139
 
139
140
  OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
140
141
  EXCEL = true # do Excel Tests?
141
- GOOGLE = false # do Google-Spreadsheet Tests?
142
+ GOOGLE = true # do Google-Spreadsheet Tests?
142
143
  EXCELX = true # do Excel-X Tests? (.xlsx-files)
143
144
 
144
- ONLINE = false
145
+ ONLINE = true
145
146
  LONG_RUN = true
146
147
  GLOBAL_TIMEOUT = 48.minutes #*60 # 2*12*60 # seconds
147
148
 
@@ -1264,6 +1265,7 @@ class TestRoo < Test::Unit::TestCase
1264
1265
  end
1265
1266
 
1266
1267
  def test_write_google
1268
+ after Date.new(2010,3,10) do
1267
1269
  # write.me: http://spreadsheets.google.com/ccc?key=ptu6bbahNZpY0N0RrxQbWdw&hl=en_GB
1268
1270
  with_each_spreadsheet(:name=>'write.me', :format=>:google) do |oo|
1269
1271
  oo.default_sheet = oo.sheets.first
@@ -1272,6 +1274,7 @@ class TestRoo < Test::Unit::TestCase
1272
1274
  oo.set_value(1,1, 1.0)
1273
1275
  assert_equal 1.0, oo.cell(1,1)
1274
1276
  end
1277
+ end
1275
1278
  end
1276
1279
 
1277
1280
  def test_bug_set_value_with_more_than_one_sheet_google
@@ -1411,7 +1414,7 @@ Sheet 3:
1411
1414
  end
1412
1415
 
1413
1416
  def test_no_remaining_tmp_files_google
1414
- after Date.new(2009,11,1) do
1417
+ after Date.new(2010,4,1) do
1415
1418
  # Exception ist irgendwie anders, nochmal ansehen TODO:
1416
1419
  if GOOGLE
1417
1420
  assert_nothing_raised() {
@@ -1805,7 +1808,7 @@ Sheet 3:
1805
1808
  # Need to extend to other formats
1806
1809
  def test_row_whitespace
1807
1810
  # auf dieses Dokument habe ich keinen Zugriff TODO:
1808
- after Date.new(2009,11,1) do
1811
+ after Date.new(2010,4,1) do
1809
1812
  with_each_spreadsheet(:name=>'whitespace') do |oo|
1810
1813
  oo.default_sheet = "Sheet1"
1811
1814
  assert_equal [nil, nil, nil, nil, nil, nil], oo.row(1)
@@ -1823,7 +1826,7 @@ Sheet 3:
1823
1826
  end
1824
1827
 
1825
1828
  def test_col_whitespace
1826
- after Date.new(2009,11,20) do
1829
+ after Date.new(2010,2,20) do
1827
1830
  #TODO:
1828
1831
  # kein Zugriff auf Dokument whitespace
1829
1832
  with_each_spreadsheet(:name=>'whitespace') do |oo|
@@ -1873,7 +1876,7 @@ Sheet 3:
1873
1876
  end
1874
1877
 
1875
1878
  def test_cell_methods
1876
- after Date.new(2010,1,30) do
1879
+ after Date.new(2010,3,30) do
1877
1880
  with_each_spreadsheet(:name=>'numbers1') do |oo|
1878
1881
  assert_equal 10, oo.a4 # cell(4,'A')
1879
1882
  assert_equal 11, oo.b4 # cell(4,'B')
@@ -1918,7 +1921,7 @@ Sheet 3:
1918
1921
  end
1919
1922
 
1920
1923
  def test_labeled_cells
1921
- after Date.new(2010,1,25) do
1924
+ after Date.new(2010,3,25) do
1922
1925
  # TODO: more spreadsheet types
1923
1926
  with_each_spreadsheet(:name=>'named_cells', :format=>:openoffice) do |oo|
1924
1927
  oo.default_sheet = oo.sheets.first
@@ -1961,12 +1964,12 @@ Sheet 3:
1961
1964
 
1962
1965
  def test_bug_excel_last_row_255
1963
1966
  after Date.new(2010,2,20) do
1964
- oo = Excel.new(File.join('test','ScienceStaff.xls'))
1965
- oo.default_sheet = oo.sheets.first
1966
- assert_equal "COMSCI", oo.cell(255,1)
1967
- assert_equal "lala", oo.cell(256,1)
1968
- assert_equal 1537, oo.last_row
1969
- end
1967
+ oo = Excel.new(File.join('test','ScienceStaff.xls'))
1968
+ oo.default_sheet = oo.sheets.first
1969
+ assert_equal "COMSCI", oo.cell(255,1)
1970
+ assert_equal "lala", oo.cell(256,1)
1971
+ assert_equal 1537, oo.last_row
1972
+ end
1970
1973
  end
1971
1974
 
1972
1975
  def test_bug_excel_last_row_255_modified
@@ -1974,13 +1977,46 @@ Sheet 3:
1974
1977
  oo.default_sheet = oo.sheets.first
1975
1978
  assert_equal 1537, oo.last_row
1976
1979
  end
1977
- require 'matrix'
1978
- def test_matrix
1979
- with_each_spreadsheet(:name => 'matrix', :format => [:openoffice, :excel, :google]) do |oo|
1980
- oo.default_sheet = oo.sheets.first
1981
- assert_equal Matrix[ [1.0, 2.0, 3.0],
1982
- [4.0, 5.0, 6.0],
1983
- [7.0, 8.0, 9.0] ], oo.to_matrix
1980
+
1981
+ require 'matrix'
1982
+ def test_matrix
1983
+ with_each_spreadsheet(:name => 'matrix', :format => [:openoffice, :excel, :google]) do |oo|
1984
+ oo.default_sheet = oo.sheets.first
1985
+ assert_equal Matrix[
1986
+ [1.0, 2.0, 3.0],
1987
+ [4.0, 5.0, 6.0],
1988
+ [7.0, 8.0, 9.0] ], oo.to_matrix
1989
+ end
1990
+ end
1991
+
1992
+ def test_matrix_selected_range
1993
+ with_each_spreadsheet(:name => 'matrix', :format=>[:excel,:openoffice,:google]) do |oo|
1994
+ oo.default_sheet = 'Sheet2'
1995
+ assert_equal Matrix[
1996
+ [1.0, 2.0, 3.0],
1997
+ [4.0, 5.0, 6.0],
1998
+ [7.0, 8.0, 9.0] ], oo.to_matrix(3,4,5,6)
1999
+ end
2000
+ end
2001
+
2002
+ def test_matrix_all_nil
2003
+ with_each_spreadsheet(:name => 'matrix', :format=>[:excel,:openoffice,:google]) do |oo|
2004
+ oo.default_sheet = 'Sheet2'
2005
+ assert_equal Matrix[
2006
+ [nil, nil, nil],
2007
+ [nil, nil, nil],
2008
+ [nil, nil, nil] ], oo.to_matrix(10,10,12,12)
2009
+ end
2010
+ end
2011
+
2012
+ def test_matrix_values_and_nil
2013
+ with_each_spreadsheet(:name => 'matrix', :format=>[:excel,:openoffice,:google]) do |oo|
2014
+ oo.default_sheet = 'Sheet3'
2015
+ assert_equal Matrix[
2016
+ [1.0, nil, 3.0],
2017
+ [4.0, 5.0, 6.0],
2018
+ [7.0, 8.0, nil] ], oo.to_matrix(1,1,3,3)
1984
2019
  end
1985
2020
  end
1986
- end # class
2021
+
2022
+ 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.2
4
+ version: 1.9.3
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: 2010-01-18 00:00:00 +01:00
12
+ date: 2010-02-12 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 3.2.0
23
+ version: 3.2.1
24
24
  version:
25
25
  description: |-
26
26
  Roo can access the contents of various spreadsheet files. It can handle
@@ -46,6 +46,7 @@ files:
46
46
  - Rakefile
47
47
  - bin/roo
48
48
  - csv11159
49
+ - csv1414
49
50
  - csv9419
50
51
  - csv9957
51
52
  - lib/roo.rb