hermeneutics 1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,137 @@
1
+ #
2
+ # hermeneutics/types.rb -- Header field types
3
+ #
4
+
5
+ require "supplement"
6
+
7
+ require "time"
8
+ require "bigdecimal"
9
+
10
+ require "hermeneutics/escape"
11
+
12
+
13
+ class NilClass
14
+ def each
15
+ end
16
+ end
17
+
18
+ module Hermeneutics
19
+
20
+ class PlainText < String
21
+ class <<self
22
+ def parse str
23
+ t = HeaderExt.decode str
24
+ new t
25
+ end
26
+ end
27
+ def initialize text
28
+ super
29
+ gsub! /\s+/, " "
30
+ strip!
31
+ end
32
+ def quote
33
+ to_s
34
+ end
35
+ def encode
36
+ (HeaderExt.encode self).split
37
+ end
38
+ end
39
+
40
+ class Timestamp < Time
41
+ class <<self
42
+ def new time = nil
43
+ case time
44
+ when nil then now
45
+ when Time then mktime *time.to_a
46
+ else parse time.to_s
47
+ end
48
+ end
49
+ end
50
+ def quote
51
+ to_s
52
+ end
53
+ def encode
54
+ rfc822
55
+ end
56
+ end
57
+
58
+ class Id < String
59
+ @host = nil
60
+ class <<self
61
+ attr_writer :host
62
+ autoload :Socket, "socket"
63
+ def host
64
+ @host ||= socket.gethostname
65
+ end
66
+ def parse str
67
+ str =~ /<(.*?)>/
68
+ yield $' if block_given?
69
+ $1
70
+ end
71
+ end
72
+ attr_reader :id
73
+ def initialize id = nil
74
+ super id || generate
75
+ end
76
+ alias quote to_s
77
+ def encode
78
+ "<#{self}>"
79
+ end
80
+ alias inspect encode
81
+ private
82
+ def generate
83
+ t = Time.now.strftime "%Y%m%d%H%M%S"
84
+ h = self.class.host
85
+ a = "a".ord
86
+ r = ""
87
+ 8.times { r << (a + (rand 26)).chr }
88
+ "#{t}.#$$.#{r}@#{h}"
89
+ end
90
+ end
91
+
92
+ class IdList < Array
93
+ class <<self
94
+ def parse str
95
+ i = new
96
+ loop do
97
+ id = Id.parse str do |rest| str = rest end
98
+ id or break
99
+ i.push id
100
+ end
101
+ i
102
+ end
103
+ end
104
+ def initialize
105
+ super
106
+ end
107
+ def add id
108
+ id = Id.new id.to_s unless Id === id
109
+ puts id
110
+ end
111
+ def quote
112
+ map { |i| i.quote }.join " "
113
+ end
114
+ alias to_s quote
115
+ def encode
116
+ map { |i| i.encode }.join " "
117
+ end
118
+ end
119
+
120
+ class Count < BigDecimal
121
+ class <<self
122
+ def parse str
123
+ new str
124
+ end
125
+ end
126
+ def initialize num
127
+ super num.to_i.to_s
128
+ end
129
+ def to_s *args
130
+ to_i.to_s
131
+ end
132
+ alias quote to_s
133
+ alias encode to_s
134
+ end
135
+
136
+ end
137
+
@@ -0,0 +1,32 @@
1
+ # encoding: UTF-8
2
+
3
+ #
4
+ # hermeneutics/version.rb -- Version number
5
+ #
6
+
7
+ # :main:Hermeneutics
8
+ #
9
+ # = Overview
10
+ #
11
+ # This library provides classes for generating and parsing mail, HTML
12
+ # and CSS. Further, it is a CGI library.
13
+ #
14
+ module Hermeneutics
15
+
16
+ NAME = "hermeneutics"
17
+ VERSION = "1.8".freeze
18
+ SUMMARY = "CGI and mail handling"
19
+
20
+ DESCRIPTION = <<~EOT
21
+ This library provides classes for generating and parsing mail, HTML
22
+ and CSS. Further, it is a CGI library.
23
+ EOT
24
+
25
+ COPYRIGHT = "(C) 2013-2020 Bertram Scharpf"
26
+ LICENSE = "BSD-2-Clause"
27
+ AUTHORS = [ "Bertram Scharpf"]
28
+ MAIL = "<software@bertram-scharpf.de>"
29
+ HOMEPAGE = "http://www.bertram-scharpf.de"
30
+
31
+ end
32
+
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hermeneutics
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.8'
5
+ platform: ruby
6
+ authors:
7
+ - Bertram Scharpf
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: supplement
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
27
+ description: |
28
+ This library provides classes for generating and parsing mail, HTML
29
+ and CSS. Further, it is a CGI library.
30
+ email: "<software@bertram-scharpf.de>"
31
+ executables:
32
+ - hermesmail
33
+ extensions: []
34
+ extra_rdoc_files:
35
+ - LICENSE
36
+ files:
37
+ - LICENSE
38
+ - bin/hermesmail
39
+ - etc/exim.conf
40
+ - lib/hermeneutics/addrs.rb
41
+ - lib/hermeneutics/boxes.rb
42
+ - lib/hermeneutics/cgi.rb
43
+ - lib/hermeneutics/cli/pop.rb
44
+ - lib/hermeneutics/color.rb
45
+ - lib/hermeneutics/contents.rb
46
+ - lib/hermeneutics/css.rb
47
+ - lib/hermeneutics/escape.rb
48
+ - lib/hermeneutics/html.rb
49
+ - lib/hermeneutics/mail.rb
50
+ - lib/hermeneutics/message.rb
51
+ - lib/hermeneutics/tags.rb
52
+ - lib/hermeneutics/transports.rb
53
+ - lib/hermeneutics/types.rb
54
+ - lib/hermeneutics/version.rb
55
+ homepage: http://www.bertram-scharpf.de
56
+ licenses:
57
+ - BSD-2-Clause
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options:
61
+ - "--charset"
62
+ - utf-8
63
+ - "--main"
64
+ - lib/hermeneutics/version.rb
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements:
78
+ - Just Ruby
79
+ rubygems_version: 3.0.6
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: CGI and mail handling
83
+ test_files: []