rodf 0.3.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +132 -62
- data/Rakefile +4 -19
- data/lib/{odf → rodf}/cell.rb +48 -27
- data/lib/{odf → rodf}/column.rb +1 -2
- data/lib/{odf → rodf}/compatibility.rb +0 -0
- data/lib/{odf → rodf}/container.rb +1 -4
- data/lib/{odf → rodf}/data_style.rb +3 -5
- data/lib/{odf → rodf}/document.rb +4 -6
- data/lib/{odf → rodf}/hyperlink.rb +2 -3
- data/lib/{odf → rodf}/master_page.rb +1 -2
- data/lib/{odf → rodf}/page_layout.rb +3 -4
- data/lib/{odf → rodf}/paragraph.rb +2 -3
- data/lib/{odf → rodf}/paragraph_container.rb +2 -3
- data/lib/{odf → rodf}/property.rb +9 -10
- data/lib/{odf → rodf}/row.rb +3 -4
- data/lib/{odf → rodf}/skeleton/manifest.xml.erb +0 -0
- data/lib/{odf → rodf}/skeleton/styles.pxml +0 -0
- data/lib/{odf → rodf}/skeleton.rb +1 -1
- data/lib/{odf → rodf}/span.rb +5 -4
- data/lib/{odf → rodf}/spreadsheet.rb +7 -12
- data/lib/{odf → rodf}/style.rb +4 -5
- data/lib/{odf → rodf}/style_section.rb +1 -3
- data/lib/{odf → rodf}/tab.rb +2 -3
- data/lib/{odf → rodf}/table.rb +4 -5
- data/lib/{odf → rodf}/text.rb +8 -10
- data/lib/rodf/version.rb +3 -0
- data/lib/rodf.rb +6 -0
- metadata +85 -108
- data/CHANGELOG +0 -17
- data/Gemfile +0 -9
- data/Manifest +0 -48
- data/rodf.gemspec +0 -48
- data/spec/cell_spec.rb +0 -189
- data/spec/data_style_spec.rb +0 -61
- data/spec/file_storage_spec.rb +0 -47
- data/spec/hyperlink_spec.rb +0 -62
- data/spec/master_page_spec.rb +0 -35
- data/spec/page_layout_spec.rb +0 -45
- data/spec/paragraph_spec.rb +0 -75
- data/spec/property_spec.rb +0 -270
- data/spec/row_spec.rb +0 -59
- data/spec/skeleton_spec.rb +0 -33
- data/spec/span_spec.rb +0 -65
- data/spec/spec_helper.rb +0 -23
- data/spec/spreadsheet_spec.rb +0 -123
- data/spec/style_section_spec.rb +0 -42
- data/spec/style_spec.rb +0 -109
- data/spec/tab_spec.rb +0 -34
- data/spec/table_spec.rb +0 -90
- data/spec/text_spec.rb +0 -79
data/spec/cell_spec.rb
DELETED
@@ -1,189 +0,0 @@
|
|
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 'date'
|
21
|
-
|
22
|
-
require 'odf/cell'
|
23
|
-
|
24
|
-
describe ODF::Cell do
|
25
|
-
it "should hold text content in a paragraph tag" do
|
26
|
-
output = ODF::Cell.new('Test').xml
|
27
|
-
output.should have_tag('//table:table-cell/*')
|
28
|
-
output.should have_tag('//text:p')
|
29
|
-
Hpricot(output).at('text:p').innerHTML.should == 'Test'
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should have string as default value type" do
|
33
|
-
[ODF::Cell.new('Test').xml, ODF::Cell.new(54).xml].each do |xml|
|
34
|
-
Hpricot(xml).at('table:table-cell')['office:value-type'].should=='string'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should allow value types to be specified" do
|
39
|
-
output = ODF::Cell.new(34.2, :type => :float).xml
|
40
|
-
Hpricot(output).at('table:table-cell')['office:value-type'].should=='float'
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should place strings in a paragraph tag and floats in value attribute" do
|
44
|
-
output = ODF::Cell.new('Test').xml
|
45
|
-
Hpricot(output).at('text:p').innerHTML.should == 'Test'
|
46
|
-
|
47
|
-
output = ODF::Cell.new(47, :type => :float).xml
|
48
|
-
output.should_not have_tag('//table:table-cell/*')
|
49
|
-
Hpricot(output).at('table:table-cell')['office:value'].should == '47'
|
50
|
-
|
51
|
-
output = ODF::Cell.new(34.2, :type => :string).xml
|
52
|
-
Hpricot(output).at('text:p').innerHTML.should == '34.2'
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should accept formulas" do
|
56
|
-
output = ODF::Cell.new(:type => :float,
|
57
|
-
:formula => "oooc:=SUM([.A1:.A4])").xml
|
58
|
-
|
59
|
-
elem = Hpricot(output).at('table:table-cell')
|
60
|
-
elem['office:value-type'].should == 'float'
|
61
|
-
elem['table:formula'].should == 'oooc:=SUM([.A1:.A4])'
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should accept matrix formulas" do
|
65
|
-
output = ODF::Cell.new(:type => :float, :matrix_formula => true,
|
66
|
-
:formula => "oooc:=SUM([.A1:.A4])").xml
|
67
|
-
|
68
|
-
elem = Hpricot(output).at('table:table-cell')
|
69
|
-
elem['table:number-matrix-columns-spanned'].should == '1'
|
70
|
-
elem['table:number-matrix-rows-spanned'].should == '1'
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should not make a matrix formula when asked not too" do
|
74
|
-
output = ODF::Cell.new(:type => :float, :matrix_formula => false,
|
75
|
-
:formula => "oooc:=SUM([.A1:.A4])").xml
|
76
|
-
|
77
|
-
elem = Hpricot(output).at('table:table-cell')
|
78
|
-
elem['table:number-matrix-columns-spanned'].should be_nil
|
79
|
-
elem['table:number-matrix-rows-spanned'].should be_nil
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should not have an empty paragraph" do
|
83
|
-
[ODF::Cell.new, ODF::Cell.new(''), ODF::Cell.new(' ')].each do |cell|
|
84
|
-
cell.xml.should_not have_tag('text:p')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should allow an style to be specified in the constructor" do
|
89
|
-
cell = ODF::Cell.new 45.8, :type => :float, :style => 'left-column-cell'
|
90
|
-
Hpricot(cell.xml).at('table:table-cell')['table:style-name'].
|
91
|
-
should == 'left-column-cell'
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should allow and style to be specified through a method call" do
|
95
|
-
cell = ODF::Cell.new 45.8, :type => :float
|
96
|
-
cell.style = 'left-column-cell'
|
97
|
-
Hpricot(cell.xml).at('table:table-cell')['table:style-name'].
|
98
|
-
should == 'left-column-cell'
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should span multiple cells when asked to" do
|
102
|
-
cell = ODF::Cell.new 'Spreadsheet title', :span => 4
|
103
|
-
doc = Hpricot(cell.xml)
|
104
|
-
doc.at('table:table-cell')['table:number-columns-spanned'].should == '4'
|
105
|
-
doc.search('table:table-cell').size.should == 4
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should have the URL set correctly when requested on a string" do
|
109
|
-
cell = ODF::Cell.new 'Example Link', :url => 'http://www.example.org'
|
110
|
-
doc = Hpricot(cell.xml)
|
111
|
-
doc.at('text:a')['xlink:href'].should == 'http://www.example.org'
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should ignore the URL requested on anything other than a string" do
|
115
|
-
cell = ODF::Cell.new(47.1, :type => :float, :url => 'http://www.example.org')
|
116
|
-
cell.xml.should_not have_tag('text:p')
|
117
|
-
cell.xml.should_not have_tag('text:a')
|
118
|
-
|
119
|
-
cell = ODF::Cell.new(Date.parse('15 Apr 2010'), :type => :date, :url => 'http://www.example.org')
|
120
|
-
cell.xml.should_not have_tag('text:p')
|
121
|
-
cell.xml.should_not have_tag('text:a')
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should have the date set correctly" do
|
125
|
-
cell = Hpricot(ODF::Cell.new(Date.parse('15 Apr 2010'), :type => :date).xml).
|
126
|
-
at('table:table-cell')
|
127
|
-
cell['office:value-type'].should == 'date'
|
128
|
-
cell['office:date-value'].should == '2010-04-15'
|
129
|
-
cell['office:value'].should be_nil
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should also accept strings as date values" do
|
133
|
-
Hpricot(ODF::Cell.new(Date.parse('16 Apr 2010'), :type => :date).xml).
|
134
|
-
at('table:table-cell')['office:date-value'] = '2010-04-16'
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should contain paragraph" do
|
138
|
-
c = ODF::Cell.new
|
139
|
-
c.paragraph "testing"
|
140
|
-
output = c.xml
|
141
|
-
|
142
|
-
output.should have_tag("//table:table-cell/*", :count => 1)
|
143
|
-
output.should have_tag("//text:p")
|
144
|
-
|
145
|
-
Hpricot(output).at('text:p').innerHTML.should == 'testing'
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should be able to hold multiple paragraphs" do
|
149
|
-
output = ODF::Cell.create do |c|
|
150
|
-
c.paragraph "first"
|
151
|
-
c.paragraph "second"
|
152
|
-
end
|
153
|
-
|
154
|
-
output.should have_tag("//table:table-cell/*", :count => 2)
|
155
|
-
output.should have_tag("//text:p")
|
156
|
-
|
157
|
-
ps = Hpricot(output).search('text:p')
|
158
|
-
ps[0].innerHTML.should == 'first'
|
159
|
-
ps[1].innerHTML.should == 'second'
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should not render value type for non-string nil values" do
|
163
|
-
Hpricot(ODF::Cell.new(nil, :type => :string).xml).
|
164
|
-
at('table:table-cell').innerHTML.should == ''
|
165
|
-
|
166
|
-
[:float, :date].each do |t|
|
167
|
-
cell = Hpricot(ODF::Cell.new(nil, :type => t).xml).at('table:table-cell')
|
168
|
-
cell.innerHTML.should == ''
|
169
|
-
cell['office:value'].should be_nil
|
170
|
-
cell['office:date-value'].should be_nil
|
171
|
-
cell['office:value-type'].should be_nil
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should accept parameterless blocks" do
|
176
|
-
output = ODF::Cell.create do
|
177
|
-
paragraph "first"
|
178
|
-
paragraph "second"
|
179
|
-
end
|
180
|
-
|
181
|
-
output.should have_tag("//table:table-cell/*", :count => 2)
|
182
|
-
output.should have_tag("//text:p")
|
183
|
-
|
184
|
-
ps = Hpricot(output).search('text:p')
|
185
|
-
ps[0].innerHTML.should == 'first'
|
186
|
-
ps[1].innerHTML.should == 'second'
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
data/spec/data_style_spec.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 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/data_style'
|
21
|
-
|
22
|
-
describe ODF::DataStyle do
|
23
|
-
it "should have sections" do
|
24
|
-
output = ODF::DataStyle.create 'year-to-day', :date do |s|
|
25
|
-
s.section :year, :style => 'long'
|
26
|
-
s.section :month, :style => 'long'
|
27
|
-
s.section :day
|
28
|
-
end
|
29
|
-
|
30
|
-
output.should have_tag('number:date-style')
|
31
|
-
output.should have_tag('number:year')
|
32
|
-
output.should have_tag('number:month')
|
33
|
-
output.should have_tag('number:day')
|
34
|
-
|
35
|
-
Hpricot(output).at('number:date-style')['style:name'].should == 'year-to-day'
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should allow short section names" do
|
39
|
-
output = ODF::DataStyle.create 'year-to-day', :date do |number|
|
40
|
-
number.year :style => 'long'
|
41
|
-
number.month :style => 'long'
|
42
|
-
number.day
|
43
|
-
end
|
44
|
-
|
45
|
-
output.should have_tag('number:year')
|
46
|
-
output.should have_tag('number:month')
|
47
|
-
output.should have_tag('number:day')
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should accept parameterless blocks" do
|
51
|
-
output = ODF::DataStyle.create 'year-to-day', :date do
|
52
|
-
section :year, :style => 'long'
|
53
|
-
section :month, :style => 'long'
|
54
|
-
section :day
|
55
|
-
end
|
56
|
-
|
57
|
-
output.should have_tag('number:date-style')
|
58
|
-
output.should have_tag('number:year')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
data/spec/file_storage_spec.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 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/text'
|
21
|
-
require "tempfile"
|
22
|
-
|
23
|
-
describe "file storage" do
|
24
|
-
|
25
|
-
before do
|
26
|
-
@default_internal = Encoding.default_internal
|
27
|
-
@tempfilename = Tempfile.new("text").path
|
28
|
-
end
|
29
|
-
|
30
|
-
after do
|
31
|
-
Encoding.default_internal = @default_internal
|
32
|
-
File.unlink @tempfilename if File.exist? @tempfilename
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should store files on disk" do
|
36
|
-
ODF::Text.file(@tempfilename) {}
|
37
|
-
|
38
|
-
File.exist?(@tempfilename).should be true
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should work with Encoding.default_internal" do
|
42
|
-
Encoding.default_internal = "UTF-8"
|
43
|
-
|
44
|
-
ODF::Text.file(@tempfilename) {}
|
45
|
-
File.exist?(@tempfilename).should be true
|
46
|
-
end
|
47
|
-
end
|
data/spec/hyperlink_spec.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 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/hyperlink'
|
21
|
-
|
22
|
-
describe ODF::Hyperlink do
|
23
|
-
it "should receive content text in first argument" do
|
24
|
-
output = ODF::Hyperlink.new('link somewhere', :href => 'http://www.example.org/').xml
|
25
|
-
output.should have_tag('//text:a')
|
26
|
-
|
27
|
-
link = Hpricot(output).at('text:a')
|
28
|
-
link.innerHTML.should == 'link somewhere'
|
29
|
-
link['xlink:href'].should == 'http://www.example.org/'
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should accept ref both in second argument as in argument hash" do
|
33
|
-
Hpricot(ODF::Hyperlink.new('link somewhere', :href => 'http://www.example.org/').xml).
|
34
|
-
at('text:a')['xlink:href'].should == 'http://www.example.org/'
|
35
|
-
|
36
|
-
Hpricot(ODF::Hyperlink.new('link somewhere', 'http://www.example.org/').xml).
|
37
|
-
at('text:a')['xlink:href'].should == 'http://www.example.org/'
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should allow nested span elements" do
|
41
|
-
output = ODF::Hyperlink.create 'http://www.example.com/' do |link|
|
42
|
-
link.strong 'important link'
|
43
|
-
end
|
44
|
-
|
45
|
-
output.should have_tag('//text:a/*', :count => 1)
|
46
|
-
tree = Hpricot(output)
|
47
|
-
tree.at('//text:a')['xlink:href'].should == 'http://www.example.com/'
|
48
|
-
span = tree.at('//text:span')
|
49
|
-
span['text:style-name'].should == 'strong'
|
50
|
-
span.innerHTML.should == 'important link'
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should accept parameterless blocks" do
|
54
|
-
output = ODF::Hyperlink.create 'http://www.example.com/' do
|
55
|
-
strong 'important link'
|
56
|
-
end
|
57
|
-
|
58
|
-
output.should have_tag('//text:a/*')
|
59
|
-
output.should have_tag('//text:span/*')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
data/spec/master_page_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 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/master_page'
|
21
|
-
|
22
|
-
describe ODF::MasterPage do
|
23
|
-
it "should have a name" do
|
24
|
-
output = ODF::MasterPage.new('my-master-page').xml
|
25
|
-
output.should have_tag('//style:master-page')
|
26
|
-
|
27
|
-
Hpricot(output).at('style:master-page')['style:name'].should == 'my-master-page'
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should accept a layout reference" do
|
31
|
-
Hpricot(ODF::MasterPage.new('my-master-page', :layout => 'A4').xml).
|
32
|
-
at('style:master-page')['style:page-layout-name'].should == 'A4'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
data/spec/page_layout_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 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/page_layout'
|
21
|
-
|
22
|
-
describe ODF::PageLayout do
|
23
|
-
it "should have a name" do
|
24
|
-
output = ODF::PageLayout.new('main-layout').xml
|
25
|
-
output.should have_tag('style:page-layout')
|
26
|
-
Hpricot(output).at('style:page-layout')['style:name'].should == 'main-layout'
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should have properties" do
|
30
|
-
output = ODF::PageLayout.create 'main-layout' do |l|
|
31
|
-
l.property 'page-layout'
|
32
|
-
end
|
33
|
-
output.should have_tag('//style:page-layout/*', :count => 1)
|
34
|
-
output.should have_tag('style:page-layout-properties')
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should accept parameterless blocks" do
|
38
|
-
output = ODF::PageLayout.create 'main-layout' do
|
39
|
-
property 'page-layout'
|
40
|
-
end
|
41
|
-
output.should have_tag('//style:page-layout/*', :count => 1)
|
42
|
-
output.should have_tag('style:page-layout-properties')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
data/spec/paragraph_spec.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 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/paragraph'
|
21
|
-
|
22
|
-
describe ODF::Paragraph do
|
23
|
-
it "should allow text content inside" do
|
24
|
-
output = ODF::Paragraph.new('Hello').xml
|
25
|
-
output.should have_tag('//text:p')
|
26
|
-
Hpricot(output).at('text:p').innerHTML.should == 'Hello'
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should accept an input sequence" do
|
30
|
-
output = ODF::Paragraph.create { |p|
|
31
|
-
p << "Hello, "
|
32
|
-
p << "world!"
|
33
|
-
}
|
34
|
-
output.should have_tag('//text:p')
|
35
|
-
Hpricot(output).at('text:p').innerHTML.should == 'Hello, world!'
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should accept styled spans" do
|
39
|
-
output = ODF::Paragraph.create { |p|
|
40
|
-
p << "Hello, "
|
41
|
-
p.span :bold, "world! "
|
42
|
-
p << "This is not bold. "
|
43
|
-
p.bold "But this is."
|
44
|
-
}
|
45
|
-
spans = Hpricot(output).at('text:p').search('text:span')
|
46
|
-
spans.first.innerHTML.should == 'world! '
|
47
|
-
spans.first['text:style-name'].should == 'bold'
|
48
|
-
spans.last.innerHTML.should == 'But this is.'
|
49
|
-
spans.last['text:style-name'].should == 'bold'
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should be able to hold hyperlinks" do
|
53
|
-
output = ODF::Paragraph.create {|p|
|
54
|
-
p << "please visit "
|
55
|
-
p.a "example.org", :href => "http://www.example.org/"
|
56
|
-
p << " for more details"
|
57
|
-
}
|
58
|
-
output.should have_tag("//text:p/*", :count => 3)
|
59
|
-
output.should have_tag("//text:a")
|
60
|
-
|
61
|
-
Hpricot(output).at('text:a').innerHTML.should == 'example.org'
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should support style attribute" do
|
65
|
-
Hpricot(ODF::Paragraph.create('styled paragraph', :style => 'highlight')).
|
66
|
-
at('text:p')['text:style-name'].should == 'highlight'
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should accept attributes in the first parameter too" do
|
70
|
-
para = Hpricot(ODF::Paragraph.create(:style => 'testing')).at('text:p')
|
71
|
-
para.innerHTML.should be_empty
|
72
|
-
para['text:style-name'].should == 'testing'
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|