rmail-sup 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/NEWS +323 -0
  3. data/NOTES +14 -0
  4. data/README +83 -0
  5. data/Rakefile +184 -0
  6. data/THANKS +25 -0
  7. data/TODO +115 -0
  8. data/guide/Intro.txt +122 -0
  9. data/guide/MIME.txt +6 -0
  10. data/guide/TableOfContents.txt +13 -0
  11. data/install.rb +1023 -0
  12. data/lib/rmail.rb +50 -0
  13. data/lib/rmail/address.rb +841 -0
  14. data/lib/rmail/header.rb +981 -0
  15. data/lib/rmail/mailbox.rb +62 -0
  16. data/lib/rmail/mailbox/mboxreader.rb +182 -0
  17. data/lib/rmail/message.rb +201 -0
  18. data/lib/rmail/parser.rb +412 -0
  19. data/lib/rmail/parser/multipart.rb +217 -0
  20. data/lib/rmail/parser/pushbackreader.rb +173 -0
  21. data/lib/rmail/serialize.rb +190 -0
  22. data/lib/rmail/utils.rb +59 -0
  23. data/test/addrgrammar.txt +113 -0
  24. data/test/data/mbox.odd +4 -0
  25. data/test/data/mbox.simple +8 -0
  26. data/test/data/multipart/data.1 +5 -0
  27. data/test/data/multipart/data.10 +1 -0
  28. data/test/data/multipart/data.11 +9 -0
  29. data/test/data/multipart/data.12 +9 -0
  30. data/test/data/multipart/data.13 +3 -0
  31. data/test/data/multipart/data.14 +3 -0
  32. data/test/data/multipart/data.15 +3 -0
  33. data/test/data/multipart/data.16 +3 -0
  34. data/test/data/multipart/data.17 +0 -0
  35. data/test/data/multipart/data.2 +5 -0
  36. data/test/data/multipart/data.3 +2 -0
  37. data/test/data/multipart/data.4 +3 -0
  38. data/test/data/multipart/data.5 +1 -0
  39. data/test/data/multipart/data.6 +2 -0
  40. data/test/data/multipart/data.7 +3 -0
  41. data/test/data/multipart/data.8 +5 -0
  42. data/test/data/multipart/data.9 +4 -0
  43. data/test/data/parser.badmime1 +4 -0
  44. data/test/data/parser.badmime2 +6 -0
  45. data/test/data/parser.nested-multipart +75 -0
  46. data/test/data/parser.nested-simple +12 -0
  47. data/test/data/parser.nested-simple2 +16 -0
  48. data/test/data/parser.nested-simple3 +21 -0
  49. data/test/data/parser.rfc822 +65 -0
  50. data/test/data/parser.simple-mime +24 -0
  51. data/test/data/parser/multipart.1 +8 -0
  52. data/test/data/parser/multipart.10 +4 -0
  53. data/test/data/parser/multipart.11 +12 -0
  54. data/test/data/parser/multipart.12 +12 -0
  55. data/test/data/parser/multipart.13 +6 -0
  56. data/test/data/parser/multipart.14 +6 -0
  57. data/test/data/parser/multipart.15 +6 -0
  58. data/test/data/parser/multipart.16 +6 -0
  59. data/test/data/parser/multipart.2 +8 -0
  60. data/test/data/parser/multipart.3 +5 -0
  61. data/test/data/parser/multipart.4 +6 -0
  62. data/test/data/parser/multipart.5 +4 -0
  63. data/test/data/parser/multipart.6 +5 -0
  64. data/test/data/parser/multipart.7 +6 -0
  65. data/test/data/parser/multipart.8 +8 -0
  66. data/test/data/parser/multipart.9 +7 -0
  67. data/test/data/transparency/absolute.1 +5 -0
  68. data/test/data/transparency/absolute.2 +1 -0
  69. data/test/data/transparency/absolute.3 +2 -0
  70. data/test/data/transparency/absolute.4 +3 -0
  71. data/test/data/transparency/absolute.5 +4 -0
  72. data/test/data/transparency/absolute.6 +49 -0
  73. data/test/data/transparency/message.1 +73 -0
  74. data/test/data/transparency/message.2 +34 -0
  75. data/test/data/transparency/message.3 +63 -0
  76. data/test/data/transparency/message.4 +5 -0
  77. data/test/data/transparency/message.5 +15 -0
  78. data/test/data/transparency/message.6 +1185 -0
  79. data/test/runtests.rb +35 -0
  80. data/test/testaddress.rb +1204 -0
  81. data/test/testbase.rb +204 -0
  82. data/test/testheader.rb +1225 -0
  83. data/test/testmailbox.rb +47 -0
  84. data/test/testmboxreader.rb +161 -0
  85. data/test/testmessage.rb +257 -0
  86. data/test/testparser.rb +634 -0
  87. data/test/testparsermultipart.rb +205 -0
  88. data/test/testpushbackreader.rb +40 -0
  89. data/test/testserialize.rb +264 -0
  90. data/test/testtestbase.rb +116 -0
  91. data/test/testtranspparency.rb +105 -0
  92. data/version +1 -0
  93. metadata +149 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: abb4dfa867a9a0b57ad087fb1066a65db6ee661d
