tmail 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/LICENSE +21 -0
  2. data/README +157 -0
  3. data/bat/changelog +19 -0
  4. data/bat/clobber/package +10 -0
  5. data/bat/compile +42 -0
  6. data/bat/config.yaml +8 -0
  7. data/bat/prepare +8 -0
  8. data/bat/publish +51 -0
  9. data/bat/rdoc +42 -0
  10. data/bat/release +12 -0
  11. data/bat/setup +1616 -0
  12. data/bat/stats +138 -0
  13. data/bat/tag +25 -0
  14. data/bat/test +25 -0
  15. data/ext/tmail/Makefile +25 -0
  16. data/ext/tmail/base64/MANIFEST +4 -0
  17. data/ext/tmail/base64/base64.c +264 -0
  18. data/ext/tmail/base64/depend +1 -0
  19. data/ext/tmail/base64/extconf.rb +38 -0
  20. data/ext/tmail/scanner_c/MANIFEST +4 -0
  21. data/ext/tmail/scanner_c/depend +1 -0
  22. data/ext/tmail/scanner_c/extconf.rb +38 -0
  23. data/ext/tmail/scanner_c/scanner_c.c +582 -0
  24. data/lib/tmail.rb +4 -0
  25. data/lib/tmail/Makefile +19 -0
  26. data/lib/tmail/address.rb +245 -0
  27. data/lib/tmail/attachments.rb +47 -0
  28. data/lib/tmail/base64.rb +75 -0
  29. data/lib/tmail/compat.rb +39 -0
  30. data/lib/tmail/config.rb +71 -0
  31. data/lib/tmail/core_extensions.rb +67 -0
  32. data/lib/tmail/encode.rb +524 -0
  33. data/lib/tmail/header.rb +931 -0
  34. data/lib/tmail/index.rb +8 -0
  35. data/lib/tmail/interface.rb +540 -0
  36. data/lib/tmail/loader.rb +1 -0
  37. data/lib/tmail/mail.rb +507 -0
  38. data/lib/tmail/mailbox.rb +435 -0
  39. data/lib/tmail/mbox.rb +1 -0
  40. data/lib/tmail/net.rb +282 -0
  41. data/lib/tmail/obsolete.rb +137 -0
  42. data/lib/tmail/parser.rb +1475 -0
  43. data/lib/tmail/parser.y +381 -0
  44. data/lib/tmail/port.rb +379 -0
  45. data/lib/tmail/quoting.rb +142 -0
  46. data/lib/tmail/require_arch.rb +56 -0
  47. data/lib/tmail/scanner.rb +44 -0
  48. data/lib/tmail/scanner_r.rb +263 -0
  49. data/lib/tmail/stringio.rb +279 -0
  50. data/lib/tmail/tmail.rb +1 -0
  51. data/lib/tmail/utils.rb +281 -0
  52. data/lib/tmail/version.rb +38 -0
  53. data/meta/icli.yaml +16 -0
  54. data/meta/tmail-1.1.1.roll +24 -0
  55. data/sample/data/multipart +23 -0
  56. data/sample/data/normal +29 -0
  57. data/sample/data/sendtest +5 -0
  58. data/sample/data/simple +14 -0
  59. data/sample/data/test +27 -0
  60. data/sample/extract-attachements.rb +33 -0
  61. data/sample/from-check.rb +26 -0
  62. data/sample/multipart.rb +26 -0
  63. data/sample/parse-bench.rb +68 -0
  64. data/sample/parse-test.rb +19 -0
  65. data/sample/sendmail.rb +94 -0
  66. data/test/extctrl.rb +6 -0
  67. data/test/fixtures/raw_base64_decoded_string +0 -0
  68. data/test/fixtures/raw_base64_email +83 -0
  69. data/test/fixtures/raw_base64_encoded_string +1 -0
  70. data/test/fixtures/raw_email +14 -0
  71. data/test/fixtures/raw_email10 +20 -0
  72. data/test/fixtures/raw_email11 +34 -0
  73. data/test/fixtures/raw_email12 +32 -0
  74. data/test/fixtures/raw_email13 +29 -0
  75. data/test/fixtures/raw_email2 +114 -0
  76. data/test/fixtures/raw_email3 +70 -0
  77. data/test/fixtures/raw_email4 +59 -0
  78. data/test/fixtures/raw_email5 +19 -0
  79. data/test/fixtures/raw_email6 +20 -0
  80. data/test/fixtures/raw_email7 +66 -0
  81. data/test/fixtures/raw_email8 +47 -0
  82. data/test/fixtures/raw_email9 +28 -0
  83. data/test/fixtures/raw_email_quoted_with_0d0a +14 -0
  84. data/test/fixtures/raw_email_simple +11 -0
  85. data/test/fixtures/raw_email_with_illegal_boundary +58 -0
  86. data/test/fixtures/raw_email_with_multipart_mixed_quoted_boundary +50 -0
  87. data/test/fixtures/raw_email_with_nested_attachment +100 -0
  88. data/test/fixtures/raw_email_with_partially_quoted_subject +14 -0
  89. data/test/fixtures/raw_email_with_quoted_illegal_boundary +58 -0
  90. data/test/kcode.rb +14 -0
  91. data/test/test_address.rb +1128 -0
  92. data/test/test_attachments.rb +35 -0
  93. data/test/test_base64.rb +63 -0
  94. data/test/test_encode.rb +77 -0
  95. data/test/test_header.rb +885 -0
  96. data/test/test_helper.rb +2 -0
  97. data/test/test_mail.rb +623 -0
  98. data/test/test_mbox.rb +126 -0
  99. data/test/test_port.rb +430 -0
  100. data/test/test_scanner.rb +209 -0
  101. data/test/test_utils.rb +37 -0
  102. metadata +205 -0
