thiagoarrais-rodf 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,2 @@
1
+ v0.1. First version with very basic support for spreadsheet generation
2
+
data/LICENSE.LGPL ADDED
@@ -0,0 +1,166 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
166
+
data/Manifest ADDED
@@ -0,0 +1,22 @@
1
+ lib/odf/row.rb
2
+ lib/odf/spreadsheet.rb
3
+ lib/odf/cell.rb
4
+ lib/odf/column.rb
5
+ lib/odf/table.rb
6
+ lib/odf/property.rb
7
+ lib/odf/style.rb
8
+ lib/odf/skeleton/manifest.xml
9
+ lib/odf/skeleton/styles.xml
10
+ lib/odf/container.rb
11
+ CHANGELOG
12
+ README.rdoc
13
+ Rakefile
14
+ LICENSE.LGPL
15
+ spec/cell_spec.rb
16
+ spec/spreadsheet_spec.rb
17
+ spec/spec_helper.rb
18
+ spec/row_spec.rb
19
+ spec/table_spec.rb
20
+ spec/style_spec.rb
21
+ spec/property_spec.rb
22
+ Manifest
data/README.rdoc ADDED
@@ -0,0 +1,41 @@
1
+ = rODF
2
+
3
+ This is (soon to be) a RubyGem for writing to ODF output. It currently supports
4
+ creating spreadsheets.
5
+
6
+ This is NOT an ODF reading library.
7
+
8
+ == Installation
9
+
10
+ At some moment you'll be able to
11
+
12
+ sudo gem install rodf
13
+
14
+ But for the time being, try going to the project's GitHub page and downloading
15
+ the source: http://github.com/thiagoarrais/rodf/tree
16
+
17
+ == How do I use it?
18
+
19
+ rODF works pretty much like Builder, but with ODF-aware constructs. Try this:
20
+
21
+ require 'odf/spreadsheet'
22
+
23
+ ODF::SpreadSheet.file("my-spreadsheet.ods") do |spreadsheet|
24
+ spreadsheet.table 'My first table from Ruby' do |table|
25
+ table.row {|row| row.cell 'Hello, rODF world!' }
26
+ end
27
+ end
28
+
29
+ Some basic formatting is also possible:
30
+
31
+ require 'odf/spreadsheet'
32
+
33
+ ODF::SpreadSheet.file("my-spreadsheet.ods") do |spreadsheet|
34
+ spreadsheet.style 'red-cell', :family => :cell do |style|
35
+ style.property :text, 'font-weight' => 'bold', 'color' => '#ff0000'
36
+ end
37
+ spreadsheet.table 'Red text table' do |table|
38
+ table.row {|row| row.cell 'Red', :style => 'red-cell' }
39
+ end
40
+ end
41
+
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ Spec::Rake::SpecTask.new
4
+ task :default => :spec
5
+ task :test => :spec
6
+
7
+ require 'echoe'
8
+ Echoe.new('rodf') do |gem|
9
+ gem.author = "Thiago Arrais"
10
+ gem.email = "thiago.arrais@gmail.com"
11
+ gem.url = "http://github.com/thiagoarrais/rodf/tree"
12
+ gem.summary = "ODF generation library for Ruby"
13
+
14
+ gem.runtime_dependencies = [
15
+ ["builder", ">= 2.1.2"],
16
+ ["rubyzip", ">= 0.9.1"],
17
+ ["activesupport", "= 2.1.2"]]
18
+ gem.development_dependencies = [
19
+ ["rspec", ">= 1.1.11"],
20
+ ["rspec_hpricot_matchers" , ">= 1.0"],
21
+ ["echoe" , ">= 3.0.2"]]
22
+ end
data/lib/odf/cell.rb ADDED
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'rubygems'
19
+ require 'builder'
20
+
21
+ module ODF
22
+ class Cell
23
+ def initialize(*args)
24
+ value = args.first || ''
25
+ opts = args.last.instance_of?(Hash) ? args.last : {}
26
+
27
+ @type = opts[:type] || :string
28
+ @value = value.to_s.strip unless value.instance_of? Hash
29
+
30
+ @elem_attrs = make_element_attributes(@type, @value, opts)
31
+ end
32
+
33
+ def xml
34
+ Builder::XmlMarkup.new.tag! 'table:table-cell', @elem_attrs do |xml|
35
+ xml.text(:p, @value) if contains_string?
36
+ end
37
+ end
38
+
39
+ def contains_string?
40
+ :string == @type && !@value.nil? && !@value.empty?
41
+ end
42
+
43
+ def make_element_attributes(type, value, opts)
44
+ attrs = {'office:value-type' => type}
45
+ attrs['office:value'] = value unless contains_string?
46
+ attrs['table:formula'] = opts[:formula] unless opts[:formula].nil?
47
+ attrs['table:style-name'] = opts[:style] unless opts[:style].nil?
48
+ attrs['table:number-matrix-columns-spanned'] =
49
+ attrs['table:number-matrix-rows-spanned'] = 1 if opts[:matrix_formula]
50
+ attrs
51
+ end
52
+ end
53
+ end
54
+
data/lib/odf/column.rb ADDED
@@ -0,0 +1,33 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'rubygems'
19
+ require 'builder'
20
+
21
+ module ODF
22
+ class Column
23
+ def initialize(opts={})
24
+ @elem_attrs = {}
25
+ @elem_attrs['table:style-name'] = opts[:style] unless opts[:style].nil?
26
+ end
27
+
28
+ def xml
29
+ Builder::XmlMarkup.new.tag! 'table:table-column', @elem_attrs
30
+ end
31
+ end
32
+ end
33
+
@@ -0,0 +1,57 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'rubygems'
19
+ gem 'activesupport', '2.1.2'
20
+
21
+ require 'active_support/core_ext/string'
22
+
23
+ module ODF
24
+ class Container
25
+ def self.contains(*stuffs_array)
26
+ stuffs_array.map {|sym| sym.to_s}.each do |stuffs|
27
+ stuff = stuffs.to_s.singularize
28
+ stuff_class = eval(stuff.capitalize)
29
+
30
+ self.class_eval "
31
+ def #{stuffs}
32
+ @#{stuffs} ||= []
33
+ end"
34
+
35
+ self.class_eval "
36
+ def #{stuff}(*args)
37
+ c = #{stuff_class}.new(*args)
38
+ yield c if block_given?
39
+ #{stuffs} << c
40
+ c
41
+ end"
42
+
43
+ self.class_eval "
44
+ def #{stuffs}_xml
45
+ #{stuffs}.map {|c| c.xml}.join
46
+ end"
47
+ end
48
+ end
49
+
50
+ def self.create(*args)
51
+ container = self.new(*args)
52
+ yield container if block_given?
53
+ container.xml
54
+ end
55
+ end
56
+ end
57
+
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'rubygems'
19
+ require 'builder'
20
+
21
+ module ODF
22
+ class Property
23
+ PROPERTY_NAMES = {:cell => 'style:table-cell-properties',
24
+ :text => 'style:text-properties',
25
+ :column => 'style:table-column-properties'}
26
+
27
+ def initialize(type, specs={})
28
+ @name = PROPERTY_NAMES[type]
29
+ @specs = specs.map { |k, v| [k.to_s, v] }
30
+ end
31
+
32
+ def xml
33
+ specs = @specs.inject({}) do |acc, kv|
34
+ prefix = 'column-width' == kv.first ? 'style' : 'fo'
35
+ acc.merge prefix + ':' + kv.first => kv.last
36
+ end
37
+ Builder::XmlMarkup.new.tag! @name, specs
38
+ end
39
+ end
40
+ end
41
+
data/lib/odf/row.rb ADDED
@@ -0,0 +1,40 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'rubygems'
19
+ require 'builder'
20
+
21
+ require 'odf/container'
22
+ require 'odf/cell'
23
+
24
+ module ODF
25
+ class Row < Container
26
+ contains :cells
27
+ attr_reader :number
28
+
29
+ def initialize(number=0)
30
+ @number = number
31
+ end
32
+
33
+ def xml
34
+ Builder::XmlMarkup.new.tag! 'table:table-row' do |xml|
35
+ xml << cells_xml
36
+ end
37
+ end
38
+ end
39
+ end
40
+
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
3
+ <manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
4
+ <manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.spreadsheet" manifest:full-path="/"/>
5
+ <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/>
6
+ <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="styles.xml"/>
7
+ </manifest:manifest>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
3
+ xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
4
+ xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
5
+ xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0">
6
+ <office:font-face-decls>
7
+ <style:font-face style:name="Arial1" svg:font-family="Arial" style:font-family-generic="swiss"/>
8
+ </office:font-face-decls>
9
+ <office:styles>
10
+ <style:style style:name="Default" style:family="table-cell">
11
+ <style:table-cell-properties style:rotation-align="none"/>
12
+ <style:text-properties style:font-name="Arial1" style:font-name-complex="Arial1"/>
13
+ </style:style>
14
+ <number:number-style style:name="currency-grouped">
15
+ <number:number number:decimal-places="2" number:min-integer-digits="1" number:grouping="true" />
16
+ </number:number-style>
17
+ <number:number-style style:name="integer-grouped">
18
+ <number:number number:decimal-places="0" number:min-integer-digits="1" number:grouping="true" />
19
+ </number:number-style>
20
+ </office:styles>
21
+ </office:document-styles>
22
+
@@ -0,0 +1,71 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'rubygems'
19
+
20
+ require 'builder'
21
+ require 'zip/zip'
22
+
23
+ require 'odf/container'
24
+ require 'odf/style'
25
+ require 'odf/table'
26
+
27
+ module ODF
28
+ class SpreadSheet < Container
29
+ contains :tables, :styles
30
+
31
+ def self.file(ods_file_name)
32
+ ods_file = Zip::ZipFile.open(ods_file_name, Zip::ZipFile::CREATE)
33
+ ods_file.get_output_stream('styles.xml') {|f| f << skeleton('styles.xml')}
34
+ ods_file.get_output_stream('META-INF/manifest.xml') {|f| f << skeleton('manifest.xml')}
35
+
36
+ yield(spreadsheet = new)
37
+
38
+ ods_file.get_output_stream('content.xml') {|f| f << spreadsheet.xml}
39
+
40
+ ods_file.close
41
+ end
42
+
43
+ def xml
44
+ b = Builder::XmlMarkup.new
45
+
46
+ b.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'
47
+ b.tag! 'office:document-content', 'xmlns:office' => "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
48
+ 'xmlns:table' => "urn:oasis:names:tc:opendocument:xmlns:table:1.0",
49
+ 'xmlns:text' => "urn:oasis:names:tc:opendocument:xmlns:text:1.0",
50
+ 'xmlns:oooc' => "http://openoffice.org/2004/calc",
51
+ 'xmlns:style' => "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
52
+ 'xmlns:fo' => "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" do
53
+ |xml|
54
+ xml.tag! 'office:automatic-styles' do
55
+ xml << styles_xml
56
+ end unless styles.empty?
57
+ xml.office:body do
58
+ xml.office:spreadsheet do
59
+ xml << tables_xml
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ private
66
+ def self.skeleton(fname)
67
+ File.open(File.dirname(__FILE__) + '/skeleton/' + fname).read
68
+ end
69
+ end
70
+ end
71
+
data/lib/odf/style.rb ADDED
@@ -0,0 +1,53 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'rubygems'
19
+ require 'builder'
20
+
21
+ require 'odf/container'
22
+ require 'odf/property'
23
+
24
+ module ODF
25
+ class Style < Container
26
+ contains :properties
27
+
28
+ FAMILIES = {:cell => 'table-cell', :column => 'table-column'}
29
+
30
+ def initialize(name='', opts={})
31
+ @name = name
32
+ @elem_attrs = make_element_attributes(@name, opts)
33
+ end
34
+
35
+ def xml
36
+ Builder::XmlMarkup.new.style:style, @elem_attrs do |xml|
37
+ xml << properties_xml
38
+ end
39
+ end
40
+
41
+ def make_element_attributes(name, opts)
42
+ attrs = {'style:name' => name, 'style:family' => FAMILIES[opts[:family]]}
43
+ attrs['style:data-style-name'] = opts[:data_style] unless opts[:data_style].nil?
44
+ attrs['style:parent-style-name'] = opts[:parent].to_s unless opts[:parent].nil?
45
+ attrs
46
+ end
47
+
48
+ def to_s
49
+ @name
50
+ end
51
+ end
52
+ end
53
+
data/lib/odf/table.rb ADDED
@@ -0,0 +1,50 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'rubygems'
19
+ require 'builder'
20
+
21
+ require 'odf/column'
22
+ require 'odf/container'
23
+ require 'odf/row'
24
+
25
+ module ODF
26
+ class Table < Container
27
+ contains :rows, :columns
28
+
29
+ def initialize(title)
30
+ @title = title
31
+ @last_row = 0
32
+ end
33
+
34
+ alias create_row row
35
+ def row
36
+ create_row(next_row) {|r| yield r if block_given?}
37
+ end
38
+
39
+ def xml
40
+ Builder::XmlMarkup.new.table:table, 'table:name' => @title do |xml|
41
+ xml << columns_xml
42
+ xml << rows_xml
43
+ end
44
+ end
45
+ private
46
+ def next_row
47
+ @last_row += 1
48
+ end
49
+ end
50
+ end
data/rodf.gemspec ADDED
@@ -0,0 +1,49 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{rodf}
5
+ s.version = "0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Thiago Arrais"]
9
+ s.date = %q{2008-11-25}
10
+ s.description = %q{ODF generation library for Ruby}
11
+ s.email = %q{thiago.arrais@gmail.com}
12
+ s.extra_rdoc_files = ["lib/odf/row.rb", "lib/odf/spreadsheet.rb", "lib/odf/cell.rb", "lib/odf/column.rb", "lib/odf/table.rb", "lib/odf/property.rb", "lib/odf/style.rb", "lib/odf/skeleton/manifest.xml", "lib/odf/skeleton/styles.xml", "lib/odf/container.rb", "CHANGELOG", "README.rdoc", "LICENSE.LGPL"]
13
+ s.files = ["lib/odf/row.rb", "lib/odf/spreadsheet.rb", "lib/odf/cell.rb", "lib/odf/column.rb", "lib/odf/table.rb", "lib/odf/property.rb", "lib/odf/style.rb", "lib/odf/skeleton/manifest.xml", "lib/odf/skeleton/styles.xml", "lib/odf/container.rb", "CHANGELOG", "README.rdoc", "Rakefile", "LICENSE.LGPL", "spec/cell_spec.rb", "spec/spreadsheet_spec.rb", "spec/spec_helper.rb", "spec/row_spec.rb", "spec/table_spec.rb", "spec/style_spec.rb", "spec/property_spec.rb", "Manifest", "rodf.gemspec"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/thiagoarrais/rodf/tree}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rodf", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{rodf}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{ODF generation library for Ruby}
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 2
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
28
+ s.add_runtime_dependency(%q<rubyzip>, [">= 0.9.1"])
29
+ s.add_runtime_dependency(%q<activesupport>, ["= 2.1.2"])
30
+ s.add_development_dependency(%q<rspec>, [">= 1.1.11"])
31
+ s.add_development_dependency(%q<rspec_hpricot_matchers>, [">= 1.0"])
32
+ s.add_development_dependency(%q<echoe>, [">= 3.0.2"])
33
+ else
34
+ s.add_dependency(%q<builder>, [">= 2.1.2"])
35
+ s.add_dependency(%q<rubyzip>, [">= 0.9.1"])
36
+ s.add_dependency(%q<activesupport>, ["= 2.1.2"])
37
+ s.add_dependency(%q<rspec>, [">= 1.1.11"])
38
+ s.add_dependency(%q<rspec_hpricot_matchers>, [">= 1.0"])
39
+ s.add_dependency(%q<echoe>, [">= 3.0.2"])
40
+ end
41
+ else
42
+ s.add_dependency(%q<builder>, [">= 2.1.2"])
43
+ s.add_dependency(%q<rubyzip>, [">= 0.9.1"])
44
+ s.add_dependency(%q<activesupport>, ["= 2.1.2"])
45
+ s.add_dependency(%q<rspec>, [">= 1.1.11"])
46
+ s.add_dependency(%q<rspec_hpricot_matchers>, [">= 1.0"])
47
+ s.add_dependency(%q<echoe>, [">= 3.0.2"])
48
+ end
49
+ end
data/spec/cell_spec.rb ADDED
@@ -0,0 +1,91 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
19
+
20
+ require 'odf/cell'
21
+
22
+ describe ODF::Cell do
23
+ it "should hold text content in a paragraph tag" do
24
+ output = ODF::Cell.new('Test').xml
25
+ output.should have_tag('//table:table-cell/*')
26
+ output.should have_tag('//text:p')
27
+ Hpricot(output).at('text:p').innerHTML.should == 'Test'
28
+ end
29
+
30
+ it "should have string as default value type" do
31
+ [ODF::Cell.new('Test').xml, ODF::Cell.new(54).xml].each do |xml|
32
+ Hpricot(xml).at('table:table-cell')['office:value-type'].should=='string'
33
+ end
34
+ end
35
+
36
+ it "should allow value types to be specified" do
37
+ output = ODF::Cell.new(34.2, :type => :float).xml
38
+ Hpricot(output).at('table:table-cell')['office:value-type'].should=='float'
39
+ end
40
+
41
+ it "should place strings in a paragraph tag and floats in value attribute" do
42
+ output = ODF::Cell.new('Test').xml
43
+ Hpricot(output).at('text:p').innerHTML.should == 'Test'
44
+
45
+ output = ODF::Cell.new(47, :type => :float).xml
46
+ output.should_not have_tag('//table:table-cell/*')
47
+ Hpricot(output).at('table:table-cell')['office:value'].should == '47'
48
+
49
+ output = ODF::Cell.new(34.2, :type => :string).xml
50
+ Hpricot(output).at('text:p').innerHTML.should == '34.2'
51
+ end
52
+
53
+ it "should accept formulas" do
54
+ output = ODF::Cell.new(:type => :float,
55
+ :formula => "oooc:=SUM([.A1:.A4])").xml
56
+
57
+ elem = Hpricot(output).at('table:table-cell')
58
+ elem['office:value-type'].should == 'float'
59
+ elem['table:formula'].should == 'oooc:=SUM([.A1:.A4])'
60
+ end
61
+
62
+ it "should accept matrix formulas" do
63
+ output = ODF::Cell.new(:type => :float, :matrix_formula => true,
64
+ :formula => "oooc:=SUM([.A1:.A4])").xml
65
+
66
+ elem = Hpricot(output).at('table:table-cell')
67
+ elem['table:number-matrix-columns-spanned'].should == '1'
68
+ elem['table:number-matrix-rows-spanned'].should == '1'
69
+ end
70
+
71
+ it "should not make a matrix formula when asked not too" do
72
+ output = ODF::Cell.new(:type => :float, :matrix_formula => false,
73
+ :formula => "oooc:=SUM([.A1:.A4])").xml
74
+
75
+ elem = Hpricot(output).at('table:table-cell')
76
+ elem['table:number-matrix-columns-spanned'].should be_nil
77
+ elem['table:number-matrix-rows-spanned'].should be_nil
78
+ end
79
+
80
+ it "should not have an empty paragraph" do
81
+ [ODF::Cell.new, ODF::Cell.new(''), ODF::Cell.new(' ')].each do |cell|
82
+ cell.xml.should_not have_tag('text:p')
83
+ end
84
+ end
85
+
86
+ it "should allow an style to be specified" do
87
+ cell = ODF::Cell.new 45.8, :type => :float, :style => 'left-column-cell'
88
+ Hpricot(cell.xml).at('table:table-cell')['table:style-name'].
89
+ should == 'left-column-cell'
90
+ end
91
+ end
@@ -0,0 +1,39 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
19
+
20
+ require 'odf/property'
21
+
22
+ describe ODF::Property do
23
+ it "should accept either strings or symbols as keys" do
24
+ property = ODF::Property.new :text, :color=>'#4c4c4c', 'font-weight'=>'bold'
25
+ elem = Hpricot(property.xml).at('style:text-properties')
26
+ elem['fo:color'].should == '#4c4c4c'
27
+ elem['fo:font-weight'].should == 'bold'
28
+ end
29
+
30
+ it "should prefix column-width property with style namespace" do
31
+ property = ODF::Property.new :column, 'column-width' => '2cm'
32
+
33
+ property.xml.should have_tag('//style:table-column-properties')
34
+
35
+ elem = Hpricot(property.xml).at('//style:table-column-properties')
36
+ elem['style:column-width'].should == '2cm'
37
+ end
38
+ end
39
+
data/spec/row_spec.rb ADDED
@@ -0,0 +1,35 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
19
+
20
+ require 'odf/row'
21
+
22
+ describe ODF::Row do
23
+ it "should allow cells to be added" do
24
+ output = ODF::Row.create
25
+ output.should have_tag('//table:table-row')
26
+ output.should_not have_tag('//table:table-row/*')
27
+
28
+ output = ODF::Row.create {|r|
29
+ r.cell
30
+ r.cell
31
+ }
32
+ output.should have_tag('//table:table-row/*', :count => 2)
33
+ output.should have_tag('//table:table-cell')
34
+ end
35
+ end
@@ -0,0 +1,23 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
19
+
20
+ require 'rubygems'
21
+
22
+ require 'rspec_hpricot_matchers'
23
+ include RspecHpricotMatchers
@@ -0,0 +1,73 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
19
+
20
+ require 'odf/spreadsheet'
21
+
22
+ describe ODF::SpreadSheet do
23
+ it "should have the expected structure" do
24
+ output = ODF::SpreadSheet.create {|s| }
25
+ output.should have_tag('//office:document-content/*')
26
+ output.should have_tag('//office:body/*')
27
+ output.should have_tag('//office:spreadsheet')
28
+ end
29
+
30
+ it "should be empty if no tables were added" do
31
+ output = ODF::SpreadSheet.create {|s| }
32
+ output.should_not have_tag('//office:spreadsheet/*')
33
+ end
34
+
35
+ it "should include tables when asked to" do
36
+ output = ODF::SpreadSheet.create { |s|
37
+ s.table 'Example'
38
+ }
39
+ output.should have_tag('//office:spreadsheet/*', :count => 1)
40
+ output.should have_tag('//table:table', :count => 1)
41
+ Hpricot(output).at('//table:table')['table:name'].should == 'Example'
42
+
43
+ output = ODF::SpreadSheet.create { |s|
44
+ s.table 'First table'
45
+ s.table 'Second table'
46
+ }
47
+ output.should have_tag('//office:spreadsheet/*', :count => 2)
48
+ end
49
+
50
+ it "should allow rows to be added inside tables" do
51
+ output = ODF::SpreadSheet.create do |s|
52
+ s.table('My table') do |t|
53
+ t.row
54
+ end
55
+ end
56
+
57
+ output.should have_tag('//table:table/*')
58
+ output.should have_tag('//table:table-row')
59
+ end
60
+
61
+ it "should allow styles to be added" do
62
+ ODF::SpreadSheet.create.should_not have_tag('//office:automatic-styles')
63
+ output = ODF::SpreadSheet.create do |s|
64
+ s.style 'even-row-cell', :family => :cell
65
+ end
66
+
67
+ output.should have_tag('//office:automatic-styles/*', :count => 1)
68
+ output.should have_tag('//style:style')
69
+ Hpricot(output).at('//style:style')['style:name'].should == 'even-row-cell'
70
+ Hpricot(output).at('//style:style')['style:family'].should == 'table-cell'
71
+ end
72
+ end
73
+
@@ -0,0 +1,77 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
19
+
20
+ require 'odf/style'
21
+
22
+ describe ODF::Style do
23
+ it "should output properties when they're added" do
24
+ ODF::Style.create.should_not have_tag('//style:style/*')
25
+
26
+ output = ODF::Style.create 'odd-row-cell', :family => :cell do |s|
27
+ s.property :cell, 'background-color' => '#b3b3b3',
28
+ 'border' => '0.002cm solid #000000'
29
+ s.property :text, 'color' => '#4c4c4c'
30
+ end
31
+
32
+ output.should have_tag('//style:style/*', :count => 2)
33
+ output.should have_tag('//style:table-cell-properties')
34
+ output.should have_tag('//style:text-properties')
35
+
36
+ cell_elem = Hpricot(output).at('style:table-cell-properties')
37
+ cell_elem['fo:background-color'].should == '#b3b3b3'
38
+ cell_elem['fo:border'].should == '0.002cm solid #000000'
39
+
40
+ text_elem = Hpricot(output).at('style:text-properties')
41
+ text_elem['fo:color'].should == '#4c4c4c'
42
+ end
43
+
44
+ it "should allow data styles" do
45
+ xml = ODF::Style.create 'my-style', :family => :cell,
46
+ :data_style => 'currency-grouped'
47
+
48
+ style = Hpricot(xml).at('//style:style')
49
+ style['style:data-style-name'].should == 'currency-grouped'
50
+ end
51
+
52
+ it "should allow parent styles" do
53
+ xml = ODF::Style.create 'child-style', :family => :cell,
54
+ :parent => 'cell-default'
55
+
56
+ style = Hpricot(xml).at('//style:style')
57
+ style['style:parent-style-name'].should == 'cell-default'
58
+
59
+ cell_style = ODF::Style.new('cell-default', :family => :cell)
60
+ xml = ODF::Style.create 'child-style', :family => :cell,
61
+ :parent => cell_style
62
+
63
+ style = Hpricot(xml).at('//style:style')
64
+ style['style:parent-style-name'].should == 'cell-default'
65
+ end
66
+
67
+ it "should be able to describe column styles" do
68
+ xml = ODF::Style.create 'column-style', :family => :column do |style|
69
+ style.property :column, 'column-width' => '2cm'
70
+ end
71
+
72
+ Hpricot(xml).at('//style:style')['style:family'].should == 'table-column'
73
+ xml.should have_tag('//style:style/*', :count => 1)
74
+ xml.should have_tag('//style:table-column-properties')
75
+ end
76
+ end
77
+
@@ -0,0 +1,58 @@
1
+ # Copyright (c) 2008 Thiago Arrais
2
+ #
3
+ # This file is part of rODF.
4
+ #
5
+ # rODF is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as
7
+ # published by the Free Software Foundation, either version 3 of
8
+ # the License, or (at your option) any later version.
9
+
10
+ # rODF is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
19
+
20
+ require 'odf/table'
21
+
22
+ describe ODF::Table do
23
+ it "should allow rows to be added" do
24
+ output = ODF::Table.create('Example') {|t| }
25
+ output.should have_tag('//table:table')
26
+ output.should_not have_tag('//table:table/*')
27
+
28
+ output = ODF::Table.create('MyTable') {|t| t.row }
29
+ output.should have_tag('//table:table/*', :count => 1)
30
+ output.should have_tag('//table:table-row')
31
+
32
+ output = ODF::Table.create('MyTable') {|t|
33
+ t.row
34
+ t.row
35
+ }
36
+ output.should have_tag('//table:table/*', :count => 2)
37
+ output.should have_tag('//table:table-row')
38
+ end
39
+
40
+ it "should provide row numbers" do
41
+ output = ODF::Table.create('Row letter table') {|t|
42
+ t.row {|row| row.cell}
43
+ t.row {|row| row.cell(row.number)}
44
+ }
45
+ output.should have_tag('text:p')
46
+ Hpricot(output).at('text:p').innerHTML.should == '2'
47
+ end
48
+
49
+ it "should allow column style specifications" do
50
+ xml = ODF::Table.create('Styles columns table') do |t|
51
+ t.column :style => 'wide'
52
+ end
53
+
54
+ xml.should have_tag('table:table-column')
55
+ column = Hpricot(xml).at('table:table-column')
56
+ column['table:style-name'].should == 'wide'
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thiagoarrais-rodf
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Thiago Arrais
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-25 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: builder
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.1.2
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: rubyzip
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 0.9.1
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: activesupport
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.1.2
41
+ version:
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ version_requirement:
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.1.11
50
+ version:
51
+ - !ruby/object:Gem::Dependency
52
+ name: rspec_hpricot_matchers
53
+ version_requirement:
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "1.0"
59
+ version:
60
+ - !ruby/object:Gem::Dependency
61
+ name: echoe
62
+ version_requirement:
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 3.0.2
68
+ version:
69
+ description: ODF generation library for Ruby
70
+ email: thiago.arrais@gmail.com
71
+ executables: []
72
+
73
+ extensions: []
74
+
75
+ extra_rdoc_files:
76
+ - lib/odf/row.rb
77
+ - lib/odf/spreadsheet.rb
78
+ - lib/odf/cell.rb
79
+ - lib/odf/column.rb
80
+ - lib/odf/table.rb
81
+ - lib/odf/property.rb
82
+ - lib/odf/style.rb
83
+ - lib/odf/skeleton/manifest.xml
84
+ - lib/odf/skeleton/styles.xml
85
+ - lib/odf/container.rb
86
+ - CHANGELOG
87
+ - README.rdoc
88
+ - LICENSE.LGPL
89
+ files:
90
+ - lib/odf/row.rb
91
+ - lib/odf/spreadsheet.rb
92
+ - lib/odf/cell.rb
93
+ - lib/odf/column.rb
94
+ - lib/odf/table.rb
95
+ - lib/odf/property.rb
96
+ - lib/odf/style.rb
97
+ - lib/odf/skeleton/manifest.xml
98
+ - lib/odf/skeleton/styles.xml
99
+ - lib/odf/container.rb
100
+ - CHANGELOG
101
+ - README.rdoc
102
+ - Rakefile
103
+ - LICENSE.LGPL
104
+ - spec/cell_spec.rb
105
+ - spec/spreadsheet_spec.rb
106
+ - spec/spec_helper.rb
107
+ - spec/row_spec.rb
108
+ - spec/table_spec.rb
109
+ - spec/style_spec.rb
110
+ - spec/property_spec.rb
111
+ - Manifest
112
+ - rodf.gemspec
113
+ has_rdoc: true
114
+ homepage: http://github.com/thiagoarrais/rodf/tree
115
+ post_install_message:
116
+ rdoc_options:
117
+ - --line-numbers
118
+ - --inline-source
119
+ - --title
120
+ - Rodf
121
+ - --main
122
+ - README.rdoc
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: "0"
130
+ version:
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: "1.2"
136
+ version:
137
+ requirements: []
138
+
139
+ rubyforge_project: rodf
140
+ rubygems_version: 1.2.0
141
+ signing_key:
142
+ specification_version: 2
143
+ summary: ODF generation library for Ruby
144
+ test_files: []
145
+