deplate 0.7.3 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.TXT +3 -0
- data/CHANGES.TXT +248 -175
- data/LICENSE.TXT +0 -0
- data/NEWS.TXT +28 -24
- data/README.TXT +0 -0
- data/TODO.TXT +174 -88
- data/VERSION.TXT +1 -1
- data/bin/deplate +0 -0
- data/bin/deplate.bat +0 -0
- data/etc/deplate.ini +91 -3
- data/lib/action_view/helpers/deplate.rb +45 -0
- data/lib/deplate.rb +6 -1
- data/lib/deplate/abstract-class.rb +0 -0
- data/lib/deplate/bib.rb +576 -0
- data/lib/deplate/builtin.rb +0 -0
- data/lib/deplate/cache.rb +55 -5
- data/lib/deplate/commands.rb +346 -183
- data/lib/deplate/common.rb +209 -48
- data/lib/deplate/converter.rb +12 -6
- data/lib/deplate/core.rb +777 -378
- data/lib/deplate/counters.rb +254 -0
- data/lib/deplate/css/article.css +4 -3
- data/lib/deplate/css/deplate.css +121 -5
- data/lib/deplate/css/heading-navbar.css +0 -0
- data/lib/deplate/css/layout-deplate-print.css +0 -0
- data/lib/deplate/css/layout-deplate.css +0 -0
- data/lib/deplate/css/sans-serif.css +0 -0
- data/lib/deplate/css/serif-e.css +0 -0
- data/lib/deplate/css/serif-rel.css +0 -0
- data/lib/deplate/css/serif.css +9 -3
- data/lib/deplate/css/slides.css +0 -0
- data/lib/deplate/css/tabbar-left.css +0 -0
- data/lib/deplate/css/tabbar-right-ie.css +3 -9
- data/lib/deplate/css/tabbar-right.css +51 -18
- data/lib/deplate/css/tabbar-top.css +7 -1
- data/lib/deplate/css/tabbar.css +0 -0
- data/lib/deplate/css/text-sans-serif.css +0 -0
- data/lib/deplate/css/text-serif.css +0 -0
- data/lib/deplate/define.rb +183 -177
- data/lib/deplate/deplate-string.rb +82 -0
- data/lib/deplate/docbook.rb +236 -128
- data/lib/deplate/elements.rb +584 -417
- data/lib/deplate/etc.rb +163 -101
- data/lib/deplate/external.rb +42 -11
- data/lib/deplate/fmt/dbk-article-4.1.2.rb +0 -0
- data/lib/deplate/fmt/dbk-article.rb +0 -0
- data/lib/deplate/fmt/dbk-book.rb +0 -0
- data/lib/deplate/fmt/dbk-ref.rb +3 -3
- data/lib/deplate/fmt/dbk-slides.rb +0 -0
- data/lib/deplate/fmt/dbk-snippet.rb +0 -0
- data/lib/deplate/fmt/html-snippet.rb +0 -0
- data/lib/deplate/fmt/html.rb +783 -550
- data/lib/deplate/fmt/htmlsite.rb +192 -199
- data/lib/deplate/fmt/htmlslides.rb +0 -0
- data/lib/deplate/fmt/htmlwebsite.rb +3 -3
- data/lib/deplate/fmt/latex-snippet.rb +0 -0
- data/lib/deplate/fmt/latex.rb +242 -83
- data/lib/deplate/fmt/null.rb +32 -0
- data/lib/deplate/fmt/php.rb +4 -4
- data/lib/deplate/fmt/phpsite.rb +6 -5
- data/lib/deplate/fmt/plain.rb +160 -106
- data/lib/deplate/fmt/template.rb +0 -0
- data/lib/deplate/fmt/xhtml10t.rb +0 -0
- data/lib/deplate/formatter-snippet.rb +0 -0
- data/lib/deplate/formatter.rb +613 -301
- data/lib/deplate/input.rb +202 -142
- data/lib/deplate/input/deplate-headings.rb +4 -6
- data/lib/deplate/input/deplate-restricted.rb +15 -9
- data/lib/deplate/input/deplate.rb +2 -4
- data/lib/deplate/input/rdoc.rb +39 -38
- data/lib/deplate/input/template.rb +0 -0
- data/lib/deplate/lib/Makefile.config +29 -0
- data/lib/deplate/lib/latex/deplate.sty +54 -0
- data/lib/deplate/lib/latex/highlight-extra.sty +0 -0
- data/lib/deplate/lib/latex/highlight-typical.sty +0 -0
- data/lib/deplate/lib/php/page-comment.inc.php +216 -0
- data/lib/deplate/lib/tabmenu.js +0 -0
- data/lib/deplate/locale/de.latin1 +155 -17
- data/lib/deplate/locale/ru.koi8-r +0 -0
- data/lib/deplate/locale/zh_cn.gb2312 +0 -0
- data/lib/deplate/macros.rb +133 -82
- data/lib/deplate/messages.rb +6 -4
- data/lib/deplate/metadata.rb +0 -0
- data/lib/deplate/metadata/marshal.rb +0 -0
- data/lib/deplate/metadata/xml.rb +0 -0
- data/lib/deplate/metadata/yaml.rb +0 -0
- data/lib/deplate/mod/anyword.rb +3 -3
- data/lib/deplate/mod/babelfish.rb +4 -4
- data/lib/deplate/mod/code-gvim.rb +8 -4
- data/lib/deplate/mod/code-highlight.rb +3 -3
- data/lib/deplate/mod/colored-log.rb +0 -0
- data/lib/deplate/mod/de.rb +2 -2
- data/lib/deplate/mod/en.rb +0 -0
- data/lib/deplate/mod/endnotes.rb +0 -0
- data/lib/deplate/mod/fr.rb +0 -0
- data/lib/deplate/mod/html-asciimath.rb +0 -0
- data/lib/deplate/mod/html-deplate-button.rb +0 -0
- data/lib/deplate/mod/html-headings-navbar.rb +5 -13
- data/lib/deplate/mod/html-jsmath.rb +39 -0
- data/lib/deplate/mod/html-obfuscate-email.rb +3 -3
- data/lib/deplate/mod/html-sidebar.rb +0 -0
- data/lib/deplate/mod/htmlslides-navbar-fh.rb +3 -3
- data/lib/deplate/mod/iconv.rb +0 -0
- data/lib/deplate/mod/imgurl.rb +4 -4
- data/lib/deplate/mod/inlatex-compound.rb +7 -10
- data/lib/deplate/mod/koma.rb +0 -0
- data/lib/deplate/mod/latex-emph-table-head.rb +0 -0
- data/lib/deplate/mod/latex-styles.rb +7 -4
- data/lib/deplate/mod/latex-verbatim-small.rb +0 -0
- data/lib/deplate/mod/makefile.rb +23 -7
- data/lib/deplate/mod/mark-external-urls.rb +3 -3
- data/lib/deplate/mod/markup-1-warn.rb +10 -10
- data/lib/deplate/mod/markup-1.rb +0 -0
- data/lib/deplate/mod/navbar-png.rb +24 -8
- data/lib/deplate/mod/noindent.rb +0 -0
- data/lib/deplate/mod/numpara.rb +0 -0
- data/lib/deplate/mod/particle-math.rb +4 -4
- data/lib/deplate/mod/php-extra.rb +46 -6
- data/lib/deplate/mod/pstoedit.rb +0 -0
- data/lib/deplate/mod/recode.rb +0 -0
- data/lib/deplate/mod/ru_koi8-r.rb +0 -0
- data/lib/deplate/mod/smart-dash.rb +26 -0
- data/lib/deplate/mod/smiley.rb +69 -7
- data/lib/deplate/mod/soffice.rb +0 -0
- data/lib/deplate/mod/symbols-latin1.rb +14 -23
- data/lib/deplate/mod/symbols-od-utf-8.rb +5 -3
- data/lib/deplate/mod/symbols-plain.rb +5 -35
- data/lib/deplate/mod/symbols-sgml.rb +8 -9
- data/lib/deplate/mod/symbols-utf-8.rb +8 -9
- data/lib/deplate/mod/symbols-xml.rb +5 -9
- data/lib/deplate/mod/syntax-region-alt.rb +5 -5
- data/lib/deplate/mod/utf8.rb +0 -0
- data/lib/deplate/mod/validate-html.rb +0 -0
- data/lib/deplate/mod/xmlrpc.rb +0 -0
- data/lib/deplate/mod/zh-cn-autospace.rb +18 -20
- data/lib/deplate/mod/zh-cn.rb +4 -6
- data/lib/deplate/nukumi2.rb +71 -0
- data/lib/deplate/once-method.rb +0 -0
- data/lib/deplate/output.rb +19 -21
- data/lib/deplate/particles.rb +178 -116
- data/lib/deplate/regions.rb +99 -58
- data/lib/deplate/skeletons.rb +122 -0
- data/lib/deplate/structured.rb +164 -106
- data/lib/deplate/template.rb +67 -43
- data/lib/deplate/templates/html-doc.html +0 -0
- data/lib/deplate/templates/html-left-tabbar-js.html +0 -0
- data/lib/deplate/templates/html-left-tabbar.html +0 -0
- data/lib/deplate/templates/html-tabbar-right-pcomments.php +22 -0
- data/lib/deplate/templates/html-tabbar-right-step.html +24 -0
- data/lib/deplate/templates/html-tabbar-right-table.html +0 -0
- data/lib/deplate/templates/html-tabbar-right.html +2 -4
- data/lib/deplate/templates/html-tabbar-top.html +0 -9
- data/lib/deplate/templates/html-tabbar.html +0 -0
- data/lib/deplate/variables.rb +127 -0
- data/lib/deplate/wiki-markup.rb +99 -33
- data/lib/deplate/xml.rb +18 -18
- data/lib/deplate/zh-cn.rb +0 -0
- data/lib/ps2ppm.rb +0 -0
- data/man/man1/deplate.1 +564 -474
- metadata +201 -186
data/lib/deplate/common.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
# @Website: http://deplate.sf.net/
|
4
4
|
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
5
5
|
# @Created: 02-Aug-2004.
|
6
|
-
# @Last Change:
|
7
|
-
# @Revision: 0.
|
6
|
+
# @Last Change: 05-Jun-2006.
|
7
|
+
# @Revision: 0.805
|
8
8
|
#
|
9
9
|
# = Description:
|
10
10
|
# Misc classes
|
@@ -13,18 +13,20 @@
|
|
13
13
|
|
14
14
|
module Deplate::CommonGround
|
15
15
|
#### pointer to the master deplater
|
16
|
-
|
16
|
+
attr_accessor :deplate
|
17
17
|
attr_writer :container
|
18
|
+
attr_accessor :indentation
|
19
|
+
attr_accessor :indentation_level
|
18
20
|
attr_accessor :args
|
19
21
|
attr_accessor :styles
|
20
22
|
attr_writer :doc_type
|
21
|
-
|
22
|
-
attr_reader :label_mode
|
23
|
+
attr_writer :doc_slot
|
23
24
|
attr_accessor :keep_whitespace
|
24
25
|
attr_accessor :match
|
25
26
|
attr_accessor :level_as_string
|
26
27
|
attr_accessor :level_as_list
|
27
28
|
attr_accessor :level
|
29
|
+
attr_reader :prototype
|
28
30
|
|
29
31
|
#### the element's parsed value
|
30
32
|
attr_accessor :elt
|
@@ -33,18 +35,18 @@ module Deplate::CommonGround
|
|
33
35
|
attr_accessor :prologue
|
34
36
|
attr_accessor :epilogue
|
35
37
|
# attr_accessor :expected
|
36
|
-
|
38
|
+
|
37
39
|
def initialize(deplate, args={})
|
38
40
|
@deplate = deplate
|
39
|
-
@
|
41
|
+
# @args = {:class => self.class, :self => self, :deplate => deplate}
|
42
|
+
@args = args[:args] || {:self => self, :deplate => deplate}
|
43
|
+
self.level_as_string = args[:level_as_string] || deplate.get_current_heading
|
40
44
|
@level_as_list = args[:level_as_string] || deplate.current_heading.dup
|
41
45
|
@elt = args[:elt] || nil
|
42
46
|
@text = args[:text] || nil
|
43
47
|
@styles = args[:styles] || []
|
44
48
|
@source = args[:source] || nil
|
45
49
|
@expected = args[:expected] || nil
|
46
|
-
# @args = {:class => self.class, :self => self, :deplate => deplate}
|
47
|
-
@args = args[:args] || {:self => self, :deplate => deplate}
|
48
50
|
@container = args[:container] || nil
|
49
51
|
@prologue = args[:prologue] || []
|
50
52
|
@epilogue = args[:epilogue] || []
|
@@ -52,7 +54,6 @@ module Deplate::CommonGround
|
|
52
54
|
@keep_whitespace = args[:keep_whitespace] || false
|
53
55
|
@doc_slot = args[:doc_slot] || nil
|
54
56
|
@doc_type = args[:doc_type] || nil
|
55
|
-
@label_mode = args[:label_mode] || nil
|
56
57
|
end
|
57
58
|
|
58
59
|
def container
|
@@ -69,35 +70,41 @@ module Deplate::CommonGround
|
|
69
70
|
end
|
70
71
|
|
71
72
|
def update_styles(styles=nil)
|
72
|
-
styles
|
73
|
-
|
74
|
-
|
73
|
+
styles ||= @args['style']
|
74
|
+
case styles
|
75
|
+
when String
|
76
|
+
styles = styles.split(/[ ,;]/)
|
77
|
+
end
|
78
|
+
if styles and !styles.empty?
|
79
|
+
@styles += styles
|
75
80
|
@styles.uniq!
|
76
81
|
end
|
77
82
|
end
|
83
|
+
alias :push_styles :update_styles
|
78
84
|
|
79
85
|
def update_id(opts={})
|
80
86
|
my_id = @args['id']
|
81
|
-
if my_id != @args[:id]
|
87
|
+
if my_id and my_id != @args[:id]
|
82
88
|
aid = @args[:id]
|
83
89
|
@label << aid if aid
|
84
90
|
@args[:id] = my_id
|
85
91
|
if block_given?
|
86
|
-
yield
|
92
|
+
yield(my_id)
|
87
93
|
end
|
88
94
|
end
|
89
95
|
end
|
90
96
|
|
91
|
-
def get_explicit_id
|
92
|
-
|
97
|
+
def get_explicit_id(args=@args)
|
98
|
+
args[:id] || args['id']
|
93
99
|
end
|
100
|
+
module_function :get_explicit_id
|
94
101
|
|
95
102
|
def get_id
|
96
103
|
# get_explicit_id || @label[0]
|
97
104
|
get_explicit_id
|
98
105
|
end
|
99
106
|
|
100
|
-
def styles_as_string(sep=
|
107
|
+
def styles_as_string(sep=' ')
|
101
108
|
if @styles.empty?
|
102
109
|
nil
|
103
110
|
else
|
@@ -117,18 +124,18 @@ module Deplate::CommonGround
|
|
117
124
|
if kind_of?(Deplate::Regions::Inlatex)
|
118
125
|
return
|
119
126
|
elsif expected
|
120
|
-
if defined?(
|
121
|
-
cc = element_or_particle(
|
122
|
-
cl =
|
127
|
+
if defined?(invoker.prototype)
|
128
|
+
cc = element_or_particle(invoker.prototype || self)
|
129
|
+
cl = invoker.prototype.class
|
123
130
|
else
|
124
131
|
cc = expected
|
125
132
|
cl = self.class
|
126
133
|
end
|
127
134
|
unless kind_of?(expected) or expected != cc
|
128
|
-
invoker.log([
|
135
|
+
invoker.log(['Expected something of a different class', expected, cl, invoker.class], :error)
|
129
136
|
end
|
130
137
|
# else
|
131
|
-
# invoker.log(
|
138
|
+
# invoker.log('Neither element nor particle', :anyway)
|
132
139
|
end
|
133
140
|
end
|
134
141
|
|
@@ -137,18 +144,18 @@ module Deplate::CommonGround
|
|
137
144
|
obj = obj.elt.first
|
138
145
|
end
|
139
146
|
for c in [Deplate::Element, Deplate::Particle]
|
140
|
-
if obj.kind_of?(c)
|
147
|
+
if obj == c or obj === c or obj.kind_of?(c)
|
141
148
|
return c
|
142
149
|
end
|
143
150
|
end
|
144
|
-
log([
|
151
|
+
log(['Neither block element nor inline text particle', self.class, obj], :error)
|
145
152
|
return nil
|
146
153
|
end
|
147
154
|
|
148
155
|
def doc_slot(default=:body, overwrite=false)
|
149
156
|
if (overwrite and default) or !@doc_slot
|
150
|
-
if @args[
|
151
|
-
@doc_slot = @args[
|
157
|
+
if @args['slot']
|
158
|
+
@doc_slot = @args['slot']
|
152
159
|
else
|
153
160
|
@doc_slot = default
|
154
161
|
end
|
@@ -158,7 +165,7 @@ module Deplate::CommonGround
|
|
158
165
|
|
159
166
|
def doc_type(default=:body, overwrite=false)
|
160
167
|
if (overwrite and default) or !@doc_type
|
161
|
-
@doc_type = @args[
|
168
|
+
@doc_type = @args['type'] || default
|
162
169
|
end
|
163
170
|
return @doc_type
|
164
171
|
end
|
@@ -176,7 +183,7 @@ module Deplate::CommonGround
|
|
176
183
|
end
|
177
184
|
|
178
185
|
def warn_unpexpected(expected, got)
|
179
|
-
msg =
|
186
|
+
msg = 'Expected %s but got %s' % [expected, got]
|
180
187
|
if @invoker
|
181
188
|
@invoker.log(msg, :error)
|
182
189
|
else
|
@@ -189,7 +196,7 @@ module Deplate::CommonGround
|
|
189
196
|
end
|
190
197
|
|
191
198
|
def plain_caption?
|
192
|
-
@deplate.variables[
|
199
|
+
@deplate.variables['headings'] == 'plain' or @args['plain']
|
193
200
|
end
|
194
201
|
|
195
202
|
def output_file_name(args={})
|
@@ -201,7 +208,7 @@ module Deplate::CommonGround
|
|
201
208
|
if level_as_string
|
202
209
|
rv = @deplate.file_name_by_level(level_as_string)
|
203
210
|
elsif label
|
204
|
-
rv = @deplate.get_filename_for_label(self, label) ||
|
211
|
+
rv = @deplate.get_filename_for_label(self, label) || ''
|
205
212
|
else
|
206
213
|
if obj.kind_of?(Deplate::BaseParticle) or obj.kind_of?(Deplate::BaseParticle)
|
207
214
|
obj = obj.container
|
@@ -214,16 +221,21 @@ module Deplate::CommonGround
|
|
214
221
|
if rv
|
215
222
|
if basename
|
216
223
|
return File.basename(rv)
|
217
|
-
elsif relative ==
|
224
|
+
elsif relative == ''
|
218
225
|
return File.basename(rv)
|
219
226
|
elsif relative
|
220
|
-
|
221
|
-
|
227
|
+
out = relative.output_file_name
|
228
|
+
if out == rv
|
229
|
+
return ''
|
230
|
+
else
|
231
|
+
dir = File.dirname(out)
|
232
|
+
return @deplate.relative_path(rv, dir)
|
233
|
+
end
|
222
234
|
else
|
223
235
|
return rv
|
224
236
|
end
|
225
237
|
else
|
226
|
-
log([
|
238
|
+
log(['Internal error in #output_file_name', obj.class.name], :error)
|
227
239
|
raise Exception
|
228
240
|
end
|
229
241
|
end
|
@@ -239,8 +251,34 @@ module Deplate::CommonGround
|
|
239
251
|
location = [output_file_name(args)]
|
240
252
|
id = get_id
|
241
253
|
location << id if id
|
242
|
-
location.join(
|
254
|
+
location.join('#')
|
255
|
+
end
|
256
|
+
|
257
|
+
def post_process_text(text, args=@args)
|
258
|
+
sub = args['sub'] || args['s']
|
259
|
+
if sub
|
260
|
+
sep = sub[0..0]
|
261
|
+
rx, rp = sub[1..-1].split(Regexp.new(Regexp.quote(sep)))
|
262
|
+
text.gsub!(Regexp.new(rx), rp)
|
263
|
+
end
|
264
|
+
tr = args['tr']
|
265
|
+
if tr
|
266
|
+
sep = tr[0..0]
|
267
|
+
rx, rp = tr[1..-1].split(Regexp.new(Regexp.quote(sep)))
|
268
|
+
text.tr!(rx, rp)
|
269
|
+
end
|
270
|
+
if args['upcase']
|
271
|
+
text.upcase!
|
272
|
+
end
|
273
|
+
if args['downcase']
|
274
|
+
text.downcase!
|
275
|
+
end
|
276
|
+
if args['capitalize']
|
277
|
+
text.capitalize!
|
278
|
+
end
|
279
|
+
text
|
243
280
|
end
|
281
|
+
module_function :post_process_text
|
244
282
|
end
|
245
283
|
|
246
284
|
|
@@ -264,10 +302,10 @@ module Deplate::CommonParticle
|
|
264
302
|
return @deplate.formatter.format_particle(agent, *args)
|
265
303
|
end
|
266
304
|
|
267
|
-
def format_as_string
|
305
|
+
def format_as_string
|
268
306
|
# <+TBD+>: Doesn't work because the particles don't give info
|
269
307
|
# about their formatting method
|
270
|
-
# @deplate.formatter.format_particle_as_string(
|
308
|
+
# @deplate.formatter.format_particle_as_string(self)
|
271
309
|
end
|
272
310
|
end
|
273
311
|
|
@@ -277,11 +315,11 @@ module Deplate::CommonElement
|
|
277
315
|
#### accumulated lines
|
278
316
|
attr_accessor :accum
|
279
317
|
|
280
|
-
def format_as_string
|
281
|
-
klass =
|
318
|
+
def format_as_string
|
319
|
+
klass = self.class
|
282
320
|
fm = klass.formatter
|
283
321
|
if fm
|
284
|
-
return @deplate.formatter.format_element_as_string(
|
322
|
+
return @deplate.formatter.format_element_as_string(fm, self)
|
285
323
|
else
|
286
324
|
log(["Don't know how to format an object of this class", klass], :error)
|
287
325
|
end
|
@@ -298,29 +336,151 @@ module Deplate::CommonElement
|
|
298
336
|
end
|
299
337
|
|
300
338
|
def update_id(opts={})
|
301
|
-
super
|
339
|
+
super do |id|
|
340
|
+
@deplate.add_label(self, get_explicit_id, level_as_string, :anyway => true)
|
341
|
+
end
|
302
342
|
end
|
303
343
|
end
|
304
344
|
|
305
345
|
|
306
|
-
class Deplate::
|
307
|
-
|
346
|
+
class Deplate::CommonObject
|
347
|
+
@class_attributes = {}
|
348
|
+
@class_meta_attributes = {}
|
308
349
|
|
309
350
|
class << self
|
310
|
-
|
351
|
+
def class_attributes
|
352
|
+
class_attributes_ensure
|
353
|
+
@class_attributes
|
354
|
+
end
|
355
|
+
# protected :class_attributes
|
356
|
+
|
357
|
+
def class_meta_attributes
|
358
|
+
class_attributes_ensure
|
359
|
+
@class_meta_attributes
|
360
|
+
end
|
361
|
+
|
362
|
+
def class_attributes=(value)
|
363
|
+
class_attributes_ensure
|
364
|
+
@class_attributes = value
|
365
|
+
end
|
366
|
+
protected :class_attributes=
|
367
|
+
|
368
|
+
def class_attributes_ensure
|
369
|
+
@class_attributes ||= {}
|
370
|
+
@class_meta_attributes ||= {}
|
371
|
+
end
|
372
|
+
private :class_attributes_ensure
|
373
|
+
|
374
|
+
def class_attribute(name, default=nil, args=nil)
|
375
|
+
class_attributes_ensure
|
376
|
+
@class_attributes[name] = default
|
377
|
+
if args
|
378
|
+
@class_meta_attributes ||= {}
|
379
|
+
if @class_meta_attributes[name]
|
380
|
+
@class_meta_attributes[name].merge!(args)
|
381
|
+
else
|
382
|
+
@class_meta_attributes[name] = args
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
311
386
|
|
387
|
+
def inherited(subclass)
|
388
|
+
subclass.class_attributes.merge!(@class_attributes.dup) do |key, ov, nv|
|
389
|
+
end
|
390
|
+
subclass.class_meta_attributes.merge!(@class_meta_attributes.dup) do |key, ov, nv|
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
def method_missing(method, *args)
|
395
|
+
# p "DBG method_missing: #{method} #{args}"
|
396
|
+
class_attributes_ensure
|
397
|
+
method_s = method.to_s
|
398
|
+
if method_s =~ /=$/
|
399
|
+
method_s = method_s[0..-2]
|
400
|
+
method_y = method_s.intern
|
401
|
+
setter = true
|
402
|
+
else
|
403
|
+
method_y = method
|
404
|
+
setter = false
|
405
|
+
end
|
406
|
+
if @class_attributes.keys.include?(method_y)
|
407
|
+
pre = "hook_pre_#{method}"
|
408
|
+
if respond_to?(pre)
|
409
|
+
send(pre, *args)
|
410
|
+
end
|
411
|
+
if setter
|
412
|
+
if args.size > 1
|
413
|
+
raise "Wrong number of arguments: #{method} #{args}"
|
414
|
+
end
|
415
|
+
rv = @class_attributes[method_y] = args[0]
|
416
|
+
else
|
417
|
+
rv = @class_attributes[method_y]
|
418
|
+
end
|
419
|
+
post = "hook_post_#{method}"
|
420
|
+
if respond_to?(post)
|
421
|
+
send(post, *args)
|
422
|
+
end
|
423
|
+
# p "DBG method_missing => #{rv}"
|
424
|
+
return rv
|
425
|
+
else
|
426
|
+
super
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
def respond_to?(symbol, *args)
|
431
|
+
class_attributes_ensure
|
432
|
+
super or @class_attributes.keys.include?(symbol)
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
|
438
|
+
class Deplate::Base < Deplate::CommonObject
|
439
|
+
include Deplate::CommonGround
|
440
|
+
|
441
|
+
class << self
|
312
442
|
def set_rx(rx)
|
313
|
-
|
443
|
+
self.rx = rx
|
314
444
|
end
|
315
445
|
|
446
|
+
def def_get(name, arg=nil)
|
447
|
+
mname = "get_#{name}"
|
448
|
+
case arg
|
449
|
+
when Array
|
450
|
+
define_method(mname) do
|
451
|
+
for i in arg
|
452
|
+
rv = @match[i]
|
453
|
+
return rv if rv
|
454
|
+
end
|
455
|
+
end
|
456
|
+
when Proc
|
457
|
+
define_method(mname, arg)
|
458
|
+
when Numeric
|
459
|
+
define_method(mname) {@match[arg]}
|
460
|
+
else
|
461
|
+
define_method(mname) {nil}
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
316
465
|
def set_formatter(formatter, alt=false)
|
317
466
|
if alt
|
318
|
-
|
467
|
+
self.formatter2 = formatter
|
319
468
|
else
|
320
|
-
|
469
|
+
self.formatter = formatter
|
321
470
|
end
|
322
471
|
end
|
323
472
|
end
|
473
|
+
|
474
|
+
def label_mode
|
475
|
+
self.class.label_mode
|
476
|
+
end
|
477
|
+
|
478
|
+
class_attribute :formatter
|
479
|
+
class_attribute :formatter2
|
480
|
+
class_attribute :rx
|
481
|
+
class_attribute :indentation_mode, :auto
|
482
|
+
class_attribute :label_mode
|
483
|
+
class_attribute :volatile, false
|
324
484
|
end
|
325
485
|
|
326
486
|
|
@@ -330,6 +490,7 @@ end
|
|
330
490
|
|
331
491
|
|
332
492
|
class Deplate::BaseParticle < Deplate::Base
|
493
|
+
class_attribute :pre_condition, nil
|
333
494
|
include Deplate::CommonParticle
|
334
495
|
end
|
335
496
|
|
data/lib/deplate/converter.rb
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
# @Website: http://deplate.sf.net/
|
5
5
|
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
6
6
|
# @Created: 14-Okt-2004.
|
7
|
-
# @Last Change:
|
8
|
-
# @Revision: 0.
|
7
|
+
# @Last Change: 07-Apr-2006.
|
8
|
+
# @Revision: 0.128
|
9
9
|
#
|
10
10
|
# = Description
|
11
11
|
# = Usage
|
@@ -56,10 +56,8 @@ class Deplate::Converter
|
|
56
56
|
@deplate = Deplate::Core.new(formatter, :options => @options)
|
57
57
|
vars = args[:variables]
|
58
58
|
vars ||= @master.variables.dup if @master
|
59
|
-
@deplate.instance_eval
|
60
|
-
|
61
|
-
end
|
62
|
-
@formatter_method = "to_%s" % formatter.gsub(/[^a-zA-Z_]/, "_")
|
59
|
+
@deplate.instance_eval {@variables = vars} if vars
|
60
|
+
@formatter_method = "to_%s" % formatter.gsub(/[^[:alnum:]_]/, "_")
|
63
61
|
end
|
64
62
|
|
65
63
|
def convert_string(string)
|
@@ -69,6 +67,14 @@ class Deplate::Converter
|
|
69
67
|
def convert_file(filename)
|
70
68
|
@deplate.send(@formatter_method, nil, filename)
|
71
69
|
end
|
70
|
+
|
71
|
+
def method_missing(method, *args, &block)
|
72
|
+
if @deplate.respond_to?(method)
|
73
|
+
@deplate.send(method, *args, &block)
|
74
|
+
else
|
75
|
+
super
|
76
|
+
end
|
77
|
+
end
|
72
78
|
end
|
73
79
|
|
74
80
|
# if __FILE__ == $0
|