@@ -0,0 +1,209 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+ require 'tmail/scanner'
3
+ require 'test/unit'
4
+ require 'extctrl'
5
+
6
+ class ScannerTester < Test::Unit::TestCase
7
+ DEBUG = false
8
+
9
+ def do_test( scantype, str, ok, cmtok )
10
+ scanner = TMail::Scanner.new( str, scantype, comments = [] )
11
+ scanner.debug = DEBUG
12
+
13
+ idx = 0
14
+ scanner.scan do |sym, val|
15
+ if sym then
16
+ assert_equal ok.shift, [sym, val], "index=#{idx}"
17
+ else
18
+ assert_equal [false, '$'], [sym, val], "$end (index=#{idx})"
19
+ end
20
+ idx += 1
21
+ end
22
+ assert_equal [], ok
23
+
24
+ comments.each_with_index do |val, i|
25
+ assert_equal cmtok.shift, val, "index=#{i}"
26
+ end
27
+ end
28
+
29
+ def test_atommode
30
+ do_test :ADDRESS,
31
+ 'Capital CAPITAL word from id by with a0000',
32
+ [
33
+ [:ATOM, 'Capital'],
34
+ [:ATOM, 'CAPITAL'],
35
+ [:ATOM, 'word'],
36
+ [:ATOM, 'from'],
37
+ [:ATOM, 'id'],
38
+ [:ATOM, 'by'],
39
+ [:ATOM, 'with'],
40
+ [:ATOM, 'a0000']
41
+ ],
42
+ []
43
+
44
+ do_test :ADDRESS,
45
+ '(comment) (nested (comment) (again)) (a(b(c(d(e)))))',
46
+ [
47
+ ],
48
+ [
49
+ 'comment',
50
+ 'nested (comment) (again)',
51
+ 'a(b(c(d(e))))'
52
+ ]
53
+
54
+ do_test :ADDRESS,
55
+ '=?iso-2022-jp?B?axaxax?=',
56
+ [
57
+ [:ATOM, '=?iso-2022-jp?B?axaxax?=']
58
+ ],
59
+ []
60
+
61
+ word = 'abcdefghijklmnopqrstuvwxyz' +
62
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
63
+ '0123456789' +
64
+ %q[_#!$%&`'*+-{|}~^/=?]
65
+ do_test :ADDRESS, word,
66
+ [
67
+ [:ATOM, word]
68
+ ],
69
+ []
70
+
71
+ do_test :ADDRESS,
72
+ " \t\t\r\n \n\r\n \r \n atom",
73
+ [
74
+ [:ATOM, 'atom']
75
+ ],
76
+ []
77
+ end
78
+
79
+ def test_tokenmode
80
+ do_test :CTYPE,
81
+ 'text/html; charset=iso-2022-jp',
82
+ [
83
+ [:TOKEN, 'text'],
84
+ ['/' , '/'],
85
+ [:TOKEN, 'html'],
86
+ [';' , ';'],
87
+ [:TOKEN, 'charset'],
88
+ ['=' , '='],
89
+ [:TOKEN, 'iso-2022-jp']
90
+ ],
91
+ []
92
+
93
+ do_test :CTYPE,
94
+ 'Text/Plain; Charset=ISO-2022-JP',
95
+ [
96
+ [:TOKEN, 'Text'],
97
+ ['/' , '/'],
98
+ [:TOKEN, 'Plain'],
99
+ [';' , ';'],
100
+ [:TOKEN, 'Charset'],
101
+ ['=' , '='],
102
+ [:TOKEN, 'ISO-2022-JP'],
103
+ ],
104
+ []
105
+
106
+ do_test :CTYPE,
107
+ 'm_m/s_s; k_k=v_v',
108
+ [
109
+ [:TOKEN, 'm_m'],
110
+ ['/' , '/'],
111
+ [:TOKEN, 's_s'],
112
+ [';' , ';'],
113
+ [:TOKEN, 'k_k'],
114
+ ['=' , '='],
115
+ [:TOKEN, 'v_v'],
116
+ ],
117
+ []
118
+
119
+ word = 'abcdefghijklmnopqrstuvwxyz' +
120
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
121
+ '0123456789' +
122
+ %q[_#!$%&`'*+-{|}~^.]
123
+ do_test :CTYPE, word,
124
+ [
125
+ [:TOKEN, word]
126
+ ],
127
+ []
128
+ end
129
+
130
+ def test_received
131
+ do_test :RECEIVED,
132
+ 'from From by By via Via with With id Id for For',
133
+ [
134
+ [:FROM, 'from'],
135
+ [:FROM, 'From'],
136
+ [:BY, 'by'],
137
+ [:BY, 'By'],
138
+ [:VIA, 'via'],
139
+ [:VIA, 'Via'],
140
+ [:WITH, 'with'],
141
+ [:WITH, 'With'],
142
+ [:ID, 'id'],
143
+ [:ID, 'Id'],
144
+ [:FOR, 'for'],
145
+ [:FOR, 'For']
146
+ ],
147
+ []
148
+
149
+ str = <<EOS
150
+ from hoyogw.netlab.co.jp (daemon@hoyogw.netlab.co.jp [202.218.249.220])
151
+ by serv1.u-netsurf.ne.jp (8.8.8/3.6W-2.66(99/03/09))
152
+ with ESMTP id RAA10692 for <aamine@dp.u-netsurf.ne.jp>;
153
+ Thu, 18 Mar 1999 17:35:23 +0900 (JST)
154
+ EOS
155
+ ok = [
156
+ [ :FROM , 'from' ],
157
+ [ :ATOM , 'hoyogw' ],
158
+ [ '.' , '.' ],
159
+ [ :ATOM , 'netlab' ],
160
+ [ '.' , '.' ],
161
+ [ :ATOM , 'co' ],
162
+ [ '.' , '.' ],
163
+ [ :ATOM , 'jp' ],
164
+ [ :BY , 'by' ],
165
+ [ :ATOM , 'serv1' ],
166
+ [ '.' , '.' ],
167
+ [ :ATOM , 'u-netsurf' ],
168
+ [ '.' , '.' ],
169
+ [ :ATOM , 'ne' ],
170
+ [ '.' , '.' ],
171
+ [ :ATOM , 'jp' ],
172
+ [ :WITH , 'with' ],
173
+ [ :ATOM , 'ESMTP' ],
174
+ [ :ID , 'id' ],
175
+ [ :ATOM , 'RAA10692' ],
176
+ [ :FOR , 'for' ],
177
+ [ '<' , '<' ],
178
+ [ :ATOM , 'aamine' ],
179
+ [ '@' , '@' ],
180
+ [ :ATOM , 'dp' ],
181
+ [ '.' , '.' ],
182
+ [ :ATOM , 'u-netsurf' ],
183
+ [ '.' , '.' ],
184
+ [ :ATOM , 'ne' ],
185
+ [ '.' , '.' ],
186
+ [ :ATOM , 'jp' ],
187
+ [ '>' , '>' ],
188
+ [ ';' , ';' ],
189
+ [ :ATOM , 'Thu' ],
190
+ [ ',' , ',' ],
191
+ [ :DIGIT, '18' ],
192
+ [ :ATOM , 'Mar' ],
193
+ [ :DIGIT, '1999' ],
194
+ [ :DIGIT, '17' ],
195
+ [ ':' , ':' ],
196
+ [ :DIGIT, '35' ],
197
+ [ ':' , ':' ],
198
+ [ :DIGIT, '23' ],
199
+ [ :ATOM , '+0900' ]
200
+ ]
201
+ cmtok = [
202
+ 'daemon@hoyogw.netlab.co.jp [202.218.249.220]',
203
+ '8.8.8/3.6W-2.66(99/03/09)',
204
+ 'JST'
205
+ ]
206
+
207
+ do_test :RECEIVED, str, ok, cmtok
208
+ end
209
+ end
@@ -0,0 +1,37 @@
1
+ require 'tmail'
2
+ require 'tmail/utils'
3
+ require 'test/unit'
4
+ require 'test_helper'
5
+
6
+ class TestUtils < Test::Unit::TestCase
7
+
8
+ include TMail::TextUtils
9
+
10
+ def _test_new_boundary
11
+ a = new_boundary()
12
+ b = new_boundary()
13
+ c = new_boundary()
14
+ assert_instance_of String, a
15
+ assert_instance_of String, b
16
+ assert_instance_of String, c
17
+ assert(a != b)
18
+ assert(b != c)
19
+ assert(c != a)
20
+ end
21
+
22
+ def test_unquote
23
+ mail = TMail::Mail.new
24
+ assert_equal('Hello', mail.unquote('"Hello"'))
25
+ end
26
+
27
+ def test_unquote_without_quotes
28
+ mail = TMail::Mail.new
29
+ assert_equal('Hello', mail.unquote('Hello'))
30
+ end
31
+
32
+ def test_unquote_with_nil
33
+ mail = TMail::Mail.new
34
+ assert_equal(nil, mail.unquote(nil))
35
+ end
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,205 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4.6
3
+ specification_version: 2
4
+ name: tmail
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.1.1
7
+ date: 2007-11-07 00:00:00 -05:00
8
+ summary: Ruby Mail Handler
9
+ require_paths:
10
+ - lib
11
+ email: tmail-talk@rubyforge.org
12
+ homepage:
13
+ rubyforge_project:
14
+ description: TMail is a Ruby-based mail handler. It allows you to compose stadards compliant emails in a very Ruby-way.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc:
19
+ required_ruby_version: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ required_rubygems_version: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: "0"
30
+ version:
31
+ platform: ruby
32
+ signing_key:
33
+ cert_chain: []
34
+
35
+ post_install_message:
36
+ extensions_fallback:
37
+ authors:
38
+ -
39
+ files:
40
+ - LICENSE
41
+ - README
42
+ - bat
43
+ - bat/changelog
44
+ - bat/clobber
45
+ - bat/clobber/package
46
+ - bat/compile
47
+ - bat/config.yaml
48
+ - bat/prepare
49
+ - bat/publish
50
+ - bat/rdoc
51
+ - bat/release
52
+ - bat/setup
53
+ - bat/stats
54
+ - bat/tag
55
+ - bat/test
56
+ - ext
57
+ - ext/tmail
58
+ - ext/tmail/Makefile
59
+ - ext/tmail/base64
60
+ - ext/tmail/base64/MANIFEST
61
+ - ext/tmail/base64/base64.c
62
+ - ext/tmail/base64/depend
63
+ - ext/tmail/base64/extconf.rb
64
+ - ext/tmail/scanner_c
65
+ - ext/tmail/scanner_c/MANIFEST
66
+ - ext/tmail/scanner_c/depend
67
+ - ext/tmail/scanner_c/extconf.rb
68
+ - ext/tmail/scanner_c/scanner_c.c
69
+ - lib
70
+ - lib/tmail
71
+ - lib/tmail/Makefile
72
+ - lib/tmail/address.rb
73
+ - lib/tmail/attachments.rb
74
+ - lib/tmail/base64.rb
75
+ - lib/tmail/compat.rb
76
+ - lib/tmail/config.rb
77
+ - lib/tmail/core_extensions.rb
78
+ - lib/tmail/encode.rb
79
+ - lib/tmail/header.rb
80
+ - lib/tmail/index.rb
81
+ - lib/tmail/interface.rb
82
+ - lib/tmail/loader.rb
83
+ - lib/tmail/mail.rb
84
+ - lib/tmail/mailbox.rb
85
+ - lib/tmail/mbox.rb
86
+ - lib/tmail/mswin32
87
+ - lib/tmail/net.rb
88
+ - lib/tmail/obsolete.rb
89
+ - lib/tmail/parser.rb
90
+ - lib/tmail/parser.y
91
+ - lib/tmail/port.rb
92
+ - lib/tmail/quoting.rb
93
+ - lib/tmail/require_arch.rb
94
+ - lib/tmail/scanner.rb
95
+ - lib/tmail/scanner_r.rb
96
+ - lib/tmail/stringio.rb
97
+ - lib/tmail/tmail.rb
98
+ - lib/tmail/utils.rb
99
+ - lib/tmail/version.rb
100
+ - lib/tmail.rb
101
+ - meta
102
+ - meta/icli.yaml
103
+ - meta/tmail-1.1.1.roll
104
+ - sample
105
+ - sample/data
106
+ - sample/data/multipart
107
+ - sample/data/normal
108
+ - sample/data/sendtest
109
+ - sample/data/simple
110
+ - sample/data/test
111
+ - sample/extract-attachements.rb
112
+ - sample/from-check.rb
113
+ - sample/multipart.rb
114
+ - sample/parse-bench.rb
115
+ - sample/parse-test.rb
116
+ - sample/sendmail.rb
117
+ - test
118
+ - test/extctrl.rb
119
+ - test/fixtures
120
+ - test/fixtures/raw_base64_decoded_string
121
+ - test/fixtures/raw_base64_email
122
+ - test/fixtures/raw_base64_encoded_string
123
+ - test/fixtures/raw_email
124
+ - test/fixtures/raw_email10
125
+ - test/fixtures/raw_email11
126
+ - test/fixtures/raw_email12
127
+ - test/fixtures/raw_email13
128
+ - test/fixtures/raw_email2
129
+ - test/fixtures/raw_email3
130
+ - test/fixtures/raw_email4
131
+ - test/fixtures/raw_email5
132
+ - test/fixtures/raw_email6
133
+ - test/fixtures/raw_email7
134
+ - test/fixtures/raw_email8
135
+ - test/fixtures/raw_email9
136
+ - test/fixtures/raw_email_quoted_with_0d0a
137
+ - test/fixtures/raw_email_simple
138
+ - test/fixtures/raw_email_with_illegal_boundary
139
+ - test/fixtures/raw_email_with_multipart_mixed_quoted_boundary
140
+ - test/fixtures/raw_email_with_nested_attachment
141
+ - test/fixtures/raw_email_with_partially_quoted_subject
142
+ - test/fixtures/raw_email_with_quoted_illegal_boundary
143
+ - test/kcode.rb
144
+ - test/test_address.rb
145
+ - test/test_attachments.rb
146
+ - test/test_base64.rb
147
+ - test/test_encode.rb
148
+ - test/test_header.rb
149
+ - test/test_helper.rb
150
+ - test/test_mail.rb
151
+ - test/test_mbox.rb
152
+ - test/test_port.rb
153
+ - test/test_scanner.rb
154
+ - test/test_utils.rb
155
+ test_files:
156
+ - test/extctrl.rb
157
+ - test/fixtures
158
+ - test/fixtures/raw_base64_decoded_string
159
+ - test/fixtures/raw_base64_email
160
+ - test/fixtures/raw_base64_encoded_string
161
+ - test/fixtures/raw_email
162
+ - test/fixtures/raw_email10
163
+ - test/fixtures/raw_email11
164
+ - test/fixtures/raw_email12
165
+ - test/fixtures/raw_email13
166
+ - test/fixtures/raw_email2
167
+ - test/fixtures/raw_email3
168
+ - test/fixtures/raw_email4
169
+ - test/fixtures/raw_email5
170
+ - test/fixtures/raw_email6
171
+ - test/fixtures/raw_email7
172
+ - test/fixtures/raw_email8
173
+ - test/fixtures/raw_email9
174
+ - test/fixtures/raw_email_quoted_with_0d0a
175
+ - test/fixtures/raw_email_simple
176
+ - test/fixtures/raw_email_with_illegal_boundary
177
+ - test/fixtures/raw_email_with_multipart_mixed_quoted_boundary
178
+ - test/fixtures/raw_email_with_nested_attachment
179
+ - test/fixtures/raw_email_with_partially_quoted_subject
180
+ - test/fixtures/raw_email_with_quoted_illegal_boundary
181
+ - test/kcode.rb
182
+ - test/test_address.rb
183
+ - test/test_attachments.rb
184
+ - test/test_base64.rb
185
+ - test/test_encode.rb
186
+ - test/test_header.rb
187
+ - test/test_helper.rb
188
+ - test/test_mail.rb
189
+ - test/test_mbox.rb
190
+ - test/test_port.rb
191
+ - test/test_scanner.rb
192
+ - test/test_utils.rb
193
+ rdoc_options: []
194
+
195
+ extra_rdoc_files: []
196
+
197
+ executables: []
198
+
199
+ extensions:
200
+ - ./ext/tmail/base64/extconf.rb
201
+ - ./ext/tmail/scanner_c/extconf.rb
202
+ requirements: []
203
+
204
+ dependencies: []
205
+