rodf 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/odf/cell.rb +11 -4
- data/rodf.gemspec +2 -2
- data/spec/cell_spec.rb +20 -0
- metadata +3 -3
data/lib/odf/cell.rb
CHANGED
@@ -46,7 +46,7 @@ module ODF
|
|
46
46
|
if contains_url?
|
47
47
|
p.text:a, @value, 'xlink:href' => @url
|
48
48
|
else
|
49
|
-
p
|
49
|
+
p.text! @value
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -64,9 +64,10 @@ module ODF
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def make_element_attributes(type, value, opts)
|
67
|
-
attrs = {
|
68
|
-
attrs['office:
|
69
|
-
attrs['office:value'] = value if :
|
67
|
+
attrs = {}
|
68
|
+
attrs['office:value-type'] = type if :string == type || !empty(value) || !opts[:formula].nil?
|
69
|
+
attrs['office:date-value'] = value if :date == type && !empty(value)
|
70
|
+
attrs['office:value'] = value if :float == type && !empty(value)
|
70
71
|
attrs['table:formula'] = opts[:formula] unless opts[:formula].nil?
|
71
72
|
attrs['table:style-name'] = opts[:style] unless opts[:style].nil?
|
72
73
|
attrs['table:number-columns-spanned'] = opts[:span] unless opts[:span].nil?
|
@@ -74,6 +75,12 @@ module ODF
|
|
74
75
|
attrs['table:number-matrix-rows-spanned'] = 1 if opts[:matrix_formula]
|
75
76
|
attrs
|
76
77
|
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def empty(value)
|
82
|
+
value.nil? || value.empty?
|
83
|
+
end
|
77
84
|
end
|
78
85
|
end
|
79
86
|
|
data/rodf.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rodf}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.8"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Thiago Arrais"]
|
9
|
-
s.date = %q{2010-04-
|
9
|
+
s.date = %q{2010-04-23}
|
10
10
|
s.description = %q{ODF generation library for Ruby}
|
11
11
|
s.email = %q{thiago.arrais@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE.LGPL", "README.rdoc", "lib/odf/cell.rb", "lib/odf/column.rb", "lib/odf/container.rb", "lib/odf/data_style.rb", "lib/odf/property.rb", "lib/odf/row.rb", "lib/odf/skeleton/manifest.xml", "lib/odf/skeleton/styles.xml", "lib/odf/spreadsheet.rb", "lib/odf/style_section.rb", "lib/odf/style.rb", "lib/odf/table.rb"]
|
data/spec/cell_spec.rb
CHANGED
@@ -124,4 +124,24 @@ describe ODF::Cell do
|
|
124
124
|
Hpricot(ODF::Cell.new(Date.parse('16 Apr 2010'), :type => :date).xml).
|
125
125
|
at('table:table-cell')['office:date-value'] = '2010-04-16'
|
126
126
|
end
|
127
|
+
|
128
|
+
it "should escape entities" do
|
129
|
+
output = ODF::Cell.new('Fish & Chips').xml
|
130
|
+
output.should have_tag('//table:table-cell/*')
|
131
|
+
output.should have_tag('//text:p')
|
132
|
+
Hpricot(output).at('text:p').innerHTML.should == 'Fish & Chips'
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should not render value type for non-string nil values" do
|
136
|
+
Hpricot(ODF::Cell.new(nil, :type => :string).xml).
|
137
|
+
at('table:table-cell').innerHTML.should == ''
|
138
|
+
|
139
|
+
[:float, :date].each do |t|
|
140
|
+
cell = Hpricot(ODF::Cell.new(nil, :type => t).xml).at('table:table-cell')
|
141
|
+
cell.innerHTML.should == ''
|
142
|
+
cell['office:value'].should be_nil
|
143
|
+
cell['office:date-value'].should be_nil
|
144
|
+
cell['office:value-type'].should be_nil
|
145
|
+
end
|
146
|
+
end
|
127
147
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 8
|
9
|
+
version: 0.1.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Thiago Arrais
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-23 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|