roo 0.0.2 → 0.0.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,14 @@
1
+ == 0.0.3 2007-05-30
2
+
3
+ * 1 minor enhancement:
4
+ * new method row()
5
+
6
+ == 0.0.2 2007-05-30
7
+
8
+ * 2 major enhancement:
9
+ * fixed some bugs
10
+ * more ways to access a cell
11
+
1
12
  == 0.0.1 2007-05-25
2
13
 
3
14
  * 1 major enhancement:
data/Rakefile CHANGED
@@ -72,10 +72,10 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
72
72
  # == Optional
73
73
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
74
74
  #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
75
- p.extra_deps = [
76
- ['ruport', '>= 1.0.0'],
77
- ['ruport-util', '>= 0.5.0'],
78
- ]
75
+ #p.extra_deps = [
76
+ # ['ruport', '>= 1.0.0'],
77
+ # ['ruport-util', '>= 0.5.0'],
78
+ #]
79
79
  #p.spec_extras = {} # A hash of extra values to set in the gemspec.
80
80
  end
81
81
 
data/lib/roo.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  module Roo
2
2
  end
3
3
 
4
- require 'rubygems'
5
- require 'ruport'
6
- require 'ruport/util'
4
+ #require 'rubygems'
7
5
  require 'roo/version'
8
6
  require 'roo/openoffice'
@@ -1,7 +1,7 @@
1
1
 
2
2
  require 'rubygems'
3
3
  require 'rexml/document'
4
- require 'matrix'
4
+ # require 'matrix'
5
5
  require 'fileutils'
6
6
  require 'zip/zipfilesystem'
7
7
 
@@ -100,6 +100,23 @@ class Openoffice
100
100
  def to_s
101
101
  @cell.inspect
102
102
  end
103
+
104
+ # returns all values in this row as an array
105
+ # row numbers are 1,2,3,... like in the spreadsheet
106
+ def row(rownumber)
107
+ read_cells unless @cells_read
108
+ result = []
109
+ @cell.each_pair {|key,value|
110
+ y,x = key.split(',')
111
+ x = x.to_i
112
+ y = y.to_i
113
+ if y == rownumber
114
+ result[x-1,rownumber] = value
115
+ end
116
+ }
117
+ result
118
+ end
119
+
103
120
  private
104
121
 
105
122
  # read all cells in the selected sheet
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 = 0
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/test/test_roo.rb CHANGED
@@ -47,11 +47,15 @@ class TestRoo < Test::Unit::TestCase
47
47
  assert_equal "tata", oo.cell('A',6)
48
48
  assert_equal "tata", oo.cell(6,'a')
49
49
  assert_equal "tata", oo.cell('a',6)
50
+
50
51
  assert_equal "thisisc8", oo.cell(8,3)
51
52
  assert_equal "thisisc8", oo.cell(8,'C')
52
53
  assert_equal "thisisc8", oo.cell('C',8)
53
54
  assert_equal "thisisc8", oo.cell(8,'c')
54
55
  assert_equal "thisisc8", oo.cell('c',8)
56
+
57
+ assert_equal "thisisd9", oo.cell('d',9)
58
+ assert_equal "thisisa11", oo.cell('a',11)
55
59
  end
56
60
 
57
61
  # Version of the (XML) office document
@@ -61,4 +65,15 @@ class TestRoo < Test::Unit::TestCase
61
65
  assert_equal "1.0", oo.officeversion
62
66
  end
63
67
 
68
+ def test_rows
69
+ oo = Openoffice.new("test/numbers1.ods")
70
+ oo.default_sheet = oo.sheets.first
71
+ assert_equal 41, oo.cell('a',12)
72
+ assert_equal 42, oo.cell('b',12)
73
+ assert_equal 43, oo.cell('c',12)
74
+ assert_equal 44, oo.cell('d',12)
75
+ assert_equal 45, oo.cell('e',12)
76
+ assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12)
77
+ end
78
+
64
79
  end
data/website/index.html CHANGED
@@ -33,12 +33,12 @@
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.0.2</a>
36
+ <a href="http://rubyforge.org/projects/roo" class="numbers">0.0.3</a>
37
37
  </div>
38
- <h1>&#x2192; &#8216;roo&#8217;</h1>
38
+ <h2>What</h2>
39
39
 
40
40
 
41
- <h2>What</h2>
41
+ <p>This gem allows you to access the values from open-office documents (.ods).</p>
42
42
 
43
43
 
44
44
  <h2>Installing</h2>