4
+ data.tar.gz: 2f87a569a5f5f6a379d21490c11c9b8c79e89199
5
+ SHA512:
6
+ metadata.gz: 1a677e561c04b9da5b7983684fc733d4510c2580d57bf6d58cf73ed64a44204963ddc133e7d819855ae113ae56288a42056baa8cc4cdb7c277f414fabe9e6b41
7
+ data.tar.gz: 81ddae6ea5bef34799ab4f9c7ec3327386de6f4f124353c3eb9de6014a240f88bcac572b7ce30d883dec7577861441bb5e7706020a1f7321807e839b18e6bcd9
data/NEWS ADDED
@@ -0,0 +1,323 @@
1
+ = Changes in RubyMail 1.0.1 (released 2013-09-04)
2
+
3
+ - Fix encoding of regexps for ruby 1.9.1+
4
+
5
+ = Changes in RubyMail 1.0.0 (released 2008-01-05)
6
+
7
+ - This version differs *only* in the changes required for Ruby 1.9
8
+ support. It is otherwise "bug compatible" with version 0.17. Users
9
+ of version 0.17 can safely upgrade to 1.0.0. You will lose the
10
+ ability to run the tests if you are using Ruby 1.6 (but who is doing
11
+ that these days?).
12
+
13
+ - Add a Rakefile. Add a gem hosted on rubyforge.org.
14
+
15
+ = Changes in RubyMail 0.17 (released 2004-04-27)
16
+
17
+ - Handle parsing addresses with non-ASCII display names. We don't do
18
+ anything intelligent with the non-ASCII data, but it is passed
19
+ through in its original (invalid) non-encoded form.
20
+
21
+ - Look for From_ lines only on the first line when parsing a message.
22
+
23
+ - RMail::Header#subject= now sets the header field name to "Subject"
24
+ instead of "subject" since some mail reading software is case
25
+ sensitive and can't understand "subject: foo".
26
+
27
+ - The RMail parser now requires only whitespace after MIME multipart
28
+ boundary lines. This violates RFC2046's "NOTE TO IMPLEMENTORS"
29
+ documented in testparsermultipart.rb's test_multipart_data_12, but
30
+ it allows real-world messages created by Eudora to be parsed.
31
+
32
+ = Changes in RubyMail 0.16 (released 2003-12-26)
33
+
34
+ - Ruby 1.8.1 compatibility fixes only.
35
+
36
+ = Changes in RubyMail 0.15 (released 2003-09-17)
37
+
38
+ - Ruby 1.8.0 compatibility fixes only.
39
+
40
+ = Changes in RubyMail 0.14 (released 2003-02-08)
41
+
42
+ - Improve RDoc documentation of the library.
43
+
44
+ - Add file level comments.
45
+ - No longer document RMail::Parser::PushbackReader and
46
+ RMail::Parser::Multipart, as they are used only internally or by
47
+ those who really want to dig deep into the library. I also think
48
+ they might be changing soon.
49
+
50
+ - Add ability to
51
+ require 'rmail'
52
+ and get all of RubyMail.
53
+
54
+ - Switch to the BSD license, mainly so the license of RubyMail is not
55
+ confusing.
56
+
57
+ = Changes in RubyMail 0.13 (released 2003-02-01)
58
+
59
+ - Add convenience methods to RMail::Header that allow easy
60
+ manipulation of the To, Cc, Bcc, Reply-To, Date, Subject and
61
+ Message-Id fields. This includes unique Message-Id generation code
62
+ and robust Date field parsing and formatting.
63
+
64
+ - Add RMail::Header#set, to delete existing fields of the same name
65
+ and then add a new one.
66
+
67
+ - RMail::Address.parse now returns an RMail::Address::List instead of
68
+ an Array (existing code still works, since RMail::Address::List
69
+ inherits from Array).
70
+
71
+ - Add RMail::Address#<=>, RMail::Address#hash and RMail::Address#eql?
72
+ methods. This allows arrays of RMail::Address to be sorted as well
73
+ as allowing RMail::Address to be placed in a hash (which in turn
74
+ allows Array#uniq to work when holding RMail::Address objects).
75
+
76
+ - Add an RMail::Mailbox::MBoxReader.each_message method.
77
+
78
+ - Deleted the rmail/header/field.rb field and incorporated
79
+ RMail::Header::Field into rmail/header.rb.
80
+
81
+ - Improve uniqueness of the MIME boundary generation by including
82
+ Time.now.tv_usec.
83
+
84
+ - Correct broken docs for RMail::Header#match and RMail::Header#match?
85
+
86
+ = Changes in RubyMail 0.12 (released 2003-01-13)
87
+
88
+ - Add an install.rb script.
89
+
90
+ = Changes in RubyMail 0.11 (released 2003-01-11)
91
+
92
+ - parse->serialize "transparency" greatly improved. This means that
93
+ when you parse a message and then serialize it back out you almost
94
+ always get the exact same message back. This is true for all single
95
+ part messages as well as all validly formatted multipart MIME
96
+ messages (and even the most common invalidly formatted ones).
97
+
98
+ The result is that RMail can now be used safely in mail filters
99
+ without risking damaging cryptographic signatures in the mails.
100
+
101
+ - RMail::Header#add now uses to_str instead of to_s to convert
102
+ arguments to strings. This makes it behave more like standard
103
+ Ruby classes.
104
+
105
+ - RMail::Mailbox::MBoxReader now always makes sure the last piece of
106
+ data returned for each message is the end of line terminator, even
107
+ if one isn't present in the input.
108
+
109
+ - RMail::Parser::PushbackReader#read now takes nil argument to mean
110
+ "read all available input." Derived classes should now override
111
+ the #read_chunk method instead of #read.
112
+
113
+ = Changes in RubyMail 0.10 (released 2002-12-13)
114
+
115
+ - Added rmail/mailbox/mboxreader.rb to the distribution.
116
+
117
+ = Changes in RubyMail 0.9 (released 2002-11-30)
118
+
119
+ - New RMail::Mailbox.parse_mbox method that can be used to conveniently
120
+ read raw messages out of a Unix mbox mailbox.
121
+
122
+ - New RMail::Mailbox::MBoxReader class in
123
+ rmail/mailbox/mboxreader.rb. This class can be used to easily read
124
+ messages out of a file in Unix "mbox" format.
125
+
126
+ - The RMail::Parser::PushbackReader class
127
+ has been documented. It has moved out of rmail/parser/multipart.rb
128
+ into rmail/parser/pushbackreader.rb
129
+
130
+ - Various documentation fixes. E.g. RMail::Parser.parse can take a
131
+ string as well as an IO object.
132
+
133
+ - The RMail::Parser::PushbackReader has a setable chunk size. This
134
+ is useful mostly for testing.
135
+
136
+ - Fix an uncaught exception when parsing multipart MIME messages that
137
+ contain only a preamble and an epilogue but no body parts.
138
+
139
+ - Fix a bug where RMail::Parser.multipart? would not return true if the
140
+ multipart message actually didn't have any parts.
141
+
142
+ = Changes in RubyMail 0.8 (released 2002-03-18)
143
+
144
+ - The following has been removed from RubyMail and made part of the
145
+ RubyFilter package:
146
+
147
+ - All scripts that were in the RubyMail 0.7 bin directory.
148
+ - Mail::LDA
149
+ - Mail::Deliver
150
+ - Mail::KeyedMailbox
151
+ - Mail::MTA
152
+ - Mail::AddressTagger
153
+
154
+ This keeps RubyMail a small and simple mail package, and provides
155
+ RubyFilter as an example of how to use RubyMail to write a mail
156
+ filter.
157
+
158
+ - The Mail module has been renamed to RMail. I think "Mail" should
159
+ be reserved for things included in the standard distribution of
160
+ Ruby.
161
+
162
+ - RMail::Header#match and match? don't require the name or value
163
+ arguments to be a case insensitive Regexps. Also, when the value
164
+ argument is converted to a string, it is passed through
165
+ Regexp::escape first.
166
+
167
+ - RMail::Parser#parse can now parse from a string.
168
+
169
+ - Mail::Address#comments= can now take a simpple string to set just
170
+ one comment.
171
+
172
+ = Changes in RubyMail 0.7 (released 2002-02-26)
173
+
174
+ - A new chunked input scheme that makes parsing huge messages about 7
175
+ times faster in ruby 1.7 and 50 times faster in ruby 1.6.
176
+
177
+ When parsing a huge message that has a 2 megabyte attachment,
178
+ RubyMail running under ruby 1.7 is now faster than any email
179
+ package for ruby, perl or python.
180
+
181
+ I wrote a benchmark that reads a 2 megabyte email from a file and
182
+ writes it out again, doing this 100 times. The results are:
183
+
184
+ ruby 1.7.2 w/rubymail (100 times)
185
+ 5.96s user 7.98s system 13.94s total
186
+ ruby 1.6.6 w/rubymail (100 times)
187
+ 76.91s user 8.62s system 85.53s total
188
+ ruby 1.7.2 w/tmail 0.10.1 (100 times)
189
+ 9.85s user 24.21s system 34.06s total
190
+ ruby 1.6.6 w/tmail 0.10.0 (100 times)
191
+ 201.89s user 15.75s system 217.64s total
192
+ python 2.2 w/email (100 times)
193
+ 76.73 user 15.16s system 91.89s total
194
+ perl 5.006001 w/mimetools 5.411 (parsing on disk) (100 times)
195
+ 190.11s user 25.25s system 215.36s total
196
+ perl 5.006001 w/mimetools 5.411 (parsing in memory) (100 times)
197
+ 962.69s user 6.77s system 969.46s total
198
+
199
+ This change also paves the way for streaming large messages
200
+ to disk when they start to get huge, so RAM isn't needlessly
201
+ used up.
202
+
203
+ - Delivery to mbox files improved.
204
+
205
+ - won't sleep forever waiting for the mailbox lock (flock)
206
+ - won't delivery to files that don't look like an mbox
207
+ (e.g. it is not a file, not in the right format).
208
+ - delivering to '/dev/null' is now a simple nop.
209
+
210
+ - Use the new File#fsync method when available in all of the mail
211
+ delivery functions.
212
+
213
+ - Add bin/rsendmail.rb as another example of how I'm using RubyMail.
214
+
215
+ - A new Mail::AddressTagger class, included for fun. Requires the
216
+ hmac-sha1 class (available in the ruby-hmac package on RAA).
217
+
218
+ = Changes in RubyMail 0.6 (released 2002-02-15)
219
+
220
+ - Multipart MIME support.
221
+
222
+ - Mail::Parser now parses arbitrarily nested multipart MIME messages.
223
+
224
+ - For the sake of dealing with multipart MIME messages, add the
225
+ following methods to Mail::Message: preamble, epilogue, multipart?,
226
+ add_part, decode, part.
227
+
228
+ - A new Mail::AddressTagger class, for tagging addresses with
229
+ cryptographically verifiable extensions akin to TMDA. Requires the
230
+ hmac-sha1 module from the RAA. (experimental, I don't currently
231
+ use this)
232
+
233
+ - A new Mail::Message#== method.
234
+
235
+ - A new Mail::Serialize class that can serialize a Mail::Message.
236
+
237
+ = Changes in RubyMail 0.5 (released 2002-02-02)
238
+
239
+ - The rdeliver.rb script is now fully documented.
240
+
241
+ - The rdeliver.rb script now evaluates the .rdeliver file in the
242
+ context of a Deliver class (as opposed to simply loading it). The
243
+ .rdeliver file must now define a Deliver#main method, where the
244
+ simplest .rdeliver file would be:
245
+
246
+ def main
247
+ lda.save("INBOX")
248
+ end
249
+
250
+ - Add a KeyedMailbox class that can be used to implement simple
251
+ mailing list style confirmations.
252
+
253
+ - Add a message= method to Mail::DeliveryAgent. This lets delivery
254
+ scripts change the message being delivered.
255
+
256
+ - Re-wrote the RFC2822 address parser. It is now more strict about
257
+ what it considers a valid address.
258
+
259
+ = Changes in RubyMail 0.4 (released 2002-01-17)
260
+
261
+ - The bin/rdeliver.rb script is now tested. Got rid of
262
+ bin/rdeliver-wrap.rb.
263
+
264
+ - Mail::DeliveryAgent::DeliveryStatus renamed to
265
+ Mail::DeliveryAgent::DeliveryComplete.
266
+ Mail::DeliveryAgent::DeliverFailure renamed to
267
+ Mail::DeliveryAgent::DeliveryPipeFailure.
268
+
269
+ - Mail::Deliver.deliver_mbox now uses File::SYNC to write the
270
+ message.
271
+
272
+ - Mail::Header and Mail::Message no longer understand how to parse
273
+ messages. Message parsing has been moved to Mail::Parser.
274
+ Mail::Parser uses the public API of Mail::Header and Mail::Message
275
+ to build up the message.
276
+
277
+ - The Mail::Header API has been greatly changed. It is now more like
278
+ Array and Hash.
279
+
280
+ - Mail::Deliver supports delivery to qmail style Maildir mailboxes.
281
+ Mail::DeliveryAgent#save will now deliver to a Maildir if the
282
+ folder's name ends in a slash. E.g. "/home/user/Maildir/".
283
+
284
+ - Mail::DeliveryAgent no longer logs an abstract of the message being
285
+ delivered. All logging is up to the users of Mail::DeliveryAgent.
286
+
287
+ = Changes in RubyMail 0.3
288
+
289
+ - Add Mail::Header.length and Mail::Header.size methods. Add
290
+ Mail::Header.match and Mail::Header.match? methods.
291
+
292
+ - Move deliver.rb to bin/rdeliver-wrap.rb and main.rb to
293
+ bin/rdeliver.rb. These are workable local delivery agent scripts
294
+ (suitable for running from .forward).
295
+
296
+ - New Mail::MTA module that provides constants for exit codes.
297
+
298
+ - New features for Mail::DeliveryAgent. Now Mail::DeliveryAgent never
299
+ calls exit, instead it throws DeliveryStatus exceptions. There is
300
+ also a new Mail::DeliveryAgent.process method that allows you to use
301
+ Mail::DeliveryAgent in block form. Mail:DeliveryAgent.exitcode will
302
+ return the correct exit code for a given DeliveryStatus exception.
303
+
304
+ = Changes in RubyMail 0.2
305
+
306
+ - HTML API documentation is now available in the doc subdirectory.
307
+
308
+ - Mail::DeliveryAgent::strip_tag is now
309
+ Mail::DeliveryAgent::strip_field_name.
310
+
311
+ - Mail::Deliver::deliver_pipe implemented. Mail::DeliveryAgent#pipe
312
+ implemented.
313
+
314
+ - Mail::DeliveryAgent#pipe and Mail::DeliveryAgent#save now report
315
+ success or failure with DeliverySuccess and DeliveryFailure
316
+ exceptions. Mail::DeliveryAgent#reject and
317
+ Mail::DeliveryAgent#defer do not yet use the exceptions (they still
318
+ call exit).
319
+
320
+ - Now runs clean under "ruby -w"
321
+
322
+ - Now works with newer rubyunit versions.
323
+
data/NOTES ADDED
@@ -0,0 +1,14 @@
1
+ -*- outline -*-
2
+
3
+ * Why RubyMail can't be completely transparent
4
+
5
+ RubyMail parses the MIME message into a document structure. If
6
+ the MIME message is invalid, RubyMail might discard invalid
7
+ portions, etc. Also, if you parse and then serialize a
8
+ RMail::Message, empty lines may be deleted or inserted around a
9
+ MIME boundary.
10
+
11
+ For these reasons, if you require a message to be output exactly
12
+ as it is put in, I suggest that you do not filter it *through*
13
+ RubyMail. Instead, parse the message and decide what to do with
14
+ it, and then save the original message.
data/README ADDED
@@ -0,0 +1,83 @@
1
+ = RubyMail
2
+
3
+ This is RubyMail, a lightweight mail library containing various
4
+ utility classes and modules that allow Ruby scripts to parse,
5
+ modify, and generate MIME mail messages.
6
+
7
+ = Requirements
8
+
9
+ Ruby 1.6.7 (or newer) or Ruby 1.8.*. Only tested under Linux, should
10
+ be fine under any Unix.
11
+
12
+ = Documentation
13
+
14
+ The documentation is in RDoc format in the doc subdirectory. Aside
15
+ from the API reference, you will be interested in guide/Intro.txt and
16
+ guide/TableOfContents.txt.
17
+
18
+ = Install
19
+
20
+ Type the following while in the package directory:
21
+
22
+ ruby install.rb config
23
+ ruby install.rb setup
24
+ ruby install.rb install
25
+
26
+ You may need special permissions to execute the last line. If you
27
+ want to just install RubyMail to a custom location, just copy the
28
+ rmail subdirectory manually.
29
+
30
+ = Status
31
+
32
+ This package works well, but I consider all API subject to change.
33
+
34
+ I very much appreciate suggestions and comments, but please think
35
+ twice about using this for production use just yet.
36
+
37
+ = Tests?
38
+
39
+ This package has a complete unit test suite (requires RubyUnit to
40
+ run). Currently all of my e-mail is processed by this library.
41
+
42
+ = Why?
43
+
44
+ It is fun.
45
+
46
+ One use for RubyMail is the RubyFilter package, available at:
47
+
48
+ http://www.lickey.com/rubyfilter/
49
+
50
+ = Alternatives
51
+
52
+ You might check out TMail as well.
53
+
54
+ = Support
55
+
56
+ To reach the author of RubyMail, send mail to matt@lickey.com.
57
+
58
+ = License
59
+
60
+ Copyright (C) 2001, 2002, 2003, 2004 Matt Armstrong. All rights
61
+ reserved.
62
+
63
+ Redistribution and use in source and binary forms, with or without
64
+ modification, are permitted provided that the following conditions are met:
65
+
66
+ 1. Redistributions of source code must retain the above copyright notice,
67
+ this list of conditions and the following disclaimer.
68
+ 2. Redistributions in binary form must reproduce the above copyright
69
+ notice, this list of conditions and the following disclaimer in the
70
+ documentation and/or other materials provided with the distribution.
71
+ 3. The name of the author may not be used to endorse or promote products
72
+ derived from this software without specific prior written permission.
73
+
74
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
75
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
76
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
77
+ NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
78
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
79
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
80
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
81
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
82
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
83
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,184 @@
1
+ # -*- ruby -*-
2
+
3
+ #
4
+ # This is a Ruby file, used by the "rake" make-like program.
5
+ #
6
+
7
+ begin
8
+ # First, we use a few ruby things...
9
+ require 'rubygems'
10
+ require 'rake/gempackagetask'
11
+ end
12
+ require 'rake/rdoctask'
13
+ require 'rake/testtask'
14
+ require 'shellwords'
15
+
16
+ #
17
+ # The default task is run if rake is given no explicit arguments.
18
+ #
19
+ desc "Default Task"
20
+ task :default => :test
21
+
22
+ #
23
+ # Test tasks
24
+ #
25
+ Rake::TestTask.new do |t|
26
+ t.libs << 'test'
27
+ t.pattern = 'test/test*.rb'
28
+ t.verbose = true
29
+ end
30
+
31
+
32
+ def unreleasable_reason
33
+ can_release_package
34
+ unreleasable_reason
35
+ end
36
+
37
+ def can_release_package
38
+ reasons = []
39
+
40
+ unless news_is_current
41
+ reasons << 'the NEWS file is not current'
42
+ end
43
+
44
+ unless defined?(Gem)
45
+ reasons << 'RubyGems is not installed'
46
+ end
47
+
48
+ reason = if reasons.empty?
49
+ ""
50
+ else
51
+ last = reasons.pop
52
+ ("Can not release package because " +
53
+ (reasons.empty? ? "#{last}." :
54
+ (reasons.join(", ") + " and #{last}.")))
55
+ end
56
+ can_release = reason.length == 0
57
+
58
+ self.class.module_eval <<-END_OF_CODE
59
+ def unreleasable_reason
60
+ \"#{reason}\"
61
+ end
62
+ def can_release_package
63
+ #{can_release.inspect}
64
+ end
65
+ END_OF_CODE
66
+
67
+ can_release_package
68
+ end
69
+
70
+ # Is the NEWS file current?
71
+ def news_is_current
72
+ today = Time.now.strftime('%Y-%m-%d')
73
+ version = Regexp.new(Regexp.quote(PKG_VERSION))
74
+ if IO.readlines('NEWS').first =~
75
+ /= Changes in RubyMail #{PKG_VERSION} \(released #{today}\)$/
76
+ true
77
+ else
78
+ false
79
+ end
80
+ end
81
+
82
+
83
+ #
84
+ # These PKG_ variables are used by Rake's package rule.
85
+ #
86
+ PKG_VERSION = begin
87
+ version= IO.readlines('version').first.chomp
88
+ if version =~ /^\d+\.\d+\.\d+$/
89
+ version.untaint
90
+ else
91
+ fail "package version is bogus"
92
+ end
93
+ version
94
+ end
95
+
96
+ PKG_FILES = FileList.new('test/**/*',
97
+ 'guide/**/*',
98
+ 'lib/**/*',
99
+ 'install.rb',
100
+ 'NEWS',
101
+ 'NOTES',
102
+ 'README',
103
+ 'THANKS',
104
+ 'TODO',
105
+ 'Rakefile',
106
+ 'version')
107
+
108
+ #
109
+ # Teach Rake how to build the RDoc documentation for this package.
110
+ #
111
+ rdoc = Rake::RDocTask.new do |rdoc|
112
+ rdoc.main = 'README'
113
+ rdoc.rdoc_files.include("README", "NEWS", "THANKS",
114
+ "TODO", "guide/*.txt", "lib/**/*.rb")
115
+ rdoc.rdoc_files.exclude(/\bSCCS\b/,
116
+ "lib/rubymail/parser/*")
117
+ unreleased = if can_release_package
118
+ ""
119
+ else
120
+ " (UNRELEASED!)"
121
+ end
122
+ rdoc.title = "RubyMail Documentation (version #{PKG_VERSION})"
123
+ rdoc.options << '--exclude' << 'SCCS'
124
+ end
125
+
126
+ # Make sure that we don't package anything that hasn't been tagged.
127
+ task :package => [ :can_release ]
128
+
129
+ desc "Check if the package is in a releasable state."
130
+ task :can_release do
131
+ unless can_release_package
132
+ puts unreleasable_reason
133
+ end
134
+ end
135
+
136
+ #
137
+ # Create a Gem::Specification right in the Rakefile, using some of the
138
+ # variables we have set up above.
139
+ #
140
+ if defined?(Gem)
141
+ spec = Gem::Specification.new do |s|
142
+ s.name = 'rmail-sup'
143
+ s.version = PKG_VERSION + if can_release_package
144
+ ''
145
+ else
146
+ '.666'
147
+ end
148
+ s.summary = 'A MIME mail parsing and generation library.'
149
+ s.description = <<-EOF
150
+ RMail is a lightweight mail library containing various utility classes and
151
+ modules that allow ruby scripts to parse, modify, and generate MIME mail
152
+ messages.
153
+ EOF
154
+
155
+ s.files = PKG_FILES.to_a
156
+
157
+ s.required_ruby_version = Gem::Version::Requirement.new(">= 1.8.1")
158
+
159
+ s.has_rdoc = true
160
+ s.extra_rdoc_files = rdoc.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
161
+ s.rdoc_options.concat([ '--title', rdoc.title, '--main', rdoc.main,
162
+ rdoc.options ].flatten)
163
+
164
+ s.test_files = FileList['test/tc_*.rb'].to_a
165
+
166
+ s.author = "Sup maintainers"
167
+ s.email = "sup-devel@rubyforge.org"
168
+ s.homepage = "http://supmua.org"
169
+ end
170
+
171
+ #
172
+ # Use our Gem::Specification to make some package tasks.
173
+ #
174
+ Rake::GemPackageTask.new(spec) do |pkg|
175
+ pkg.need_zip = true
176
+ pkg.need_tar = true
177
+ end
178
+ end
179
+
180
+ desc "Install RubyMail using the standard install.rb script"
181
+ task :install do
182
+ ruby "install.rb"
183
+ end
184
+