odf-report 0.3.0 → 0.3.1
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-report/hash_gsub.rb +8 -1
- data/lib/odf-report/section.rb +0 -13
- data/lib/odf-report/table.rb +0 -13
- data/odf-report.gemspec +2 -2
- data/test/test.rb +1 -0
- metadata +3 -3
data/lib/odf-report/hash_gsub.rb
CHANGED
@@ -4,7 +4,9 @@ module ODFReport
|
|
4
4
|
|
5
5
|
def hash_gsub!(_text, hash_of_values)
|
6
6
|
hash_of_values.each do |key, val|
|
7
|
-
|
7
|
+
txt = html_escape(val)
|
8
|
+
txt = odf_linebreak(txt)
|
9
|
+
_text.gsub!("[#{key.to_s.upcase}]", txt)
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
@@ -15,6 +17,11 @@ module ODFReport
|
|
15
17
|
s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
|
16
18
|
end
|
17
19
|
|
20
|
+
def odf_linebreak(s)
|
21
|
+
return "" unless s
|
22
|
+
s.to_s.gsub("\n", "<text:line-break/>")
|
23
|
+
end
|
24
|
+
|
18
25
|
end
|
19
26
|
|
20
27
|
end
|
data/lib/odf-report/section.rb
CHANGED
@@ -108,19 +108,6 @@ private
|
|
108
108
|
return collection
|
109
109
|
end
|
110
110
|
|
111
|
-
def hash_gsub!(_text, hash_of_values)
|
112
|
-
hash_of_values.each do |key, val|
|
113
|
-
_text.gsub!("[#{key.to_s.upcase}]", html_escape(val))
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
HTML_ESCAPE = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' }
|
118
|
-
|
119
|
-
def html_escape(s)
|
120
|
-
return "" unless s
|
121
|
-
s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
|
122
|
-
end
|
123
|
-
|
124
111
|
end
|
125
112
|
|
126
113
|
end
|
data/lib/odf-report/table.rb
CHANGED
@@ -126,19 +126,6 @@ private
|
|
126
126
|
return ret[0]
|
127
127
|
end
|
128
128
|
|
129
|
-
def hash_gsub!(_text, hash_of_values)
|
130
|
-
hash_of_values.each do |key, val|
|
131
|
-
_text.gsub!("[#{key.to_s.upcase}]", html_escape(val))
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
HTML_ESCAPE = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' }
|
136
|
-
|
137
|
-
def html_escape(s)
|
138
|
-
return "" unless s
|
139
|
-
s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
|
140
|
-
end
|
141
|
-
|
142
129
|
end
|
143
130
|
|
144
131
|
end
|
data/odf-report.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{odf-report}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Sandro Duarte"]
|
9
|
-
s.date = %q{2010-05-
|
9
|
+
s.date = %q{2010-05-31}
|
10
10
|
s.description = %q{Generates ODF files, given a template (.odt) and data, replacing tags}
|
11
11
|
s.email = %q{sandrods@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["lib/odf-report.rb", "README.textile"]
|
data/test/test.rb
CHANGED
@@ -11,6 +11,7 @@ col2 = []
|
|
11
11
|
col2 << OpenStruct.new({:name=>"josh harnet", :id=>"02", :address=>"testing <&> ", :phone=>99025668, :zip=>"90420-002"})
|
12
12
|
col2 << OpenStruct.new({:name=>"sandro duarte", :id=>"45", :address=>"address with &", :phone=>88774451, :zip=>"90490-002"})
|
13
13
|
col2 << OpenStruct.new({:name=>"ellen bicca", :id=>"77", :address=>"<address with escaped html>", :phone=>77025668, :zip=>"94420-002"})
|
14
|
+
col2 << OpenStruct.new({:name=>"luiz garcia", :id=>"88", :address=>"address with\nlinebreak", :phone=>27025668, :zip=>"94520-025"})
|
14
15
|
|
15
16
|
report = ODFReport::Report.new("test.odt") do |r|
|
16
17
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 1
|
9
|
+
version: 0.3.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sandro Duarte
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-31 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|