tmail 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data/CHANGES +50 -5
  2. data/MANIFEST +188 -0
  3. data/NOTES +1 -1
  4. data/README +10 -4
  5. data/Rakefile +1 -10
  6. data/lib/tmail.rb +1 -0
  7. data/lib/tmail/Makefile +0 -1
  8. data/lib/tmail/address.rb +190 -17
  9. data/lib/tmail/attachments.rb +1 -1
  10. data/lib/tmail/base64.rb +4 -10
  11. data/lib/tmail/compat.rb +8 -6
  12. data/lib/tmail/config.rb +2 -6
  13. data/lib/tmail/core_extensions.rb +14 -18
  14. data/lib/tmail/encode.rb +47 -12
  15. data/lib/tmail/header.rb +7 -10
  16. data/lib/tmail/index.rb +2 -1
  17. data/lib/tmail/interface.rb +14 -12
  18. data/lib/tmail/loader.rb +2 -0
  19. data/lib/tmail/mail.rb +83 -24
  20. data/lib/tmail/mailbox.rb +70 -10
  21. data/lib/tmail/main.rb +2 -0
  22. data/lib/tmail/mbox.rb +2 -0
  23. data/lib/tmail/net.rb +16 -15
  24. data/lib/tmail/obsolete.rb +7 -12
  25. data/lib/tmail/parser.rb +1 -0
  26. data/lib/tmail/require_arch.rb +2 -0
  27. data/lib/tmail/scanner.rb +2 -1
  28. data/lib/tmail/scanner_r.rb +11 -10
  29. data/lib/tmail/utils.rb +83 -26
  30. data/lib/tmail/version.rb +3 -2
  31. data/log/BugTrackingLog.txt +1208 -0
  32. data/log/{ChangeLog.txt → Changelog-0.txt} +36 -0
  33. data/log/Changelog.txt +534 -0
  34. data/log/Testlog.txt +114 -0
  35. data/log/Todo.txt +0 -2
  36. data/meta/VERSION +1 -0
  37. data/meta/project.yaml +8 -5
  38. data/meta/unixname +1 -0
  39. data/setup.rb +1481 -0
  40. data/site/contributing/index.html +183 -0
  41. data/site/css/clean.css +27 -0
  42. data/site/css/layout.css +31 -0
  43. data/site/css/style.css +60 -0
  44. data/site/download/index.html +61 -0
  45. data/site/img/envelope.jpg +0 -0
  46. data/site/img/mailman.gif +0 -0
  47. data/site/img/stamp-sm.jpg +0 -0
  48. data/site/img/stamp.jpg +0 -0
  49. data/site/img/stampborder.jpg +0 -0
  50. data/site/img/tfire.jpg +0 -0
  51. data/site/img/tmail.png +0 -0
  52. data/site/index.html +270 -0
  53. data/site/js/jquery.js +31 -0
  54. data/site/log/Changelog.xsl +33 -0
  55. data/site/log/changelog.xml +1677 -0
  56. data/site/outdated/BUGS +3 -0
  57. data/site/outdated/DEPENDS +1 -0
  58. data/site/outdated/Incompatibilities +89 -0
  59. data/site/outdated/Incompatibilities.ja +102 -0
  60. data/site/outdated/NEWS +9 -0
  61. data/site/outdated/README.ja +73 -0
  62. data/site/outdated/doc.ja/address.html +275 -0
  63. data/site/outdated/doc.ja/basics.html +405 -0
  64. data/site/outdated/doc.ja/config.html +49 -0
  65. data/site/outdated/doc.ja/details.html +146 -0
  66. data/site/outdated/doc.ja/index.html +39 -0
  67. data/site/outdated/doc.ja/mail.html +793 -0
  68. data/site/outdated/doc.ja/mailbox.html +265 -0
  69. data/site/outdated/doc.ja/port.html +95 -0
  70. data/site/outdated/doc.ja/tmail.html +58 -0
  71. data/site/outdated/doc.ja/usage.html +202 -0
  72. data/site/outdated/rdd/address.rrd.m +229 -0
  73. data/site/outdated/rdd/basics.rd.m +275 -0
  74. data/site/outdated/rdd/config.rrd.m +26 -0
  75. data/site/outdated/rdd/details.rd.m +117 -0
  76. data/site/outdated/rdd/index.rhtml.m +54 -0
  77. data/site/outdated/rdd/mail.rrd.m +701 -0
  78. data/site/outdated/rdd/mailbox.rrd.m +228 -0
  79. data/site/outdated/rdd/port.rrd.m +69 -0
  80. data/site/outdated/rdd/tmail.rrd.m +33 -0
  81. data/site/outdated/rdd/usage.rd.m +247 -0
  82. data/site/quickstart/index.html +69 -0
  83. data/site/quickstart/quickstart.html +52 -0
  84. data/site/quickstart/usage.html +193 -0
  85. data/site/reference/address.html +247 -0
  86. data/site/reference/config.html +30 -0
  87. data/site/reference/index.html +101 -0
  88. data/site/reference/mail.html +726 -0
  89. data/site/reference/mailbox.html +245 -0
  90. data/site/reference/port.html +75 -0
  91. data/site/reference/tmail.html +35 -0
  92. data/test/fixtures/mailbox +405 -4
  93. data/test/fixtures/raw_email_multiple_from +30 -0
  94. data/test/kcode.rb +2 -2
  95. data/test/temp_test_one.rb +46 -0
  96. data/test/test_address.rb +77 -38
  97. data/test/test_encode.rb +0 -2
  98. data/test/test_header.rb +47 -24
  99. data/test/test_mail.rb +52 -9
  100. data/test/test_mbox.rb +28 -0
  101. data/test/test_port.rb +33 -27
  102. data/test/test_quote.rb +35 -8
  103. data/work/script/make +26 -0
  104. data/work/script/rdoc +39 -0
  105. data/{script → work/script}/setup +0 -0
  106. data/work/script/test +30 -0
  107. metadata +249 -184
  108. data/log/History.txt +0 -40
  109. data/meta/config.yaml +0 -8
  110. data/meta/icli.yaml +0 -16
  111. data/meta/tmail.roll +0 -3
  112. data/script/changelog +0 -19
  113. data/script/clobber/distclean +0 -8
  114. data/script/clobber/package +0 -10
  115. data/script/compile +0 -32
  116. data/script/pack/gem +0 -93
  117. data/script/pack/tgz +0 -41
  118. data/script/pack/zip +0 -41
  119. data/script/prepare +0 -15
  120. data/script/publish +0 -51
  121. data/script/rdoc +0 -42
  122. data/script/release +0 -10
  123. data/script/stamp +0 -33
  124. data/script/stats +0 -138
  125. data/script/tag +0 -25
  126. data/script/test +0 -36
