rmail 0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/NEWS +309 -0
  2. data/NOTES +14 -0
  3. data/README +83 -0
  4. data/THANKS +25 -0
  5. data/TODO +112 -0
  6. data/guide/Intro.txt +122 -0
  7. data/guide/MIME.txt +6 -0
  8. data/guide/TableOfContents.txt +13 -0
  9. data/install.rb +1023 -0
  10. data/lib/rmail.rb +50 -0
  11. data/lib/rmail/address.rb +829 -0
  12. data/lib/rmail/header.rb +987 -0
  13. data/lib/rmail/mailbox.rb +62 -0
  14. data/lib/rmail/mailbox/mboxreader.rb +182 -0
  15. data/lib/rmail/message.rb +201 -0
  16. data/lib/rmail/parser.rb +412 -0
  17. data/lib/rmail/parser/multipart.rb +217 -0
  18. data/lib/rmail/parser/pushbackreader.rb +173 -0
  19. data/lib/rmail/serialize.rb +190 -0
  20. data/lib/rmail/utils.rb +59 -0
  21. data/rmail.gemspec +17 -0
  22. data/tests/addrgrammar.txt +113 -0
  23. data/tests/data/mbox.odd +4 -0
  24. data/tests/data/mbox.simple +8 -0
  25. data/tests/data/multipart/data.1 +5 -0
  26. data/tests/data/multipart/data.10 +1 -0
  27. data/tests/data/multipart/data.11 +9 -0
  28. data/tests/data/multipart/data.12 +9 -0
  29. data/tests/data/multipart/data.13 +3 -0
  30. data/tests/data/multipart/data.14 +3 -0
  31. data/tests/data/multipart/data.15 +3 -0
  32. data/tests/data/multipart/data.16 +3 -0
  33. data/tests/data/multipart/data.17 +0 -0
  34. data/tests/data/multipart/data.2 +5 -0
  35. data/tests/data/multipart/data.3 +2 -0
  36. data/tests/data/multipart/data.4 +3 -0
  37. data/tests/data/multipart/data.5 +1 -0
  38. data/tests/data/multipart/data.6 +2 -0
  39. data/tests/data/multipart/data.7 +3 -0
  40. data/tests/data/multipart/data.8 +5 -0
  41. data/tests/data/multipart/data.9 +4 -0
  42. data/tests/data/parser.badmime1 +4 -0
  43. data/tests/data/parser.badmime2 +6 -0
  44. data/tests/data/parser.nested-multipart +75 -0
  45. data/tests/data/parser.nested-simple +12 -0
  46. data/tests/data/parser.nested-simple2 +16 -0
  47. data/tests/data/parser.nested-simple3 +21 -0
  48. data/tests/data/parser.rfc822 +65 -0
  49. data/tests/data/parser.simple-mime +24 -0
  50. data/tests/data/parser/multipart.1 +8 -0
  51. data/tests/data/parser/multipart.10 +4 -0
  52. data/tests/data/parser/multipart.11 +12 -0
  53. data/tests/data/parser/multipart.12 +12 -0
  54. data/tests/data/parser/multipart.13 +6 -0
  55. data/tests/data/parser/multipart.14 +6 -0
  56. data/tests/data/parser/multipart.15 +6 -0
  57. data/tests/data/parser/multipart.16 +6 -0
  58. data/tests/data/parser/multipart.2 +8 -0
  59. data/tests/data/parser/multipart.3 +5 -0
  60. data/tests/data/parser/multipart.4 +6 -0
  61. data/tests/data/parser/multipart.5 +4 -0
  62. data/tests/data/parser/multipart.6 +5 -0
  63. data/tests/data/parser/multipart.7 +6 -0
  64. data/tests/data/parser/multipart.8 +8 -0
  65. data/tests/data/parser/multipart.9 +7 -0
  66. data/tests/data/transparency/absolute.1 +5 -0
  67. data/tests/data/transparency/absolute.2 +1 -0
  68. data/tests/data/transparency/absolute.3 +2 -0
  69. data/tests/data/transparency/absolute.4 +3 -0
  70. data/tests/data/transparency/absolute.5 +4 -0
  71. data/tests/data/transparency/absolute.6 +49 -0
  72. data/tests/data/transparency/message.1 +73 -0
  73. data/tests/data/transparency/message.2 +34 -0
  74. data/tests/data/transparency/message.3 +63 -0
  75. data/tests/data/transparency/message.4 +5 -0
  76. data/tests/data/transparency/message.5 +15 -0
  77. data/tests/data/transparency/message.6 +1185 -0
  78. data/tests/runtests.rb +35 -0
  79. data/tests/testaddress.rb +1192 -0
  80. data/tests/testbase.rb +207 -0
  81. data/tests/testheader.rb +1207 -0
  82. data/tests/testmailbox.rb +47 -0
  83. data/tests/testmboxreader.rb +161 -0
  84. data/tests/testmessage.rb +257 -0
  85. data/tests/testparser.rb +634 -0
  86. data/tests/testparsermultipart.rb +205 -0
  87. data/tests/testpushbackreader.rb +40 -0
  88. data/tests/testserialize.rb +264 -0
  89. data/tests/testtestbase.rb +112 -0
  90. data/tests/testtranspparency.rb +105 -0
  91. metadata +143 -0
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # Copyright (C) 2001, 2002 Matt Armstrong. All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of source code must retain the above copyright notice,
9
+ # this list of conditions and the following disclaimer.
10
+ # 2. Redistributions in binary form must reproduce the above copyright
11
+ # notice, this list of conditions and the following disclaimer in the
12
+ # documentation and/or other materials provided with the distribution.
13
+ # 3. The name of the author may not be used to endorse or promote products
14
+ # derived from this software without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
+ # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19
+ # NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
+ # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ #
27
+
28
+ # Test the TestBase class itself
29
+
30
+ require 'rubyunit'
31
+ require 'tests/testbase.rb'
32
+
33
+ class TestTestBase < TestBase
34
+
35
+ def test_cleandir
36
+ Dir.mkdir("_testdir_")
37
+ Dir.mkdir("_testdir_/testsubdir")
38
+ File.open("_testdir_/testfile", "w") { |file|
39
+ file.puts "some data"
40
+ }
41
+ File.open("_testdir_/testsubdir/testfile", "w") { |file|
42
+ file.puts "some data"
43
+ }
44
+ assert(test(?e, "_testdir_"))
45
+ assert(test(?e, "_testdir_/testsubdir"))
46
+ assert(test(?e, "_testdir_/testsubdir/testfile"))
47
+ assert(test(?e, "_testdir_/testfile"))
48
+ cleandir("_testdir_")
49
+ assert(test(?e, "_testdir_"))
50
+ assert(!test(?e, "_testdir_/testsubdir"))
51
+ assert(!test(?e, "_testdir_/testsubdir/testfile"))
52
+ assert(!test(?e, "_testdir_/testfile"))
53
+ assert_equal(0, Dir.delete('_testdir_'))
54
+ end
55
+
56
+ def test_file_contains
57
+ scratch = scratch_filename("file_contains")
58
+ File.open(scratch, "w") { |f|
59
+ f.puts "contains AAA"
60
+ f.puts "contains BBB"
61
+ }
62
+ assert(file_contains(scratch, /BBB/))
63
+ assert(file_contains(scratch, "AAA"))
64
+ assert(file_contains(scratch, /contains AAA/))
65
+ assert(file_contains(scratch, "contains BBB"))
66
+ assert_equal(false, file_contains(scratch, /contains CCC/))
67
+ assert_equal(false, file_contains(scratch, "contains CCC"))
68
+ end
69
+
70
+ def test_ruby_program
71
+ assert_not_nil(ruby_program)
72
+ assert_kind_of(String, ruby_program)
73
+ end
74
+
75
+ def verify_scratch_dir_name(dir)
76
+ assert_match(/scratch.*TestTestBase.*test/, dir)
77
+ end
78
+
79
+ def test_scratch_dir
80
+ assert_not_nil(scratch_dir)
81
+ assert_kind_of(String, scratch_dir)
82
+ verify_scratch_dir_name(scratch_dir)
83
+ end
84
+
85
+ def test_scratch_filename
86
+ name = scratch_filename("foobar")
87
+ assert_kind_of(String, name)
88
+ verify_scratch_dir_name(File.dirname(name))
89
+ assert_equal("foobar", File.basename(name))
90
+
91
+ name = scratch_filename("foobar")
92
+ assert_kind_of(String, name)
93
+ verify_scratch_dir_name(File.dirname(name))
94
+ assert_equal("foobar.1", File.basename(name))
95
+ end
96
+
97
+ def test_string_as_file
98
+ string = "yo\nman\n"
99
+ string_as_file(string) { |f|
100
+ assert_equal(string, f.readlines.join(''))
101
+ }
102
+ string2 = " yo\n man\n"
103
+ string_as_file(string2) { |f|
104
+ assert_equal("yo\nman\n", f.readlines.join(''))
105
+ }
106
+ string_as_file(string2, false) { |f|
107
+ assert_equal(string2, f.readlines.join(''))
108
+ }
109
+ end
110
+
111
+ end
112
+
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # Copyright (C) 2002 Matt Armstrong. All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # 1. Redistributions of source code must retain the above copyright notice,
9
+ # this list of conditions and the following disclaimer.
10
+ # 2. Redistributions in binary form must reproduce the above copyright
11
+ # notice, this list of conditions and the following disclaimer in the
12
+ # documentation and/or other materials provided with the distribution.
13
+ # 3. The name of the author may not be used to endorse or promote products
14
+ # derived from this software without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
+ # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19
+ # NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
+ # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ #
27
+
28
+ require 'tests/testbase'
29
+ require 'rmail/parser'
30
+ require 'rmail/serialize'
31
+
32
+ class TestRMailTransparency < TestBase
33
+ def do_file(file)
34
+ full_name = data_filename(file)
35
+ message1 = data_as_file(file) { |f|
36
+ RMail::Parser.new.parse(f)
37
+ }
38
+ scratch_base = file.gsub(/[^\w]/, '-')
39
+ scratch_name = scratch_filename(scratch_base)
40
+ message2 = File.open(scratch_name, "w+") { |f|
41
+ RMail::Serialize.new(f).serialize(message1)
42
+ f.seek(0)
43
+ RMail::Parser.new.parse(f)
44
+ }
45
+ if message1 != message2
46
+ puts "-" * 70
47
+ pp message1
48
+ puts "-" * 70
49
+ pp message2
50
+ puts "-" * 70
51
+ end
52
+ assert(File.compare(full_name, scratch_name),
53
+ "parse->serialize failure transparency #{file}")
54
+ assert_equal(message1, message2,
55
+ "parse->serialize->parse transparency failure #{file}")
56
+ end
57
+
58
+ # Test that all our various input files get formatted on output the
59
+ # same way they came in.
60
+ def test_transparency_simple_mime
61
+ do_file('parser.simple-mime')
62
+ end
63
+ def test_transparency_rfc822
64
+ do_file('parser.rfc822')
65
+ end
66
+ def test_transparency_nested_multipart
67
+ do_file('parser.nested-multipart')
68
+ end
69
+ def test_transparency_message_01
70
+ do_file("transparency/message.1")
71
+ end
72
+ def test_transparency_message_02
73
+ do_file("transparency/message.2")
74
+ end
75
+ def test_transparency_message_03
76
+ do_file("transparency/message.3")
77
+ end
78
+ def test_transparency_message_04
79
+ do_file("transparency/message.4")
80
+ end
81
+ def test_transparency_message_05
82
+ do_file("transparency/message.5")
83
+ end
84
+ def test_transparency_message_06
85
+ do_file("transparency/message.6")
86
+ end
87
+ def test_transparency_absolute_01
88
+ do_file('transparency/absolute.1')
89
+ end
90
+ def test_transparency_absolute_02
91
+ do_file('transparency/absolute.2')
92
+ end
93
+ def test_transparency_absolute_03
94
+ do_file('transparency/absolute.3')
95
+ end
96
+ def test_transparency_absolute_04
97
+ do_file('transparency/absolute.4')
98
+ end
99
+ def test_transparency_absolute_05
100
+ do_file('transparency/absolute.5')
101
+ end
102
+ def test_transparency_absolute_06
103
+ do_file('transparency/absolute.6')
104
+ end
105
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: "0.8"
3
+ specification_version: 1
4
+ name: rmail
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.17"
7
+ date: 2004-10-22
8
+ summary: "This is RubyMail, a lightweight mail library containing various utility classes and modules that allow Ruby scripts to parse, modify, and generate MIME mail messages."
9
+ require_paths:
10
+ - lib
11
+ author: Matt Armstrong
12
+ email: matt@lickey.com
13
+ homepage: http://www.lickey.com/rubymail/
14
+ rubyforge_project:
15
+ description:
16
+ autorequire: rmail
17
+ default_executable:
18
+ bindir: bin
19
+ has_rdoc: true
20
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
21
+ requirements:
22
+ -
23
+ - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 1.6.7
26
+ version:
27
+ platform: ruby
28
+ files:
29
+ - lib
30
+ - NEWS
31
+ - TODO
32
+ - NOTES
33
+ - guide
34
+ - tests
35
+ - README
36
+ - THANKS
37
+ - install.rb
38
+ - rmail.gemspec
39
+ - lib/rmail.rb
40
+ - lib/rmail
41
+ - lib/rmail/parser.rb
42
+ - lib/rmail/message.rb
43
+ - lib/rmail/header.rb
44
+ - lib/rmail/mailbox
45
+ - lib/rmail/address.rb
46
+ - lib/rmail/parser
47
+ - lib/rmail/mailbox.rb
48
+ - lib/rmail/serialize.rb
49
+ - lib/rmail/utils.rb
50
+ - lib/rmail/mailbox/mboxreader.rb
51
+ - lib/rmail/parser/multipart.rb
52
+ - lib/rmail/parser/pushbackreader.rb
53
+ - guide/MIME.txt
54
+ - guide/TableOfContents.txt
55
+ - guide/Intro.txt
56
+ - tests/data
57
+ - tests/addrgrammar.txt
58
+ - tests/testmboxreader.rb
59
+ - tests/testpushbackreader.rb
60
+ - tests/runtests.rb
61
+ - tests/testaddress.rb
62
+ - tests/testtestbase.rb
63
+ - tests/testserialize.rb
64
+ - tests/testparser.rb
65
+ - tests/testtranspparency.rb
66
+ - tests/testmailbox.rb
67
+ - tests/testheader.rb
68
+ - tests/testparsermultipart.rb
69
+ - tests/testbase.rb
70
+ - tests/testmessage.rb
71
+ - tests/data/parser.rfc822
72
+ - tests/data/transparency
73
+ - tests/data/parser.simple-mime
74
+ - tests/data/parser.badmime1
75
+ - tests/data/parser.badmime2
76
+ - tests/data/multipart
77
+ - tests/data/parser.nested-multipart
78
+ - tests/data/mbox.odd
79
+ - tests/data/parser
80
+ - tests/data/parser.nested-simple
81
+ - tests/data/mbox.simple
82
+ - tests/data/parser.nested-simple2
83
+ - tests/data/parser.nested-simple3
84
+ - tests/data/transparency/message.1
85
+ - tests/data/transparency/message.2
86
+ - tests/data/transparency/message.3
87
+ - tests/data/transparency/message.4
88
+ - tests/data/transparency/message.5
89
+ - tests/data/transparency/message.6
90
+ - tests/data/transparency/absolute.1
91
+ - tests/data/transparency/absolute.2
92
+ - tests/data/transparency/absolute.3
93
+ - tests/data/transparency/absolute.4
94
+ - tests/data/transparency/absolute.5
95
+ - tests/data/transparency/absolute.6
96
+ - tests/data/multipart/data.10
97
+ - tests/data/multipart/data.11
98
+ - tests/data/multipart/data.12
99
+ - tests/data/multipart/data.13
100
+ - tests/data/multipart/data.14
101
+ - tests/data/multipart/data.15
102
+ - tests/data/multipart/data.16
103
+ - tests/data/multipart/data.17
104
+ - tests/data/multipart/data.1
105
+ - tests/data/multipart/data.2
106
+ - tests/data/multipart/data.3
107
+ - tests/data/multipart/data.4
108
+ - tests/data/multipart/data.5
109
+ - tests/data/multipart/data.6
110
+ - tests/data/multipart/data.7
111
+ - tests/data/multipart/data.8
112
+ - tests/data/multipart/data.9
113
+ - tests/data/parser/multipart.1
114
+ - tests/data/parser/multipart.2
115
+ - tests/data/parser/multipart.3
116
+ - tests/data/parser/multipart.4
117
+ - tests/data/parser/multipart.5
118
+ - tests/data/parser/multipart.6
119
+ - tests/data/parser/multipart.7
120
+ - tests/data/parser/multipart.8
121
+ - tests/data/parser/multipart.9
122
+ - tests/data/parser/multipart.10
123
+ - tests/data/parser/multipart.11
124
+ - tests/data/parser/multipart.12
125
+ - tests/data/parser/multipart.13
126
+ - tests/data/parser/multipart.14
127
+ - tests/data/parser/multipart.15
128
+ - tests/data/parser/multipart.16
129
+ test_files:
130
+ - tests/runtests.rb
131
+ rdoc_options:
132
+ - "--main"
133
+ - README
134
+ extra_rdoc_files:
135
+ - README
136
+ - NOTES
137
+ - NEWS
138
+ - TODO
139
+ - THANKS
140
+ executables: []
141
+ extensions: []
142
+ requirements: []
143
+ dependencies: []