hermeneutics 1.10 → 1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README +11 -0
- data/bin/hermesmail +97 -62
- data/lib/hermeneutics/addrs.rb +6 -4
- data/lib/hermeneutics/boxes.rb +134 -119
- data/lib/hermeneutics/cgi.rb +210 -85
- data/lib/hermeneutics/cli/imap/commands.rb +283 -0
- data/lib/hermeneutics/cli/imap/parser.rb +245 -0
- data/lib/hermeneutics/cli/imap/utf7imap.rb +75 -0
- data/lib/hermeneutics/cli/imap.rb +240 -0
- data/lib/hermeneutics/cli/openssl.rb +11 -0
- data/lib/hermeneutics/cli/pop3.rb +257 -0
- data/lib/hermeneutics/cli/protocol.rb +141 -0
- data/lib/hermeneutics/cli/smtp.rb +218 -0
- data/lib/hermeneutics/color.rb +16 -9
- data/lib/hermeneutics/contents.rb +10 -0
- data/lib/hermeneutics/css.rb +14 -10
- data/lib/hermeneutics/escape.rb +31 -34
- data/lib/hermeneutics/html.rb +38 -60
- data/lib/hermeneutics/mail.rb +248 -63
- data/lib/hermeneutics/message.rb +245 -254
- data/lib/hermeneutics/tags.rb +4 -0
- data/lib/hermeneutics/types.rb +8 -7
- data/lib/hermeneutics/version.rb +3 -4
- metadata +27 -6
- data/lib/hermeneutics/cli/pop.rb +0 -102
- data/lib/hermeneutics/transports.rb +0 -230
data/lib/hermeneutics/css.rb
CHANGED
@@ -26,7 +26,7 @@ module Hermeneutics
|
|
26
26
|
# a ":visited", ATTR_COL2, ATTR_DECON
|
27
27
|
# a ":active", ATTR_COL1, ATTR_DECON
|
28
28
|
# a ":focus", ATTR_COL1, ATTR_DECOU
|
29
|
-
#
|
29
|
+
# skip
|
30
30
|
#
|
31
31
|
# body "#dummy" do
|
32
32
|
# properties background_color: "f7f7f7".to_rgb
|
@@ -145,22 +145,22 @@ module Hermeneutics
|
|
145
145
|
def comment str
|
146
146
|
@out << "/*"
|
147
147
|
str = mask_comment str
|
148
|
-
ml = str =~ %r(
|
148
|
+
ml = str =~ %r(\n)
|
149
149
|
if ml then
|
150
|
-
@out <<
|
150
|
+
@out << "\n"
|
151
151
|
str.each_line { |l|
|
152
152
|
l.chomp!
|
153
|
-
@out << " * " << l <<
|
153
|
+
@out << " * " << l << "\n"
|
154
154
|
}
|
155
155
|
else
|
156
156
|
@out << " " << str
|
157
157
|
end
|
158
158
|
@out << " */"
|
159
|
-
ml and @out <<
|
159
|
+
ml and @out << "\n"
|
160
160
|
end
|
161
161
|
|
162
|
-
def
|
163
|
-
@out <<
|
162
|
+
def skip
|
163
|
+
@out << "\n"
|
164
164
|
end
|
165
165
|
|
166
166
|
def tag *args
|
@@ -182,6 +182,8 @@ module Hermeneutics
|
|
182
182
|
protected_instance_methods + instance_methods)
|
183
183
|
undef_method *m
|
184
184
|
|
185
|
+
private
|
186
|
+
|
185
187
|
def method_missing sym, *args, &block
|
186
188
|
if Html::TAGS[ sym] then
|
187
189
|
if args.any? and not Hash === args.first then
|
@@ -198,6 +200,8 @@ module Hermeneutics
|
|
198
200
|
end
|
199
201
|
end
|
200
202
|
|
203
|
+
public
|
204
|
+
|
201
205
|
def properties *args
|
202
206
|
write @selector.to_s, *args
|
203
207
|
end
|
@@ -228,15 +232,15 @@ module Hermeneutics
|
|
228
232
|
args.each { |a| p.update a }
|
229
233
|
@out << sel << " {"
|
230
234
|
nl, ind = if p.size > 1 then
|
231
|
-
@out <<
|
232
|
-
[
|
235
|
+
@out << "\n"
|
236
|
+
[ "\n", INDENT]
|
233
237
|
else
|
234
238
|
[ " ", " "]
|
235
239
|
end
|
236
240
|
single p do |s|
|
237
241
|
@out << ind << s << nl
|
238
242
|
end
|
239
|
-
@out << "}" <<
|
243
|
+
@out << "}" << "\n"
|
240
244
|
end
|
241
245
|
|
242
246
|
def single hash
|
data/lib/hermeneutics/escape.rb
CHANGED
@@ -12,25 +12,25 @@ require "supplement"
|
|
12
12
|
:section: Classes definied here
|
13
13
|
|
14
14
|
Hermeneutics::Entities encodes to and decodes from HTML-Entities
|
15
|
-
(
|
15
|
+
(+&+ etc.)
|
16
16
|
|
17
17
|
Hermeneutics::URLText encodes to and decodes from URLs
|
18
|
-
(
|
18
|
+
(+%2d+ etc.)
|
19
19
|
|
20
20
|
Hermeneutics::HeaderExt encodes to and decodes from E-Mail Header fields
|
21
|
-
(
|
21
|
+
(+=?UTF-8?Q?=C3=B6?=+ etc.).
|
22
22
|
|
23
23
|
=end
|
24
24
|
|
25
25
|
module Hermeneutics
|
26
26
|
|
27
|
-
# Translate HTML and XML character entities:
|
28
|
-
#
|
27
|
+
# Translate HTML and XML character entities: +"&"+ to
|
28
|
+
# +"&"+ and vice versa.
|
29
29
|
#
|
30
30
|
# == What actually happens
|
31
31
|
#
|
32
|
-
# HTML pages usually come in with characters encoded
|
33
|
-
#
|
32
|
+
# HTML pages usually come in with characters encoded +<+ for +<+ and
|
33
|
+
# +€+ for +€+.
|
34
34
|
#
|
35
35
|
# Further, they may contain a meta tag in the header like this:
|
36
36
|
#
|
@@ -41,27 +41,25 @@ module Hermeneutics
|
|
41
41
|
#
|
42
42
|
# <?xml version="1.0" encoding="UTF-8" ?> (XHTML)
|
43
43
|
#
|
44
|
-
# When +charset+ is
|
45
|
-
#
|
46
|
-
# be displayed a character <code>"ä"</code>.
|
44
|
+
# When +charset+ is +utf-8+ and the file contains the byte sequence
|
45
|
+
# +"\303\244"+/+"\xc3\xa4"+ then there will be displayed a character +"ä"+.
|
47
46
|
#
|
48
|
-
# When +charset+ is
|
49
|
-
#
|
50
|
-
# displayed a character <code>"ä"</code>, too.
|
47
|
+
# When +charset+ is +iso8859-15+ and the file contains the byte sequence
|
48
|
+
# +"\344"+/+"\xe4"+ then there will be displayed a character +"ä"+, too.
|
51
49
|
#
|
52
|
-
# The sequence
|
50
|
+
# The sequence +"ä"+ will produce an +"ä"+ in any
|
53
51
|
# case.
|
54
52
|
#
|
55
53
|
# == What you should do
|
56
54
|
#
|
57
55
|
# Generating your own HTML pages you will always be safe when you only
|
58
|
-
# produce entity tags as
|
59
|
-
#
|
56
|
+
# produce entity tags as +ä+ and +€+ or +ä+ and +€+
|
57
|
+
# respectively.
|
60
58
|
#
|
61
59
|
# == What this module does
|
62
60
|
#
|
63
|
-
# This module translates strings to a HTML-masked version. The encoding
|
64
|
-
# not be changed and you may demand to keep 8-bit-characters.
|
61
|
+
# This module translates strings to a HTML-masked version. The encoding
|
62
|
+
# will not be changed and you may demand to keep 8-bit-characters.
|
65
63
|
#
|
66
64
|
# == Examples
|
67
65
|
#
|
@@ -118,7 +116,7 @@ module Hermeneutics
|
|
118
116
|
# :call-seq:
|
119
117
|
# new( keep_8bit: bool) -> ent
|
120
118
|
#
|
121
|
-
# Creates an
|
119
|
+
# Creates an +Entities+ converter.
|
122
120
|
#
|
123
121
|
# ent = Entities.new keep_8bit: true
|
124
122
|
#
|
@@ -184,9 +182,8 @@ module Hermeneutics
|
|
184
182
|
# Entities.decode "<" #=> "<"
|
185
183
|
# Entities.decode "äöü" #=> "äöü"
|
186
184
|
#
|
187
|
-
# Unmasked 8-bit-characters (
|
188
|
-
#
|
189
|
-
# a unique encoding.
|
185
|
+
# Unmasked 8-bit-characters (+"ä"+ instead of +"ä"+) will be kept
|
186
|
+
# but translated to a unique encoding.
|
190
187
|
#
|
191
188
|
# s = "ä ö ü"
|
192
189
|
# s.encode! "utf-8"
|
@@ -259,7 +256,7 @@ module Hermeneutics
|
|
259
256
|
# :call-seq:
|
260
257
|
# new( hash) -> urltext
|
261
258
|
#
|
262
|
-
# Creates a
|
259
|
+
# Creates a +URLText+ converter.
|
263
260
|
#
|
264
261
|
# The parameters may be given as values or as a hash.
|
265
262
|
#
|
@@ -276,7 +273,7 @@ module Hermeneutics
|
|
276
273
|
# :call-seq:
|
277
274
|
# encode( str) -> str
|
278
275
|
#
|
279
|
-
# Create a string that contains
|
276
|
+
# Create a string that contains +%XX+-encoded bytes.
|
280
277
|
#
|
281
278
|
# utx = URLText.new
|
282
279
|
# utx.encode "'Stop!' said Fred." #=> "%27Stop%21%27+said+Fred."
|
@@ -292,15 +289,14 @@ module Hermeneutics
|
|
292
289
|
# s = "< ä >".encode "ISO-8859-1"
|
293
290
|
# utx.encode s #=> "%3C+\xe4+%3E" in ISO-8859-1
|
294
291
|
#
|
295
|
-
# A space
|
296
|
-
#
|
292
|
+
# A space +" "+ will not be replaced by a plus +"\+"+ if +keep_space+ is
|
293
|
+
# set.
|
297
294
|
#
|
298
295
|
# utx = URLText.new keep_space: true
|
299
296
|
# s = "< x >"
|
300
297
|
# utx.encode s #=> "%3C x %3E"
|
301
298
|
#
|
302
|
-
# When +mask_space+ is set, then a space will be represented as
|
303
|
-
# <code>"%20"</code>,
|
299
|
+
# When +mask_space+ is set, then a space will be represented as +"%20"+,
|
304
300
|
#
|
305
301
|
def encode str
|
306
302
|
r = str.new_string
|
@@ -347,6 +343,7 @@ module Hermeneutics
|
|
347
343
|
else val.to_s.notempty?
|
348
344
|
end
|
349
345
|
end
|
346
|
+
private
|
350
347
|
def method_missing sym, *args
|
351
348
|
if args.empty? and not sym =~ /[!?=]\z/ then
|
352
349
|
self[ sym]
|
@@ -369,7 +366,7 @@ module Hermeneutics
|
|
369
366
|
# :call-seq:
|
370
367
|
# encode_hash( hash) -> str
|
371
368
|
#
|
372
|
-
# Encode a
|
369
|
+
# Encode a +Hash+ to a URL-style string.
|
373
370
|
#
|
374
371
|
# utx = URLText.new
|
375
372
|
#
|
@@ -469,8 +466,8 @@ module Hermeneutics
|
|
469
466
|
# decode_hash( str) -> hash
|
470
467
|
# decode_hash( str) { |key,val| ... } -> nil or int
|
471
468
|
#
|
472
|
-
# Decode a URL-style encoded string to a
|
473
|
-
#
|
469
|
+
# Decode a URL-style encoded string to a +Hash+. In case a block is
|
470
|
+
# given, the number of key-value pairs is returned.
|
474
471
|
#
|
475
472
|
# str = "a=%3B%3B%3B&x=%26auml%3B%26ouml%3B%26uuml%3B"
|
476
473
|
# URLText.decode_hash str do |k,v|
|
@@ -527,7 +524,7 @@ module Hermeneutics
|
|
527
524
|
# :call-seq:
|
528
525
|
# new( [ parameters] ) -> con
|
529
526
|
#
|
530
|
-
# Creates a
|
527
|
+
# Creates a +HeaderExt+ converter.
|
531
528
|
#
|
532
529
|
# See the +encode+ method for an explanation of the parameters.
|
533
530
|
#
|
@@ -571,8 +568,8 @@ module Hermeneutics
|
|
571
568
|
# The result will not contain any 8-bit characters. The encoding will
|
572
569
|
# be kept although it won't have a meaning.
|
573
570
|
#
|
574
|
-
# The parameter
|
575
|
-
#
|
571
|
+
# The parameter +:mask+ will have no influence on the masking itself but
|
572
|
+
# will guarantee characters to be masked.
|
576
573
|
#
|
577
574
|
# == Examples
|
578
575
|
#
|
data/lib/hermeneutics/html.rb
CHANGED
@@ -121,6 +121,10 @@ module Hermeneutics
|
|
121
121
|
@out.path
|
122
122
|
rescue NoMethodError
|
123
123
|
end
|
124
|
+
def merge str
|
125
|
+
do_ind
|
126
|
+
@out << str
|
127
|
+
end
|
124
128
|
def plain str
|
125
129
|
do_ind
|
126
130
|
@out << (@ent.encode str)
|
@@ -147,7 +151,7 @@ module Hermeneutics
|
|
147
151
|
@out << tag
|
148
152
|
mkattrs attrs
|
149
153
|
end
|
150
|
-
if nls
|
154
|
+
if nls>3 then
|
151
155
|
verbose_block yield
|
152
156
|
else
|
153
157
|
indent_if nls>2 do
|
@@ -209,9 +213,9 @@ module Hermeneutics
|
|
209
213
|
@out << "/* "
|
210
214
|
brace false do
|
211
215
|
@out << "![CDATA["
|
212
|
-
@out << "
|
216
|
+
@out << " */\n"
|
213
217
|
@out << str
|
214
|
-
@out <<
|
218
|
+
@out << "\n/* "
|
215
219
|
@out << "]]"
|
216
220
|
end
|
217
221
|
@out << " */"
|
@@ -223,7 +227,7 @@ module Hermeneutics
|
|
223
227
|
def brk
|
224
228
|
unless @nl then
|
225
229
|
@nl = true
|
226
|
-
@out <<
|
230
|
+
@out << "\n"
|
227
231
|
end
|
228
232
|
end
|
229
233
|
def out_brk str
|
@@ -319,6 +323,8 @@ module Hermeneutics
|
|
319
323
|
TAGS[ name]
|
320
324
|
end
|
321
325
|
|
326
|
+
private
|
327
|
+
|
322
328
|
def method_missing name, *args, &block
|
323
329
|
t = tag? name
|
324
330
|
t or super
|
@@ -330,10 +336,16 @@ module Hermeneutics
|
|
330
336
|
end
|
331
337
|
end
|
332
338
|
|
339
|
+
public
|
340
|
+
|
341
|
+
def merge str
|
342
|
+
@generator.merge str
|
343
|
+
nil
|
344
|
+
end
|
345
|
+
|
333
346
|
def pcdata *strs
|
334
347
|
strs.each { |s|
|
335
|
-
s
|
336
|
-
@generator.plain s
|
348
|
+
@generator.plain s if s.notempty?
|
337
349
|
}
|
338
350
|
nil
|
339
351
|
end
|
@@ -343,9 +355,13 @@ module Hermeneutics
|
|
343
355
|
self
|
344
356
|
end
|
345
357
|
|
346
|
-
def _
|
347
|
-
|
348
|
-
|
358
|
+
def _ *strs
|
359
|
+
if strs.notempty? then
|
360
|
+
pcdata *strs
|
361
|
+
else
|
362
|
+
@generator.plain yield
|
363
|
+
nil
|
364
|
+
end
|
349
365
|
end
|
350
366
|
|
351
367
|
def comment str
|
@@ -362,64 +378,26 @@ module Hermeneutics
|
|
362
378
|
method_missing :html, **attrs do yield end
|
363
379
|
end
|
364
380
|
|
365
|
-
def head attrs
|
366
|
-
method_missing :head, attrs do
|
381
|
+
def head **attrs
|
382
|
+
method_missing :head, **attrs do
|
367
383
|
meta charset: @generator.encoding
|
368
384
|
yield
|
369
385
|
end
|
370
386
|
end
|
371
387
|
|
372
|
-
def
|
373
|
-
|
374
|
-
"post"
|
375
|
-
else
|
376
|
-
"get"
|
377
|
-
end
|
378
|
-
@tabindex = 0
|
379
|
-
method_missing :form, attrs, &block
|
380
|
-
ensure
|
381
|
-
@tabindex = nil
|
388
|
+
def h i, **attrs, &block
|
389
|
+
method_missing :"h#{i.to_i}", **attrs, &block
|
382
390
|
end
|
383
391
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
@tabindex += 1
|
389
|
-
attrs[ :tabindex] ||= @tabindex
|
390
|
-
Field[ type, attrs]
|
392
|
+
def form **attrs, &block
|
393
|
+
attrs[ :method] ||=
|
394
|
+
attrs[ :enctype] == "multipart/form-data" ? "post" : "get"
|
395
|
+
method_missing :form, **attrs, &block
|
391
396
|
end
|
392
397
|
|
393
|
-
def
|
394
|
-
|
395
|
-
|
396
|
-
else
|
397
|
-
if Field === field or attrs then
|
398
|
-
attrs = attrs.merge for: field.attrs[ :id]
|
399
|
-
else
|
400
|
-
attrs = field
|
401
|
-
end
|
402
|
-
method_missing :label, attrs, &block
|
403
|
-
end
|
404
|
-
end
|
405
|
-
|
406
|
-
def input arg, &block
|
407
|
-
if Field === arg then
|
408
|
-
case arg.type
|
409
|
-
when /select/i then
|
410
|
-
method_missing :select, arg.attrs, &block
|
411
|
-
when /textarea/i then
|
412
|
-
block and
|
413
|
-
raise ArgumentError, "Field textarea: use the value attribute."
|
414
|
-
v = arg.attrs.delete :value
|
415
|
-
method_missing :textarea, arg.attrs do v end
|
416
|
-
else
|
417
|
-
arg.attrs[ :type] ||= arg.type
|
418
|
-
method_missing :input, arg.attrs, &block
|
419
|
-
end
|
420
|
-
else
|
421
|
-
method_missing :input, arg, &block
|
422
|
-
end
|
398
|
+
def input **attrs, &block
|
399
|
+
attrs[ :id] ||= attrs[ :name]
|
400
|
+
method_missing :input, **attrs, &block
|
423
401
|
end
|
424
402
|
|
425
403
|
end
|
@@ -433,8 +411,8 @@ module Hermeneutics
|
|
433
411
|
super
|
434
412
|
end
|
435
413
|
|
436
|
-
def a attrs
|
437
|
-
attrs[ :name] ||= attrs[ :id]
|
414
|
+
def a **attrs
|
415
|
+
attrs[ :name] ||= attrs[ :id]
|
438
416
|
super
|
439
417
|
end
|
440
418
|
|