@@ -150,9 +150,78 @@ module TMail
150
150
 
151
151
  class UNIXMbox
152
152
 
153
+ class << self
154
+ alias newobj new
155
+ end
156
+
157
+ # Creates a new mailbox object that you can iterate through to collect the
158
+ # emails from with "each_port".
159
+ #
160
+ # You need to pass it a filename of a unix mailbox format file, the format of this
161
+ # file can be researched at this page at {wikipedia}[link:http://en.wikipedia.org/wiki/Mbox]
162
+ #
163
+ # ==== Parameters
164
+ #
165
+ # +filename+: The filename of the mailbox you want to open
166
+ #
167
+ # +tmpdir+: Can be set to override TMail using the system environment's temp dir. TMail will first
168
+ # use the temp dir specified by you (if any) or then the temp dir specified in the Environment's TEMP
169
+ # value then the value in the Environment's TMP value or failing all of the above, '/tmp'
170
+ #
171
+ # +readonly+: If set to false, each email you take from the mail box will be removed from the mailbox.
172
+ # default is *false* - ie, it *WILL* truncate your mailbox file to ZERO once it has read the emails out.
173
+ #
174
+ # ==== Options:
175
+ #
176
+ # None
177
+ #
178
+ # ==== Examples:
179
+ #
180
+ # # First show using readonly true:
181
+ #
182
+ # require 'ftools'
183
+ # File.size("../test/fixtures/mailbox")
184
+ # #=> 20426
185
+ #
186
+ # mailbox = TMail::UNIXMbox.new("../test/fixtures/mailbox", nil, true)
187
+ # #=> #<TMail::UNIXMbox:0x14a2aa8 @readonly=true.....>
188
+ #
189
+ # mailbox.each_port do |port|
190
+ # mail = TMail::Mail.new(port)
191
+ # puts mail.subject
192
+ # end
193
+ # #Testing mailbox 1
194
+ # #Testing mailbox 2
195
+ # #Testing mailbox 3
196
+ # #Testing mailbox 4
197
+ # require 'ftools'
198
+ # File.size?("../test/fixtures/mailbox")
199
+ # #=> 20426
200
+ #
201
+ # # Now show with readonly set to the default false
202
+ #
203
+ # mailbox = TMail::UNIXMbox.new("../test/fixtures/mailbox")
204
+ # #=> #<TMail::UNIXMbox:0x14a2aa8 @readonly=false.....>
205
+ #
206
+ # mailbox.each_port do |port|
207
+ # mail = TMail::Mail.new(port)
208
+ # puts mail.subject
209
+ # end
210
+ # #Testing mailbox 1
211
+ # #Testing mailbox 2
212
+ # #Testing mailbox 3
213
+ # #Testing mailbox 4
214
+ #
215
+ # File.size?("../test/fixtures/mailbox")
216
+ # #=> nil
217
+ def UNIXMbox.new( filename, tmpdir = nil, readonly = false )
218
+ tmpdir = ENV['TEMP'] || ENV['TMP'] || '/tmp'
219
+ newobj(filename, "#{tmpdir}/ruby_tmail_#{$$}_#{rand()}", readonly, false)
220
+ end
221
+
153
222
  def UNIXMbox.lock( fname )