@@ -49,7 +49,7 @@
49
49
  <h2>The basics</h2>
50
50
 
51
51
 
52
- <p>This gem allows you to access the values from open-office documents (.ods).</p>
52
+ <p>Currently only read-access is implemented.</p>
53
53
 
54
54
 
55
55
  <p>Please note that the upper left cell of a table is numbered (1,1) or (1,&#8217;A&#8217;) (not 0,0).</p>
@@ -58,56 +58,88 @@
58
58
  <h2>Demonstration of usage</h2>
59
59
 
60
60
 
61
- <p>Not a complete tutorial (I will add this later) but these snippets from the tests will hopefully show you how to use this gem.</p>
61
+ <p>Supposed you have created this spreadsheet:</p>
62
+
63
+
64
+ <p><img src="Screenshot-spreadsheet.png"></p>
65
+
66
+
67
+ <p>which includes the amount of work you have done for a customer.</p>
68
+
69
+
70
+ <p>You can now process this spreadsheet with the following sample code.</p>
62
71
 
63
72
 
64
73
  <pre>
65
74
  <code>
66
- def test_sheets
67
- oo = Openoffice.new("numbers1.ods")
68
- assert_equal ["Tabelle1","Sheet2","Sheet3"], oo.sheets
69
- end
70
-
71
- def test_cell
72
- oo = Openoffice.new("numbers1.ods")
73
- oo.default_sheet = oo.sheets.first
74
- assert_equal 1, oo.cell(1,1)
75
- assert_equal 2, oo.cell(1,2)
76
- assert_equal 3, oo.cell(1,3)
77
- assert_equal 4, oo.cell(1,4)
78
- assert_equal 5, oo.cell(2,1)
79
- assert_equal 6, oo.cell(2,2)
80
- assert_equal 7, oo.cell(2,3)
81
- assert_equal 8, oo.cell(2,4)
82
- assert_equal 9, oo.cell(2,5)
83
- assert_equal "test", oo.cell(2,6)
84
- assert_equal "string", oo.celltype(2,6)
85
- assert_equal 11, oo.cell(2,7)
86
-
87
- assert_equal 10, oo.cell(4,1)
88
- assert_equal 11, oo.cell(4,2)
89
- assert_equal 12, oo.cell(4,3)
90
- assert_equal 13, oo.cell(4,4)
91
- assert_equal 14, oo.cell(4,5)
92
-
93
- assert_equal 10, oo.cell(4,'A')
94
- assert_equal 11, oo.cell(4,'B')
95
- assert_equal 12, oo.cell(4,'C')
96
- assert_equal 13, oo.cell(4,'D')
97
- assert_equal 14, oo.cell(4,'E')
98
-
99
- assert_equal "date", oo.celltype(5,1)
100
- assert_equal "1961-11-21", oo.cell(5,1)
101
- end
75
+ 1 require 'rubygems'
76
+ 2 require 'roo'
77
+ 3
78
+ 4 HOURLY_RATE = 123.45
79
+ 5
80
+ 6 oo = Openoffice.new("/home/tp/Desktop/simple_spreadsheet.ods")
81
+ 7 oo.default_sheet = oo.sheets.first
82
+ 8 4.upto(1000) do |line|
83
+ 9 # puts "line: "+line.to_s
84
+ 10 date = oo.cell(line,'A')
85
+ 11 start_time = oo.cell(line,'B')
86
+ 12 start_time = 0.0 unless start_time
87
+ 13 end_time = oo.cell(line,'C')
88
+ 14 end_time = 0.0 unless end_time
89
+ 15 pause = oo.cell(line,'D')
90
+ 16 pause = 0.0 unless pause
91
+ 17 sum = (end_time-start_time)-pause
92
+ 18 comment = oo.cell(line,'F')
93
+ 19 amount = sum * HOURLY_RATE
94
+ 20 if date
95
+ 21 puts "#{date}\t#{sum}\t#{amount}\t#{comment}"
96
+ 22 end
97
+ 23 end
102
98
  </code>
103
99
  </pre>
104
100
 
101
+ <p>which produces this output</p>
102
+
103
+
104
+ <pre>
105
+ <code>
106
+ 2007-05-07 1.75 216.0375 lokale lauff��hige Umgebung aufgesetzt, Datenbank eingerichtet, Repository erstellt und anf��nglichen Sourcecode eingestellt
107
+ 2007-05-07 1.0 123.45 Userstories erfasst
108
+ 2007-05-08 1.0 123.45 Test neuen User anlegen, Perioden (��berschneidend) anzulegen
109
+ 2007-05-08 1.0 123.45 Bestandsaufnahme/Aufwandssch��tzung/Korrespondenz
110
+ 2007-05-08 0.5 61.725 Functional Test Ueberschneidung
111
+ 2007-05-14 0.5 61.725
112
+ 2007-05-14 0.5 61.725
113
+ 2007-05-15 1.0 123.45
114
+ 2007-05-15 0.75 92.5875 G��stebuch
115
+ 2007-05-15 0.5 61.725 G��stebuch
116
+ 2007-05-15 0.5 61.725 G��stebuch
117
+ 2007-05-16 1.0 123.45 G��stebuch
118
+ 2007-05-17 0.25 30.8625 G��stebuch
119
+ 2007-05-17 1.25 154.3125 G��stebuch
120
+ 2007-05-18 3.0 370.35 G��stebuch
121
+ 2007-05-18 1.75 216.0375 G��stebuch
122
+ </code>
123
+ </pre>
124
+
125
+ <h2>Documentation</h2>
126
+
127
+
128
+ <p><a href="rdoc/index.html">rdoc</a></p>
129
+
130
+
105
131
  <h2>Forum</h2>
106
132
 
107
133
 
108
134
  <p><a href="http://groups.google.com/group/ruby-roo">http://groups.google.com/group/ruby-roo</a></p>
109
135
 
110
136
 
137
+ <h2>Wiki</h2>
138
+
139
+
140
+ <p><a href="http://roo.rubyforge.org/wiki/wiki.pl">http://roo.rubyforge.org/wiki/wiki.pl</a></p>
141
+
142
+
111
143
  <h2>License</h2>
112
144
 
113
145
 
@@ -119,7 +151,7 @@ def test_sheets
119
151
 
120
152
  <p>Comments are welcome. Send an email to <a href="mailto:thopre@gmail.com">Thomas Preymesser</a>.</p>
121
153
  <p class="coda">
122
- <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 29th May 2007<br>
154
+ <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 30th May 2007<br>
123
155
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
124
156
  </p>
125
157
  </div>
data/website/index.txt CHANGED
@@ -1,10 +1,8 @@
1
1
  h1. roo
2
2
 
3
- h1. &#x2192; 'roo'
4
-
5
-
6
3
  h2. What
7
4
 
5
+ This gem allows you to access the values from open-office documents (.ods).
8
6
 
9
7
  h2. Installing
10
8
 
@@ -12,60 +10,83 @@ h2. Installing
12
10
 
13
11
  h2. The basics
14
12
 
15
- This gem allows you to access the values from open-office documents (.ods).
13
+ Currently only read-access is implemented.
16
14
 
17
15
  Please note that the upper left cell of a table is numbered (1,1) or (1,'A') (not 0,0).
18
16
 
19
17
  h2. Demonstration of usage
20
18
 
21
- Not a complete tutorial (I will add this later) but these snippets from the tests will hopefully show you how to use this gem.
19
+ Supposed you have created this spreadsheet:
20
+
21
+ <img src="Screenshot-spreadsheet.png">
22
+
23
+ which includes the amount of work you have done for a customer.
24
+
25
+ You can now process this spreadsheet with the following sample code.
26
+
27
+ <pre>
28
+ <code>
29
+ 1 require 'rubygems'
30
+ 2 require 'roo'
31
+ 3
32
+ 4 HOURLY_RATE = 123.45
33
+ 5
34
+ 6 oo = Openoffice.new("/home/tp/Desktop/simple_spreadsheet.ods")
35
+ 7 oo.default_sheet = oo.sheets.first
36
+ 8 4.upto(1000) do |line|
37
+ 9 # puts "line: "+line.to_s
38
+ 10 date = oo.cell(line,'A')
39
+ 11 start_time = oo.cell(line,'B')
40
+ 12 start_time = 0.0 unless start_time
41
+ 13 end_time = oo.cell(line,'C')
42
+ 14 end_time = 0.0 unless end_time
43
+ 15 pause = oo.cell(line,'D')
44
+ 16 pause = 0.0 unless pause
45
+ 17 sum = (end_time-start_time)-pause
46
+ 18 comment = oo.cell(line,'F')
47
+ 19 amount = sum * HOURLY_RATE
48
+ 20 if date
49
+ 21 puts "#{date}\t#{sum}\t#{amount}\t#{comment}"
50
+ 22 end
51
+ 23 end
52
+ </code>
53
+ </pre>
54
+
55
+ which produces this output
22
56
 
23
57
  <pre>
24
58
  <code>
25
- def test_sheets
26
- oo = Openoffice.new("numbers1.ods")
27
- assert_equal ["Tabelle1","Sheet2","Sheet3"], oo.sheets
28
- end
29
-
30
- def test_cell
31
- oo = Openoffice.new("numbers1.ods")
32
- oo.default_sheet = oo.sheets.first
33
- assert_equal 1, oo.cell(1,1)
34
- assert_equal 2, oo.cell(1,2)
35
- assert_equal 3, oo.cell(1,3)
36
- assert_equal 4, oo.cell(1,4)
37
- assert_equal 5, oo.cell(2,1)
38
- assert_equal 6, oo.cell(2,2)
39
- assert_equal 7, oo.cell(2,3)
40
- assert_equal 8, oo.cell(2,4)
41
- assert_equal 9, oo.cell(2,5)
42
- assert_equal "test", oo.cell(2,6)
43
- assert_equal "string", oo.celltype(2,6)
44
- assert_equal 11, oo.cell(2,7)
45
-
46
- assert_equal 10, oo.cell(4,1)
47
- assert_equal 11, oo.cell(4,2)
48
- assert_equal 12, oo.cell(4,3)
49
- assert_equal 13, oo.cell(4,4)
50
- assert_equal 14, oo.cell(4,5)
51
-
52
- assert_equal 10, oo.cell(4,'A')
53
- assert_equal 11, oo.cell(4,'B')
54
- assert_equal 12, oo.cell(4,'C')
55
- assert_equal 13, oo.cell(4,'D')
56
- assert_equal 14, oo.cell(4,'E')
57
-
58
- assert_equal "date", oo.celltype(5,1)
59
- assert_equal "1961-11-21", oo.cell(5,1)
60
- end
59
+ 2007-05-07 1.75 216.0375 lokale lauff��hige Umgebung aufgesetzt, Datenbank eingerichtet, Repository erstellt und anf��nglichen Sourcecode eingestellt
60
+ 2007-05-07 1.0 123.45 Userstories erfasst
61
+ 2007-05-08 1.0 123.45 Test neuen User anlegen, Perioden (��berschneidend) anzulegen
62
+ 2007-05-08 1.0 123.45 Bestandsaufnahme/Aufwandssch��tzung/Korrespondenz
63
+ 2007-05-08 0.5 61.725 Functional Test Ueberschneidung
64
+ 2007-05-14 0.5 61.725
65
+ 2007-05-14 0.5 61.725
66
+ 2007-05-15 1.0 123.45
67
+ 2007-05-15 0.75 92.5875 G��stebuch
68
+ 2007-05-15 0.5 61.725 G��stebuch
69
+ 2007-05-15 0.5 61.725 G��stebuch
70
+ 2007-05-16 1.0 123.45 G��stebuch
71
+ 2007-05-17 0.25 30.8625 G��stebuch
72
+ 2007-05-17 1.25 154.3125 G��stebuch
73
+ 2007-05-18 3.0 370.35 G��stebuch
74
+ 2007-05-18 1.75 216.0375 G��stebuch
61
75
  </code>
62
76
  </pre>
63
77
 
78
+ h2. Documentation
79
+
80
+ "rdoc":rdoc/index.html
64
81
 
65
82
  h2. Forum
66
83
 
67
84
  "http://groups.google.com/group/ruby-roo":http://groups.google.com/group/ruby-roo
68
85
 
86
+ h2. Wiki
87
+
88
+ "http://roo.rubyforge.org/wiki/wiki.pl":http://roo.rubyforge.org/wiki/wiki.pl
89
+
69
90
  h2. License
70
91
 
71
92
  This code is free to use under the terms of Ruby
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: roo
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
6
+ version: 0.0.3
7
7
  date: 2007-05-30 00:00:00 +02:00
8
8
  summary: roo can access the contents of OpenOffice-Spreadsheets
9
9
  require_paths:
@@ -64,22 +64,5 @@ extensions: []
64
64
 
65
65
  requirements: []
66
66
 
67
- dependencies:
68
- - !ruby/object:Gem::Dependency
69
- name: ruport
70
- version_requirement:
71
- version_requirements: !ruby/object:Gem::Version::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 1.0.0
76
- version:
77
- - !ruby/object:Gem::Dependency
78
- name: ruport-util
79
- version_requirement:
80
- version_requirements: !ruby/object:Gem::Version::Requirement
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: 0.5.0
85
- version:
67
+ dependencies: []
68
+