documatic 0.0.1 → 0.0.2
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/README +36 -8
- data/lib/documatic/component.rb +2 -2
- data/lib/documatic/formatter/open_document.rb +27 -0
- data/lib/documatic/init.rb +4 -0
- data/lib/documatic/open_document_text/helper.rb +55 -0
- data/lib/documatic/{partial.rb → open_document_text/partial.rb} +14 -14
- data/lib/documatic/{template.rb → open_document_text/template.rb} +37 -39
- data/lib/documatic.rb +25 -3
- metadata +37 -13
- data/lib/documatic/helper.rb +0 -53
data/README
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
= Documatic
|
2
2
|
|
3
|
-
Documatic is an OpenDocument
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
Documatic is an OpenDocument extension for Ruby Reports (Ruport). It
|
4
|
+
is a template-driven formatter that can be used to produce attractive
|
5
|
+
printable documents such as database reports, invoices, letters, faxes
|
6
|
+
and more.
|
7
7
|
|
8
8
|
|
9
9
|
== Installation
|
@@ -13,6 +13,22 @@ Documatic can be installed via Rubygems.
|
|
13
13
|
% gem install documatic
|
14
14
|
|
15
15
|
|
16
|
+
== Usage
|
17
|
+
|
18
|
+
Documatic is a Ruport extension, so it is loaded like this:
|
19
|
+
|
20
|
+
require 'rubygems'
|
21
|
+
require 'ruport'
|
22
|
+
require 'ruport/extensions'
|
23
|
+
|
24
|
+
Documatic will then be available as a formatter for your Ruport tables, groups and groupings:
|
25
|
+
|
26
|
+
data.to_odt_template(:template => 'path/filename.odt',
|
27
|
+
:output => 'output-path/filename.odt')
|
28
|
+
|
29
|
+
The wiki has more documentation and examples, plus a simple tutorial.
|
30
|
+
|
31
|
+
|
16
32
|
== Licence
|
17
33
|
|
18
34
|
Documatic is (p) Public Domain 2007, no rights reserved.
|
@@ -22,8 +38,20 @@ Documatic comes with no warranty whatsoever.
|
|
22
38
|
|
23
39
|
== Support
|
24
40
|
|
25
|
-
|
26
|
-
http://documatic.
|
41
|
+
See the Documatic Trac page at
|
42
|
+
http://stonecode.svnrepository.com/documatic/trac.cgi. The wiki is
|
43
|
+
the main source of information for end-users. The tracking system is
|
44
|
+
where bug reports should be filed.
|
45
|
+
|
46
|
+
Users can discuss Documatic on the Ruby Reports mailing list at
|
47
|
+
http://groups.google.com/group/ruby-reports.
|
48
|
+
|
49
|
+
The Subversion repository for Documatic is at
|
50
|
+
http://stonecode.svnrepository.com/svn/documatic.
|
51
|
+
|
52
|
+
The Rubyforge project page for Documatic is at
|
53
|
+
http://rubyforge.org/projects/documatic. The Documatic rubygem is
|
54
|
+
distributed from here.
|
27
55
|
|
28
|
-
|
29
|
-
|
56
|
+
For any other enquiries please contact Dave Nelson (urbanus at 240gl
|
57
|
+
dot org).
|
data/lib/documatic/component.rb
CHANGED
@@ -3,7 +3,7 @@ require 'erb'
|
|
3
3
|
module Documatic
|
4
4
|
class Component
|
5
5
|
include ERB::Util
|
6
|
-
include Documatic::Helper
|
6
|
+
include Documatic::OpenDocumentText::Helper
|
7
7
|
|
8
8
|
attr_accessor :erb
|
9
9
|
|
@@ -46,7 +46,7 @@ module Documatic
|
|
46
46
|
# intended to be called directly by client applications: it is
|
47
47
|
# called automatically by Documatic::Template after processing.
|
48
48
|
def merge_partial_styles
|
49
|
-
cache = Documatic::Partial.cache_by_prefix
|
49
|
+
cache = Documatic::OpenDocumentText::Partial.cache_by_prefix
|
50
50
|
if cache.length > 0
|
51
51
|
styles = self.xml.root.elements['office:automatic-styles']
|
52
52
|
if styles
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'ruport'
|
3
|
+
|
4
|
+
module Documatic::Formatter
|
5
|
+
|
6
|
+
class OpenDocumentText < Ruport::Formatter
|
7
|
+
PROCESSOR = Documatic::OpenDocumentText::Template
|
8
|
+
renders :odt_template, :for => [ Ruport::Renderer::Table, Ruport::Renderer::Group,
|
9
|
+
Ruport::Renderer::Grouping ]
|
10
|
+
|
11
|
+
def build
|
12
|
+
PROCESSOR.process_template(:data => data, :options => options)
|
13
|
+
end
|
14
|
+
alias_method :build_table_body, :build # for Ruport::Renderer::Table
|
15
|
+
alias_method :build_group_body, :build # for Ruport::Renderer::Group
|
16
|
+
alias_method :build_grouping_body, :build # for Ruport::Renderer::Grouping
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
# Coming soon
|
21
|
+
# class OpenDocumentSpreadsheet < OpenDocumentText
|
22
|
+
# PROCESSOR = Documatic::OpenDocumentSpreadsheet::Template
|
23
|
+
# renders :ods_template, :for => [ Ruport::Renderer::Table, Ruport::Renderer::Group,
|
24
|
+
# Ruport::Renderer::Grouping ]
|
25
|
+
# end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Documatic
|
4
|
+
module OpenDocumentText
|
5
|
+
module Helper
|
6
|
+
|
7
|
+
include ERB::Util
|
8
|
+
|
9
|
+
|
10
|
+
# Inserts a paragraph (<text:p>) containing the provided content;
|
11
|
+
# or nothing if no content is provided. This helper should be
|
12
|
+
# invoked from within "Ruby Block" because paragraphs are
|
13
|
+
# block-level elements.
|
14
|
+
#
|
15
|
+
# Note that the content is not escaped by default because you
|
16
|
+
# might want to include other tags in the content. You should use
|
17
|
+
# ERB::Util.h() to escape any content that could possibly contain
|
18
|
+
# XML characters.
|
19
|
+
def para(stylename, content = nil)
|
20
|
+
end_element = ( content ? ">#{content}</text:p>" : "/>" )
|
21
|
+
%Q(<text:p text:style-name="#{stylename}"#{end_element})
|
22
|
+
end
|
23
|
+
|
24
|
+
# Inserts a text span (<text:span>) containing the provided
|
25
|
+
# content. This helper should be invoked from within "Ruby
|
26
|
+
# Literal" because the tag is a text-level element that shouldn't
|
27
|
+
# be escaped. However the content is escaped.
|
28
|
+
def span(stylename, content)
|
29
|
+
%Q(<text:span text:style-name="#{stylename}">#{ERB::Util.h(content)}</text:span>)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
# Inserts a partial into the document at the chosen position.
|
34
|
+
# This helper should be invoked from within "Ruby Block" because
|
35
|
+
# it inserts unescaped block-level material in the current
|
36
|
+
# template.
|
37
|
+
#
|
38
|
+
# The +assigns+ hash is passed through to the partial for binding.
|
39
|
+
#
|
40
|
+
# This method will add the provided partial to the
|
41
|
+
# Documatic::Partial cache if it hasn't yet been loaded; or if it
|
42
|
+
# has been loaded then the existing partial will be re-used.
|
43
|
+
def partial(filename, *assigns)
|
44
|
+
if Documatic::OpenDocumentText::Partial.cache.has_key?(filename)
|
45
|
+
p = Documatic::OpenDocumentText::Partial.cache[filename]
|
46
|
+
else
|
47
|
+
p = Documatic::OpenDocumentText::Partial.new(filename)
|
48
|
+
Documatic::OpenDocumentText::Partial.add_partial(filename, p)
|
49
|
+
end
|
50
|
+
p.process(*assigns)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rexml/document'
|
2
2
|
|
3
|
-
module Documatic
|
4
|
-
class Partial <
|
3
|
+
module Documatic::OpenDocumentText
|
4
|
+
class Partial < Template
|
5
5
|
|
6
6
|
attr_accessor :content
|
7
7
|
attr_accessor :filename
|
@@ -35,13 +35,13 @@ module Documatic
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def process(local_assigns = {})
|
38
|
-
self.
|
38
|
+
self.jar.find_entry('documatic/partial') || self.compile
|
39
39
|
@content = Documatic::Component.new( self.content_erb )
|
40
40
|
@content.process(local_assigns)
|
41
41
|
end
|
42
42
|
|
43
43
|
def compile
|
44
|
-
doc = REXML::Document.new( self.
|
44
|
+
doc = REXML::Document.new( self.jar.read('content.xml') )
|
45
45
|
style_names = Hash.new
|
46
46
|
|
47
47
|
# Gather all auto style names from <office:automatic-styles>
|
@@ -60,16 +60,16 @@ module Documatic
|
|
60
60
|
end
|
61
61
|
|
62
62
|
# Create 'documatic/partial/' in zip file
|
63
|
-
self.
|
63
|
+
self.jar.find_entry('documatic/partial') || self.jar.mkdir('documatic/partial')
|
64
64
|
|
65
65
|
# Save the prefix in documatic/partial.txt
|
66
|
-
self.
|
66
|
+
self.jar.get_output_stream('documatic/partial/partial.txt') do |f|
|
67
67
|
f.write self.prefix
|
68
68
|
end
|
69
69
|
|
70
70
|
# Set @styles, & save it in documatic/styles.xml
|
71
71
|
@styles = doc.root.elements['office:automatic-styles']
|
72
|
-
self.
|
72
|
+
self.jar.get_output_stream('documatic/partial/styles.xml') do |f|
|
73
73
|
f.write @styles.to_s
|
74
74
|
end
|
75
75
|
|
@@ -78,7 +78,7 @@ module Documatic
|
|
78
78
|
body_text.elements.delete('text:sequence-decls')
|
79
79
|
body_text.elements.delete('office:forms')
|
80
80
|
@content_erb = self.erbify( (body_text.elements.to_a.collect do |e| e.to_s ; end ).join )
|
81
|
-
self.
|
81
|
+
self.jar.get_output_stream('documatic/partial/content.erb') do |f|
|
82
82
|
f.write @content_erb
|
83
83
|
end
|
84
84
|
|
@@ -89,8 +89,8 @@ module Documatic
|
|
89
89
|
|
90
90
|
def prefix
|
91
91
|
if not @prefix
|
92
|
-
if self.
|
93
|
-
@prefix = self.
|
92
|
+
if self.jar.find_entry('documatic/partial/partial.txt')
|
93
|
+
@prefix = self.jar.read('documatic/partial/partial.txt')
|
94
94
|
else
|
95
95
|
@prefix = File.basename(self.filename, '.odt').gsub(/[^A-Za-z0-9_]/, '_')
|
96
96
|
end
|
@@ -100,8 +100,8 @@ module Documatic
|
|
100
100
|
|
101
101
|
def content_erb
|
102
102
|
if not @content_erb
|
103
|
-
if self.
|
104
|
-
self.
|
103
|
+
if self.jar.find_entry('documatic/partial/content.erb')
|
104
|
+
self.jar.read('documatic/partial/content.erb')
|
105
105
|
else
|
106
106
|
self.compile
|
107
107
|
end
|
@@ -111,8 +111,8 @@ module Documatic
|
|
111
111
|
|
112
112
|
def styles
|
113
113
|
if not @styles
|
114
|
-
if self.
|
115
|
-
@styles = REXML::Document.new( self.
|
114
|
+
if self.jar.find_entry('documatic/partial/styles.xml')
|
115
|
+
@styles = REXML::Document.new( self.jar.read('documatic/partial/styles.xml') ).root
|
116
116
|
else
|
117
117
|
self.compile
|
118
118
|
end
|
@@ -2,14 +2,15 @@ require 'rexml/text'
|
|
2
2
|
require 'rexml/attribute'
|
3
3
|
require 'zip/zip'
|
4
4
|
require 'erb'
|
5
|
+
require 'fileutils'
|
5
6
|
|
6
|
-
module Documatic
|
7
|
+
module Documatic::OpenDocumentText
|
7
8
|
class Template
|
8
9
|
include ERB::Util
|
9
10
|
|
10
11
|
attr_accessor :content
|
11
12
|
attr_accessor :styles
|
12
|
-
attr_accessor :
|
13
|
+
attr_accessor :jar
|
13
14
|
# The raw contents of 'content.xml'.
|
14
15
|
attr_accessor :content_raw
|
15
16
|
# Compiled text, to be written to 'content.erb'
|
@@ -57,7 +58,7 @@ module Documatic
|
|
57
58
|
require 'action_view/helpers/number_helper'
|
58
59
|
require 'action_view/helpers/text_helper'
|
59
60
|
|
60
|
-
[self, Documatic::Partial].each do |klass|
|
61
|
+
[self, Documatic::OpenDocumentText::Partial].each do |klass|
|
61
62
|
klass.class_eval do
|
62
63
|
include ActionView::Helpers::NumberHelper
|
63
64
|
include ActionView::Helpers::TextHelper
|
@@ -65,23 +66,41 @@ module Documatic
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
69
|
+
def process_template(args, &block)
|
70
|
+
if args[:options] && args[:options].template && args[:options].output
|
71
|
+
output_dir = File.dirname(args[:options].output)
|
72
|
+
File.directory?(output_dir) || FileUtils.mkdir_p(output_dir)
|
73
|
+
FileUtils.cp(args[:options].template, args[:options].output)
|
74
|
+
template = self.new(args[:options].output)
|
75
|
+
template.process :data => args[:data], :options => args[:options]
|
76
|
+
template.save
|
77
|
+
if block
|
78
|
+
block.call(template)
|
79
|
+
template.save
|
80
|
+
end
|
81
|
+
template.close
|
82
|
+
else
|
83
|
+
raise ArgumentError, 'Need to specify both :template and :output in options'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
68
87
|
end # class << self
|
69
88
|
|
70
89
|
def initialize(filename)
|
71
90
|
@filename = filename
|
72
|
-
@
|
91
|
+
@jar = Zip::ZipFile.open(@filename)
|
73
92
|
return true
|
74
93
|
end
|
75
94
|
|
76
95
|
def process(local_assigns = {})
|
77
96
|
# Compile this template, if not compiled already.
|
78
|
-
self.
|
97
|
+
self.jar.find_entry('documatic/master') || self.compile
|
79
98
|
# Process the styles (incl. headers and footers).
|
80
99
|
# This is conditional because partials don't need styles.erb.
|
81
|
-
@styles = Documatic::Component.new( self.
|
100
|
+
@styles = Documatic::Component.new( self.jar.read('documatic/master/styles.erb') )
|
82
101
|
@styles.process(local_assigns)
|
83
102
|
# Process the main (body) content.
|
84
|
-
@content = Documatic::Component.new( self.
|
103
|
+
@content = Documatic::Component.new( self.jar.read('documatic/master/content.erb') )
|
85
104
|
@content.process(local_assigns)
|
86
105
|
@content.merge_partial_styles
|
87
106
|
end
|
@@ -89,36 +108,36 @@ module Documatic
|
|
89
108
|
def save
|
90
109
|
# Gather all the styles from the partials, add them to the master's styles.
|
91
110
|
# Put the body into the document.
|
92
|
-
self.
|
111
|
+
self.jar.get_output_stream('content.xml') do |f|
|
93
112
|
f.write self.content.to_s
|
94
113
|
end
|
95
114
|
|
96
115
|
if self.styles
|
97
|
-
self.
|
116
|
+
self.jar.get_output_stream('styles.xml') do |f|
|
98
117
|
f.write self.styles.to_s
|
99
118
|
end
|
100
119
|
end
|
101
120
|
end
|
102
121
|
|
103
122
|
def close
|
104
|
-
self.
|
123
|
+
self.jar.close
|
105
124
|
end
|
106
125
|
|
107
126
|
def compile
|
108
127
|
# Read the raw files
|
109
|
-
@content_raw = self.
|
110
|
-
@styles_raw = self.
|
128
|
+
@content_raw = self.jar.read('content.xml')
|
129
|
+
@styles_raw = self.jar.read('styles.xml')
|
111
130
|
|
112
131
|
@content_erb = self.erbify(@content_raw)
|
113
132
|
@styles_erb = self.erbify(@styles_raw)
|
114
133
|
|
115
134
|
# Create 'documatic/master/' in zip file
|
116
|
-
self.
|
135
|
+
self.jar.find_entry('documatic/master') || self.jar.mkdir('documatic/master')
|
117
136
|
|
118
|
-
self.
|
137
|
+
self.jar.get_output_stream('documatic/master/content.erb') do |f|
|
119
138
|
f.write @content_erb
|
120
139
|
end
|
121
|
-
self.
|
140
|
+
self.jar.get_output_stream('documatic/master/styles.erb') do |f|
|
122
141
|
f.write @styles_erb
|
123
142
|
end
|
124
143
|
end
|
@@ -134,7 +153,7 @@ module Documatic
|
|
134
153
|
end
|
135
154
|
|
136
155
|
# Massage OpenDocument XML into ERb. (This is the heart of the compiler.)
|
137
|
-
def erbify(code
|
156
|
+
def erbify(code)
|
138
157
|
# First gather all the ERb-related derived styles
|
139
158
|
remaining = code
|
140
159
|
styles = {'Ruby_20_Code' => 'Code', 'Ruby_20_Value' => 'Value',
|
@@ -170,7 +189,7 @@ module Documatic
|
|
170
189
|
# 11. ROW_END End table row (incl. covered rows) ?
|
171
190
|
#
|
172
191
|
# "?": optional, might not occur every time
|
173
|
-
re_erb = /(<table:table-row
|
192
|
+
re_erb = /(<table:table-row[^>]*><table:table-cell [^>]+>)?(<text:list-item>)?(<text:p [^>]+>)?(<\/text:span>)?<text:span text:style-name="(#{styles.keys.join '|'})">(([^<]*|<text:line-break\/>|<text:tab\/>)+)<\/text:span>(<text:span [^>]+>)?(<\/text:p>)?(<\/text:list-item>)?(<\/table:table-cell>(<table:covered-table-cell\/>)*<\/table:table-row>)?/
|
174
193
|
|
175
194
|
# Then search for all text using those styles
|
176
195
|
while remaining.length > 0
|
@@ -179,13 +198,6 @@ module Documatic
|
|
179
198
|
|
180
199
|
if md
|
181
200
|
|
182
|
-
### TESTING ONLY
|
183
|
-
# puts "#{md[ERB_CODE]}:"
|
184
|
-
# for i in 1 ... md.size do
|
185
|
-
# puts "\t#{i}: #{md[i]}"
|
186
|
-
# end
|
187
|
-
# puts ""
|
188
|
-
|
189
201
|
result += md.pre_match
|
190
202
|
|
191
203
|
match_code = false
|
@@ -212,7 +224,7 @@ module Documatic
|
|
212
224
|
match_para = true
|
213
225
|
end
|
214
226
|
else # style is Value or Literal
|
215
|
-
if
|
227
|
+
if styles[md[TYPE]] == 'Literal'
|
216
228
|
delim_start = '<%= ' ; delim_end = ' %>'
|
217
229
|
else
|
218
230
|
delim_start = '<%= ERB::Util.h(' ; delim_end = ') %>'
|
@@ -245,9 +257,6 @@ module Documatic
|
|
245
257
|
result += md[SPAN_START]
|
246
258
|
end
|
247
259
|
end
|
248
|
-
# if md[SPAN_START] and not match_span
|
249
|
-
# result += md[SPAN_START]
|
250
|
-
# end
|
251
260
|
|
252
261
|
result += "#{delim_start}#{self.unnormalize md[ERB_CODE]}#{delim_end}"
|
253
262
|
|
@@ -265,10 +274,6 @@ module Documatic
|
|
265
274
|
end
|
266
275
|
end
|
267
276
|
|
268
|
-
# if md[SPAN_END] and not match_span
|
269
|
-
# result += md[SPAN_END]
|
270
|
-
# end
|
271
|
-
|
272
277
|
if md[PARA_END] and not match_para
|
273
278
|
result += md[PARA_END]
|
274
279
|
end
|
@@ -294,10 +299,3 @@ module Documatic
|
|
294
299
|
|
295
300
|
end
|
296
301
|
end
|
297
|
-
|
298
|
-
# Force REXML to use double-quotes (consistent with OOo).
|
299
|
-
REXML::Attribute.class_eval do
|
300
|
-
def to_string
|
301
|
-
%Q[#@expanded_name="#{to_s().gsub(/"/, '"')}"]
|
302
|
-
end
|
303
|
-
end
|
data/lib/documatic.rb
CHANGED
@@ -1,7 +1,29 @@
|
|
1
|
-
require 'documatic/helper'
|
2
|
-
require 'documatic/template'
|
1
|
+
require 'documatic/open_document_text/helper'
|
2
|
+
require 'documatic/open_document_text/template'
|
3
3
|
require 'documatic/component'
|
4
|
-
require 'documatic/partial'
|
4
|
+
require 'documatic/open_document_text/partial'
|
5
5
|
|
6
|
+
|
7
|
+
# The module "Documatic" is the namespace for the other modules and
|
8
|
+
# classes in this project. It also contains some convenience methods.
|
6
9
|
module Documatic
|
10
|
+
class << self
|
11
|
+
|
12
|
+
# Short-cut method for including a helper in
|
13
|
+
# OpenDocumentText::Template.
|
14
|
+
def text_helper(helper_module)
|
15
|
+
Documatic::Component.class_eval do
|
16
|
+
include helper_module
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end # class << self
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# Force REXML to use double-quotes (consistent with OOo).
|
25
|
+
REXML::Attribute.class_eval do
|
26
|
+
def to_string
|
27
|
+
%Q[#@expanded_name="#{to_s().gsub(/"/, '"')}"]
|
28
|
+
end
|
7
29
|
end
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: documatic
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-
|
8
|
-
summary: Documatic is
|
6
|
+
version: 0.0.2
|
7
|
+
date: 2007-06-15 00:00:00 +10:00
|
8
|
+
summary: Documatic is an OpenDocument extension for Ruby Reports (Ruport). It is a template-driven formatter that can be used to produce attractive printable documents such as database reports, invoices, letters, faxes and more.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: urbanus@240gl.org
|
12
|
-
homepage: http://documatic.
|
12
|
+
homepage: http://stonecode.svnrepository.com/documatic/trac.cgi
|
13
13
|
rubyforge_project: documatic
|
14
14
|
description:
|
15
|
-
autorequire:
|
15
|
+
autorequire: init.rb
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
18
18
|
has_rdoc: true
|
@@ -32,18 +32,24 @@ files:
|
|
32
32
|
- lib
|
33
33
|
- lib/documatic
|
34
34
|
- lib/documatic.rb
|
35
|
-
- lib/documatic/template.rb
|
36
35
|
- lib/documatic/component.rb
|
37
|
-
- lib/documatic/
|
38
|
-
- lib/documatic/
|
36
|
+
- lib/documatic/open_document_text
|
37
|
+
- lib/documatic/open_document_text/helper.rb
|
38
|
+
- lib/documatic/open_document_text/partial.rb
|
39
|
+
- lib/documatic/open_document_text/template.rb
|
40
|
+
- lib/documatic/formatter
|
41
|
+
- lib/documatic/formatter/open_document.rb
|
42
|
+
- lib/documatic/init.rb
|
39
43
|
- tests
|
40
44
|
- README
|
41
45
|
test_files: []
|
42
46
|
|
43
|
-
rdoc_options:
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
rdoc_options:
|
48
|
+
- --main
|
49
|
+
- README
|
50
|
+
- --inline-source
|
51
|
+
extra_rdoc_files:
|
52
|
+
- README
|
47
53
|
executables: []
|
48
54
|
|
49
55
|
extensions: []
|
@@ -60,3 +66,21 @@ dependencies:
|
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: 0.9.1
|
62
68
|
version:
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: gem_plugin
|
71
|
+
version_requirement:
|
72
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0.1"
|
77
|
+
version:
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: ruport
|
80
|
+
version_requirement:
|
81
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.0.0
|
86
|
+
version:
|
data/lib/documatic/helper.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
module Documatic
|
4
|
-
module Helper
|
5
|
-
|
6
|
-
include ERB::Util
|
7
|
-
|
8
|
-
|
9
|
-
# Inserts a paragraph (<text:p>) containing the provided content;
|
10
|
-
# or nothing if no content is provided. This helper should be
|
11
|
-
# invoked from within "Ruby Block" because paragraphs are
|
12
|
-
# block-level elements.
|
13
|
-
#
|
14
|
-
# Note that the content is not escaped by default because you
|
15
|
-
# might want to include other tags in the content. You should use
|
16
|
-
# ERB::Util.h() to escape any content that could possibly contain
|
17
|
-
# XML characters.
|
18
|
-
def para(stylename, content = nil)
|
19
|
-
end_element = ( content ? ">#{content}</text:p>" : "/>" )
|
20
|
-
%Q(<text:p text:style-name="#{stylename}"#{end_element})
|
21
|
-
end
|
22
|
-
|
23
|
-
# Inserts a text span (<text:span>) containing the provided
|
24
|
-
# content. This helper should be invoked from within "Ruby
|
25
|
-
# Literal" because the tag is a text-level element that shouldn't
|
26
|
-
# be escaped. However the content is escaped.
|
27
|
-
def span(stylename, content)
|
28
|
-
%Q(<text:span text:style-name="#{stylename}">#{ERB::Util.h(content)}</text:span>)
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
# Inserts a partial into the document at the chosen position.
|
33
|
-
# This helper should be invoked from within "Ruby Block" because
|
34
|
-
# it inserts unescaped block-level material in the current
|
35
|
-
# template.
|
36
|
-
#
|
37
|
-
# The +assigns+ hash is passed through to the partial for binding.
|
38
|
-
#
|
39
|
-
# This method will add the provided partial to the
|
40
|
-
# Documatic::Partial cache if it hasn't yet been loaded; or if it
|
41
|
-
# has been loaded then the existing partial will be re-used.
|
42
|
-
def partial(filename, *assigns)
|
43
|
-
if Documatic::Partial.cache.has_key?(filename)
|
44
|
-
p = Documatic::Partial.cache[filename]
|
45
|
-
else
|
46
|
-
p = Documatic::Partial.new(filename)
|
47
|
-
Documatic::Partial.add_partial(filename, p)
|
48
|
-
end
|
49
|
-
p.process(*assigns)
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|