154
223
  begin
155
- f = File.open(fname)
224
+ f = File.open(fname, 'r+')
156
225
  f.flock File::LOCK_EX
157
226
  yield f
158
227
  ensure
@@ -161,15 +230,6 @@ module TMail
161
230
  end
162
231
  end
163
232
 
164
- class << self
165
- alias newobj new
166
- end
167
-
168
- def UNIXMbox.new( fname, tmpdir = nil, readonly = false )
169
- tmpdir = ENV['TEMP'] || ENV['TMP'] || '/tmp'
170
- newobj(fname, "#{tmpdir}/ruby_tmail_#{$$}_#{rand()}", readonly, false)
171
- end
172
-
173
233
  def UNIXMbox.static_new( fname, dir, readonly = false )
174
234
  newobj(fname, dir, readonly, true)
175
235
  end
@@ -1,4 +1,6 @@
1
+ #:stopdoc:
1
2
  require 'tmail/version'
2
3
  require 'tmail/mail'
3
4
  require 'tmail/mailbox'
4
5
  require 'tmail/core_extensions'
6
+ #:startdoc:
@@ -1 +1,3 @@
1
+ #:stopdoc:
1
2
  require 'tmail/mailbox'
3
+ #:startdoc:
@@ -1,8 +1,3 @@
1
- =begin rdoc
2
-
3
- = Net provides SMTP wrapping
4
-
5
- =end
6
1
  #--
7
2
  # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
8
3
  #
@@ -29,13 +24,14 @@
29
24
  # with permission of Minero Aoki.
30
25
  #++
31
26
 
27
+ #:stopdoc:
32
28
  require 'nkf'
33
-
29
+ #:startdoc:
34
30
 
35
31
  module TMail
36
32
 
37
33
  class Mail
38
-
34
+
39
35
  def send_to( smtp )
40
36
  do_send_to(smtp) do
41
37
  ready_to_send
@@ -131,7 +127,7 @@ module TMail
131
127
 
132
128
  end
133
129
 
134
-
130
+ #:stopdoc:
135
131
  class DeleteFields
136
132
 
137
133
  NOSEND_FIELDS = %w(
@@ -155,8 +151,9 @@ module TMail
155
151
  end
156
152
 
157
153
  end
154
+ #:startdoc:
158
155
 
159
-
156
+ #:stopdoc:
160
157
  class AddMessageId
161
158
 
162
159
  def initialize( fqdn = nil )
@@ -170,8 +167,9 @@ module TMail
170
167
  end
171
168
 
172
169
  end
170
+ #:startdoc:
173
171
 
174
-
172
+ #:stopdoc:
175
173
  class AddDate
176
174
 
177
175
  def exec( mail )
@@ -179,8 +177,9 @@ module TMail
179
177
  end
180
178
 
181
179
  end
180
+ #:startdoc:
182
181
 
183
-
182
+ #:stopdoc:
184
183
  class MimeEncodeAuto
185
184
 
186
185
  def initialize( s = nil, m = nil )
@@ -198,8 +197,9 @@ module TMail
198
197
  end
199
198
 
200
199
  end
201
-
200
+ #:startdoc:
202
201
 
202
+ #:stopdoc:
203
203
  class MimeEncodeSingle
204
204
 
205
205
  def exec( mail )
@@ -225,8 +225,9 @@ module TMail
225
225
  end
226
226
 
227
227
  end
228
-
229
-
228
+ #:startdoc:
229
+
230
+ #:stopdoc:
230
231
  class MimeEncodeMulti
231
232
 
232
233
  def exec( mail, top = true )
@@ -243,5 +244,5 @@ module TMail
243
244
  end
244
245
 
245
246
  end
246
-
247
+ #:startdoc:
247
248
  end # module TMail
@@ -2,6 +2,9 @@
2
2
 
3
3
  = Obsolete methods that are depriciated
4
4
 
5
+ If you really want to see them, go to lib/tmail/obsolete.rb and view to your
6
+ heart's content.
7
+
5
8
  =end
6
9
  #--
7
10
  # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
@@ -28,10 +31,9 @@
28
31
  # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
29
32
  # with permission of Minero Aoki.
30
33
  #++
34
+ #:stopdoc:
35
+ module TMail #:nodoc:
31
36
 
32
- module TMail
33
-
34
- # mail.rb
35
37
  class Mail
36
38
  alias include? key?
37
39
  alias has_key? key?
@@ -51,8 +53,6 @@ module TMail
51
53
  alias has_value? value?
52
54
  end
53
55
 
54
-
55
- # facade.rb
56
56
  class Mail
57
57
  def from_addr( default = nil )
58
58
  addr, = from_addrs(nil)
@@ -83,13 +83,11 @@ module TMail
83
83
  alias each_dest each_destination
84
84
  end
85
85
 
86
-
87
- # address.rb
88
86
  class Address
89
87
  alias route routes
90
88
  alias addr spec
91
89
 
92
- def spec=( str )
90
+ def spec=( str )
93
91
  @local, @domain = str.split(/@/,2).map {|s| s.split(/\./) }
94
92
  end
95
93
 
@@ -97,8 +95,6 @@ module TMail
97
95
  alias address= spec=
98
96
  end
99
97
 
100
-
101
- # mbox.rb
102
98
  class MhMailbox
103
99
  alias new_mail new_port
104
100
  alias each_mail each_port
@@ -115,8 +111,6 @@ module TMail
115
111
  alias each_newmail each_new_port
116
112
  end
117
113
 
118
-
119
- # utils.rb
120
114
  extend TextUtils
121
115
 
122
116
  class << self
@@ -135,3 +129,4 @@ module TMail
135
129
  end
136
130
 
137
131
  end # module TMail
132
+ #:startdoc:
@@ -1,3 +1,4 @@
1
+ #:stopdoc:
1
2
  # DO NOT MODIFY!!!!
2
3
  # This file is automatically generated by racc 1.4.5
3
4
  # from racc grammer file "parser.y".
@@ -1,3 +1,4 @@
1
+ #:stopdoc:
1
2
  require 'rbconfig'
2
3
 
3
4
  # Attempts to require anative extension.
@@ -54,3 +55,4 @@ end
54
55
  # end
55
56
  # end
56
57
  # end
58
+ #:startdoc:
@@ -28,7 +28,7 @@
28
28
  # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
29
29
  # with permission of Minero Aoki.
30
30
  #++
31
-
31
+ #:stopdoc:
32
32
  #require 'tmail/require_arch'
33
33
  require 'tmail/utils'
34
34
  require 'tmail/config'
@@ -46,3 +46,4 @@ module TMail
46
46
  Scanner = TMailScanner
47
47
  end
48
48
  end
49
+ #:stopdoc:
@@ -26,7 +26,7 @@
26
26
  # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
27
27
  # with permission of Minero Aoki.
28
28
  #++
29
-
29
+ #:stopdoc:
30
30
  require 'tmail/config'
31
31
 
32
32
  module TMail
@@ -105,7 +105,7 @@ module TMail
105
105
  @received = (scantype == :RECEIVED)
106
106
  @is_mime_header = MIME_HEADERS[scantype]
107
107
 
108
- atom, token, @quoted_re, @domlit_re, @comment_re = PATTERN_TABLE[$KCODE]
108
+ atom, token, @quoted_re, @domlit_re, @comment_re = PATTERN_TABLE[TMail.KCODE]
109
109
  @word_re = (MIME_HEADERS[scantype] ? token : atom)
110
110
  end
111
111
 
@@ -145,34 +145,34 @@ module TMail
145
145
 
146
146
  if s = readstr(@word_re)
147
147
  if @is_mime_header
148
- yield :TOKEN, s
148
+ yield [:TOKEN, s]
149
149
  else
150
150
  # atom
151
151
  if /\A\d+\z/ === s
152
- yield :DIGIT, s
152
+ yield [:DIGIT, s]
153
153
  elsif @received
154
- yield RECV_TOKEN[s.downcase] || :ATOM, s
154
+ yield [RECV_TOKEN[s.downcase] || :ATOM, s]
155
155
  else
156
- yield :ATOM, s
156
+ yield [:ATOM, s]
157
157
  end
158
158
  end
159
159
 
160
160
  elsif skip(/\A"/)
161
- yield :QUOTED, scan_quoted_word()
161
+ yield [:QUOTED, scan_quoted_word()]
162
162
 
163
163
  elsif skip(/\A\[/)
164
- yield :DOMLIT, scan_domain_literal()
164
+ yield [:DOMLIT, scan_domain_literal()]
165
165
 
166
166
  elsif skip(/\A\(/)
167
167
  @comments.push scan_comment()
168
168
 
169
169
  else
170
170
  c = readchar()
171
- yield c, c
171
+ yield [c, c]
172
172
  end
173
173
  end
174
174
 
175
- yield false, '$'
175
+ yield [false, '$']
176
176
  end
177
177
 
178
178
  def scan_quoted_word
@@ -259,3 +259,4 @@ module TMail
259
259
  end
260
260
 
261
261
  end # module TMail
262
+ #:startdoc:
@@ -1,8 +1,3 @@
1
- =begin rdoc
2
-
3
- = General Purpose TMail Utilities
4
-
5
- =end
6
1
  #--
7
2
  # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
8
3
  #
@@ -29,21 +24,73 @@
29
24
  # with permission of Minero Aoki.
30
25
  #++
31
26
 
27
+ # = TMail - The EMail Swiss Army Knife for Ruby
28
+ #
29
+ # The TMail library provides you with a very complete way to handle and manipulate EMails
30
+ # from within your Ruby programs.
31
+ #
32
+ # Used as the backbone for email handling by the Ruby on Rails and Nitro web frameworks as
33
+ # well as a bunch of other Ruby apps including the Ruby-Talk mailing list to newsgroup email
34
+ # gateway, it is a proven and reliable email handler that won't let you down.
35
+ #
36
+ # Originally created by Minero Aoki, TMail has been recently picked up by Mikel Lindsaar and
37
+ # is being actively maintained. Numerous backlogged bug fixes have been applied as well as
38
+ # Ruby 1.9 compatibility and a swath of documentation to boot.
39
+ #
40
+ # TMail allows you to treat an email totally as an object and allow you to get on with your
41
+ # own programming without having to worry about crafting the perfect email address validation
42
+ # parser, or assembling an email from all it's component parts.
43
+ #
44
+ # TMail handles the most complex part of the email - the header. It generates and parses
45
+ # headers and provides you with instant access to their innards through simple and logically
46
+ # named accessor and setter methods.
47
+ #
48
+ # TMail also provides a wrapper to Net/SMTP as well as Unix Mailbox handling methods to
49
+ # directly read emails from your unix mailbox, parse them and use them.
50
+ #
51
+ # Following is the comprehensive list of methods to access TMail::Mail objects. You can also
52
+ # check out TMail::Mail, TMail::Address and TMail::Headers for other lists.
32
53
  module TMail
33
54
 
55
+ # Provides an exception to throw on errors in Syntax within TMail's parsers
34
56
  class SyntaxError < StandardError; end
35
57
 
36
-
58
+ # Provides a new email boundary to separate parts of the email. This is a random
59
+ # string based off the current time, so should be fairly unique.
60
+ #
61
+ # For Example:
62
+ #
63
+ # TMail.new_boundary
64
+ # #=> "mimepart_47bf656968207_25a8fbb80114"
65
+ # TMail.new_boundary
66
+ # #=> "mimepart_47bf66051de4_25a8fbb80240"
37
67
  def TMail.new_boundary
38
68
  'mimepart_' + random_tag
39
69
  end
40
70
 
71
+ # Provides a new email message ID. You can use this to generate unique email message
72
+ # id's for your email so you can track them.
73
+ #
74
+ # Optionally takes a fully qualified domain name (default to the current hostname
75
+ # returned by Socket.gethostname) that will be appended to the message ID.
76
+ #
77
+ # For Example:
78
+ #
79
+ # email.message_id = TMail.new_message_id
80
+ # #=> "<47bf66845380e_25a8fbb80332@baci.local.tmail>"
81
+ # email.to_s
82
+ # #=> "Message-Id: <47bf668b633f1_25a8fbb80475@baci.local.tmail>\n\n"
83
+ # email.message_id = TMail.new_message_id("lindsaar.net")
84
+ # #=> "<47bf668b633f1_25a8fbb80475@lindsaar.net.tmail>"
85
+ # email.to_s
86
+ # #=> "Message-Id: <47bf668b633f1_25a8fbb80475@lindsaar.net.tmail>\n\n"
41
87
  def TMail.new_message_id( fqdn = nil )
42
88
  fqdn ||= ::Socket.gethostname
43
89
  "<#{random_tag()}@#{fqdn}.tmail>"
44
90
  end
45
91
 
46
- def TMail.random_tag
92
+ #:stopdoc:
93
+ def TMail.random_tag #:nodoc:
47
94
  @uniq += 1
48
95
  t = Time.now
49
96
  sprintf('%x%x_%x%x%d%x',
@@ -54,8 +101,13 @@ module TMail
54
101
 
55
102
  @uniq = 0
56
103
 
104
+ #:startdoc:
105
+
106
+ # Text Utils provides a namespace to define TOKENs, ATOMs, PHRASEs and CONTROL characters that
107
+ # are OK per RFC 2822.
108
+ #
109
+ # It also provides methods you can call to determine if a string is safe
57
110
  module TextUtils
58
- # Defines characters per RFC that are OK for TOKENs, ATOMs, PHRASEs and CONTROL characters.
59
111
 
60
112
  aspecial = '()<>[]:;.\\,"'
61
113
  tspecial = '()<>[];:\\,"/?='
@@ -67,37 +119,37 @@ module TMail
67
119
  TOKEN_UNSAFE = /[#{Regexp.quote tspecial}#{control}#{lwsp}]/n
68
120
  CONTROL_CHAR = /[#{control}]/n
69
121
 
122
+ # Returns true if the string supplied is free from characters not allowed as an ATOM
70
123
  def atom_safe?( str )
71
- # Returns true if the string supplied is free from characters not allowed as an ATOM
72
124
  not ATOM_UNSAFE === str
73
125
  end
74
126
 
127
+ # If the string supplied has ATOM unsafe characters in it, will return the string quoted
128
+ # in double quotes, otherwise returns the string unmodified
75
129
  def quote_atom( str )
76
- # If the string supplied has ATOM unsafe characters in it, will return the string quoted
77
- # in double quotes, otherwise returns the string unmodified
78
130
  (ATOM_UNSAFE === str) ? dquote(str) : str
79
131
  end
80
132
 
133
+ # If the string supplied has PHRASE unsafe characters in it, will return the string quoted
134
+ # in double quotes, otherwise returns the string unmodified
81
135
  def quote_phrase( str )
82
- # If the string supplied has PHRASE unsafe characters in it, will return the string quoted
83
- # in double quotes, otherwise returns the string unmodified
84
136
  (PHRASE_UNSAFE === str) ? dquote(str) : str
85
137
  end
86
138
 
139
+ # Returns true if the string supplied is free from characters not allowed as a TOKEN
87
140
  def token_safe?( str )
88
- # Returns true if the string supplied is free from characters not allowed as a TOKEN
89
141
  not TOKEN_UNSAFE === str
90
142
  end
91
143
 
144
+ # If the string supplied has TOKEN unsafe characters in it, will return the string quoted
145
+ # in double quotes, otherwise returns the string unmodified
92
146
  def quote_token( str )
93
- # If the string supplied has TOKEN unsafe characters in it, will return the string quoted
94
- # in double quotes, otherwise returns the string unmodified
95
147
  (TOKEN_UNSAFE === str) ? dquote(str) : str
96
148
  end
97
149
 
98
- def dquote( str )
99
- # Wraps supplied string in double quotes unless it is already wrapped
100
- # Returns double quoted string
150
+ # Wraps supplied string in double quotes unless it is already wrapped
151
+ # Returns double quoted string
152
+ def dquote( str ) #:nodoc:
101
153
  unless str =~ /^".*?"$/
102
154
  '"' + str.gsub(/["\\]/n) {|s| '\\' + s } + '"'
103
155
  else
@@ -106,12 +158,14 @@ module TMail
106
158
  end
107
159
  private :dquote
108
160
 
161
+ # Unwraps supplied string from inside double quotes
162
+ # Returns unquoted string
109
163
  def unquote( str )
110
- # Unwraps supplied string from inside double quotes
111
- # Returns unquoted string
112
164
  str =~ /^"(.*?)"$/ ? $1 : str
113
165
  end
114
166
 
167
+ # Provides a method to join a domain name by it's parts and also makes it
168
+ # ATOM safe by quoting it as needed
115
169
  def join_domain( arr )
116
170
  arr.map {|i|
117
171
  if /\A\[.*\]\z/ === i
@@ -122,7 +176,7 @@ module TMail
122
176
  }.join('.')
123
177
  end
124
178
 
125
-
179
+ #:stopdoc:
126
180
  ZONESTR_TABLE = {
127
181
  'jst' => 9 * 60,
128
182
  'eet' => 2 * 60,
@@ -168,9 +222,10 @@ module TMail
168
222
  'y' => 12 * 60,
169
223
  'z' => 0 * 60
170
224
  }
225
+ #:startdoc:
171
226
 
227
+ # Takes a time zone string from an EMail and converts it to Unix Time (seconds)
172
228
  def timezone_string_to_unixtime( str )
173
- # Takes a time zone string from an EMail and converts it to Unix Time (seconds)
174
229
  if m = /([\+\-])(\d\d?)(\d\d)/.match(str)
175
230
  sec = (m[2].to_i * 60 + m[3].to_i) * 60
176
231
  m[1] == '-' ? -sec : sec
@@ -181,7 +236,7 @@ module TMail
181
236
  end
182
237
  end
183
238
 
184
-
239
+ #:stopdoc:
185
240
  WDAY = %w( Sun Mon Tue Wed Thu Fri Sat TMailBUG )
186
241
  MONTH = %w( TMailBUG Jan Feb Mar Apr May Jun
187
242
  Jul Aug Sep Oct Nov Dec TMailBUG )
@@ -201,7 +256,7 @@ module TMail
201
256
 
202
257
 
203
258
  MESSAGE_ID = /<[^\@>]+\@[^>\@]+>/
204
-
259
+
205
260
  def message_id?( str )
206
261
  MESSAGE_ID === str
207
262
  end
@@ -239,7 +294,7 @@ module TMail
239
294
  }
240
295
 
241
296
  def to_kcode( str )
242
- flag = NKF_FLAGS[$KCODE] or return str
297
+ flag = NKF_FLAGS[TMail.KCODE] or return str
243
298
  NKF.nkf(flag, str)
244
299
  end
245
300
 
@@ -274,6 +329,8 @@ module TMail
274
329
  end
275
330
  end
276
331
  end
332
+ #:startdoc:
333
+
277
334
 
278
335
  end
279
336