tmail 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/CHANGES +5 -0
  2. data/NOTES +84 -0
  3. data/README +6 -1
  4. data/ext/Makefile +20 -0
  5. data/ext/{tmail/base64 → mailscanner/tmail}/MANIFEST +1 -1
  6. data/ext/mailscanner/tmail/depend +1 -0
  7. data/ext/mailscanner/tmail/extconf.rb +24 -0
  8. data/ext/{tmail/scanner_c/scanner_c.c → mailscanner/tmail/mailscanner.c} +8 -7
  9. data/lib/tmail/base64.rb +29 -52
  10. data/lib/tmail/encode.rb +37 -38
  11. data/lib/tmail/interface.rb +632 -49
  12. data/lib/tmail/main.rb +4 -0
  13. data/lib/tmail/net.rb +0 -35
  14. data/lib/tmail/quoting.rb +8 -8
  15. data/lib/tmail/scanner.rb +10 -6
  16. data/lib/tmail/scanner_r.rb +3 -5
  17. data/lib/tmail/version.rb +2 -2
  18. data/log/ChangeLog.txt +1131 -0
  19. data/log/History.txt +40 -0
  20. data/log/Todo.txt +32 -0
  21. data/meta/MANIFEST +118 -0
  22. data/meta/ROLLRC +3 -0
  23. data/meta/icli.yaml +2 -2
  24. data/meta/{tmail-1.1.1.roll → project.yaml} +3 -7
  25. data/sample/bench_base64.rb +48 -0
  26. data/{bat → script}/changelog +0 -0
  27. data/script/clobber/distclean +8 -0
  28. data/{bat → script}/clobber/package +0 -0
  29. data/script/compile +32 -0
  30. data/{bat → script}/config.yaml +2 -2
  31. data/{bat → script}/prepare +4 -2
  32. data/{bat → script}/publish +0 -0
  33. data/{bat → script}/release +0 -0
  34. data/{bat → script}/setup +0 -0
  35. data/{bat → script}/stats +0 -0
  36. data/{bat → script}/tag +0 -0
  37. data/script/test +36 -0
  38. data/test/fixtures/raw_email_reply +32 -0
  39. data/test/fixtures/raw_email_with_bad_date +48 -0
  40. data/test/test_address.rb +1 -3
  41. data/test/test_attachments.rb +1 -2
  42. data/test/test_base64.rb +3 -2
  43. data/test/test_encode.rb +1 -0
  44. data/test/test_header.rb +2 -3
  45. data/test/test_helper.rb +8 -2
  46. data/test/test_mail.rb +45 -16
  47. data/test/test_mbox.rb +1 -1
  48. data/test/test_port.rb +1 -1
  49. data/test/test_scanner.rb +1 -1
  50. data/test/test_utils.rb +1 -2
  51. metadata +82 -76
  52. data/bat/compile +0 -42
  53. data/bat/rdoc +0 -42
  54. data/bat/test +0 -25
  55. data/ext/tmail/Makefile +0 -25
  56. data/ext/tmail/base64/base64.c +0 -264
  57. data/ext/tmail/base64/depend +0 -1
  58. data/ext/tmail/base64/extconf.rb +0 -38
  59. data/ext/tmail/scanner_c/MANIFEST +0 -4
  60. data/ext/tmail/scanner_c/depend +0 -1
  61. data/ext/tmail/scanner_c/extconf.rb +0 -38
  62. data/lib/tmail/tmail.rb +0 -1
data/CHANGES ADDED
@@ -0,0 +1,5 @@
1
+ = TMail 1.2.0 / 2007-11-29
2
+
3
+ * Extensive documentation work. (mikel)
4
+ * Renamed scanner_c.c to mailscanner.c.
5
+ * Removed base64 c extension. It's speed benefit was negligable (only 0.2 sec over 10000 sizable encode/decode runs).
data/NOTES ADDED
@@ -0,0 +1,84 @@
1
+ [ANN] TMail 1.2.0
2
+
3
+ TMail is The Mail Handling Library for Ruby!
4
+
5
+ TMail is the Ruby Mail handler used in the
6
+ Ruby on Rails and Nitro web frame works as
7
+ well as many others (now including, the Ruby
8
+ Talk mail gateway!).
9
+
10
+ TMail is now a gem. You can install it on any
11
+ platform via:
12
+
13
+ # gem install tmail
14
+
15
+ Alternatively you can download the source code
16
+ or view extra documentation at the website:
17
+
18
+ http://tmail.rubyforge.org/
19
+
20
+
21
+ Release Summary:
22
+ ------------------
23
+ New release handles two tickets in the TMail
24
+ tracker as well as a lot more documentation and
25
+ removes an unnecessary c-library.
26
+
27
+
28
+ Release Update Details:
29
+ -------------------------
30
+
31
+ Closed 15445 - TMail::Mail#create_forward now returns
32
+ a new Mail object that has the original mail as an
33
+ encoded 7 bit multipart attachment. Also moved
34
+ create_forward and create_reply from tmail/net
35
+ into tmail/interface as it makes more sense to have
36
+ it there.
37
+
38
+ Closed 15643 - TMail::Mail#reply_addresses was
39
+ returning an empty array if reply_to was set to nil
40
+ (ie, the header field existed but was empty) instead
41
+ of returning the from address or default.
42
+
43
+ Removed base64.c after doing profiling on several
44
+ platforms and finding out that the Ruby inbuilt
45
+ version is just as fast (varies per platform but
46
+ all in all about the same speed.)
47
+
48
+ Renamed the Scanner_C extension to MailScanner.
49
+
50
+ New release adds extensive new documentation to
51
+ mainly the TMail::Mail class, approximately 500
52
+ lines of examples have been included in the RDoc.
53
+
54
+ Added a default value to TMail::Mail#sender method
55
+ to allow arbitrary defaults to be passed into the
56
+ method in alignment with all the other mail interface
57
+ methods.
58
+
59
+ Made base64_decode and base64_encode into ! versions
60
+ as they are destructive on the mail body (encodes the
61
+ body to base64 or decodes it), made aliases for
62
+ base64_decode and base64_encode to point back to the
63
+ bang versions. Doing this with a view to change
64
+ base64_encode to a non destructive version
65
+ (returns the encoded body) in future versions.
66
+
67
+ See the changelog for previous changes.
68
+
69
+
70
+ Bug Reports / Fixes:
71
+ ----------------------
72
+
73
+ As always, we really welcome any bug reports or code
74
+ for patches you have created. Please submit anything
75
+ you find through our RubyForge tracker project which
76
+ you can get to from our website:
77
+
78
+ http://tmail.rubyforge.org/
79
+
80
+
81
+ We hope you enjoy this release!
82
+
83
+
84
+ The TMail Team.
data/README CHANGED
@@ -127,10 +127,14 @@ You can just call to_s on any email to have it serialized out as a single string
127
127
  * C compiler if you want the Ruby extensions for Scanner and Base64
128
128
  * Ruby 1.8 or later
129
129
 
130
- == Installation
130
+ == INSTALLATION:
131
131
 
132
132
  * sudo gem install tmail
133
133
 
134
+ Or manually,
135
+
136
+ * sudo script/setup
137
+
134
138
  == LICENSE:
135
139
 
136
140
  (The MIT License)
@@ -155,3 +159,4 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
155
159
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
156
160
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
157
161
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
162
+
@@ -0,0 +1,20 @@
1
+ #
2
+ # ext/tmail/Makefile
3
+ #
4
+
5
+ .PHONY: mailscanner clean distclean
6
+
7
+ all: mailscanner
8
+
9
+ mailscanner: mailscanner/tmail/Makefile
10
+ cd mailscanner/tmail; $(MAKE)
11
+
12
+ mailscanner/tmail/Makefile: mailscanner/tmail/extconf.rb
13
+ cd mailscanner/tmail; ruby extconf.rb
14
+
15
+ clean:
16
+ cd mailscanner/tmail; $(MAKE) clean
17
+
18
+ distclean:
19
+ cd mailscanner/tmail; $(MAKE) distclean
20
+
@@ -1,4 +1,4 @@
1
1
  MANIFEST
2
- tmbase64.c
2
+ mailscanner.c
3
3
  extconf.rb
4
4
  depend
@@ -0,0 +1 @@
1
+ mailscanner.o: mailscanner.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h Makefile
@@ -0,0 +1,24 @@
1
+ require 'mkmf'
2
+ require 'rbconfig'
3
+
4
+ extension_name = 'mailscanner'
5
+
6
+ arch = Config::CONFIG['sitearch']
7
+
8
+ windows = (/djgpp|(cyg|ms|bcc)win|mingw/ =~ arch)
9
+
10
+ if (ENV['NORUBYEXT'] == 'true')
11
+ File.open('Makefile', 'w') do |f|
12
+ f << "all:\n"
13
+ f << "install:\n"
14
+ end
15
+ else
16
+ #dir_config(extension_name)
17
+ if windows && ENV['make'].nil?
18
+ $LIBS += " msvcprt.lib"
19
+ else
20
+ $CFLAGS += " -D_FILE_OFFSET_BITS=64" #???
21
+ end
22
+ create_makefile(extension_name)
23
+ end
24
+
@@ -1,6 +1,6 @@
1
1
  /*
2
2
 
3
- scanner_c.c
3
+ mailscanner.c
4
4
 
5
5
  Copyright (c) 1998-2007 Minero Aoki
6
6
 
@@ -19,7 +19,7 @@
19
19
  #include "re.h"
20
20
 
21
21
 
22
- #define TMAIL_VERSION "0.10.8"
22
+ #define TMAIL_VERSION "0.11.0"
23
23
 
24
24
  static VALUE MailScanner;
25
25
  static VALUE ScanError;
@@ -58,7 +58,7 @@ mails_free(sc)
58
58
 
59
59
  /*
60
60
  * Document-method: mails_s_new
61
- *
61
+ *
62
62
  * Creates a new mail
63
63
  *
64
64
  */
@@ -100,7 +100,7 @@ mails_s_new(klass, str, ident, cmt)
100
100
 
101
101
  /*
102
102
  * Document-method: mails_debug_get
103
- *
103
+ *
104
104
  * TODO: Documentation needed
105
105
  *
106
106
  */
@@ -119,7 +119,7 @@ mails_debug_get(self)
119
119
 
120
120
  /*
121
121
  * Document-method: mails_debug_set
122
- *
122
+ *
123
123
  * TODO: Documentation needed
124
124
  *
125
125
  */
@@ -538,7 +538,7 @@ cstr2symbol(str)
538
538
  }
539
539
 
540
540
  void
541
- Init_scanner_c()
541
+ Init_mailscanner()
542
542
  {
543
543
  VALUE TMail;
544
544
  VALUE tmp;
@@ -549,7 +549,7 @@ Init_scanner_c()
549
549
  else {
550
550
  TMail = rb_define_module("TMail");
551
551
  }
552
- MailScanner = rb_define_class_under(TMail, "Scanner_C", rb_cObject);
552
+ MailScanner = rb_define_class_under(TMail, "MailScanner", rb_cObject);
553
553
 
554
554
  tmp = rb_str_new2(TMAIL_VERSION);
555
555
  rb_obj_freeze(tmp);
@@ -580,3 +580,4 @@ Init_scanner_c()
580
580
  tok_id = cstr2symbol("ID");
581
581
  tok_for = cstr2symbol("FOR");
582
582
  }
583
+
@@ -1,75 +1,52 @@
1
- =begin rdoc
2
-
3
- = Base64 handling class
4
-
5
- =end
6
- #--
7
- # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
1
+ # = TITLE:
8
2
  #
9
- # Permission is hereby granted, free of charge, to any person obtaining
10
- # a copy of this software and associated documentation files (the
11
- # "Software"), to deal in the Software without restriction, including
12
- # without limitation the rights to use, copy, modify, merge, publish,
13
- # distribute, sublicense, and/or sell copies of the Software, and to
14
- # permit persons to whom the Software is furnished to do so, subject to
15
- # the following conditions:
3
+ # Base64
16
4
  #
17
- # The above copyright notice and this permission notice shall be
18
- # included in all copies or substantial portions of the Software.
5
+ # = COPYRIGHT:
19
6
  #
20
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
27
8
  #
28
- # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
29
- # with permission of Minero Aoki.
30
- #++
31
-
32
- require 'tmail/require_arch'
9
+ # Permission is hereby granted, free of charge, to any person obtaining
10
+ # a copy of this software and associated documentation files (the
11
+ # "Software"), to deal in the Software without restriction, including
12
+ # without limitation the rights to use, copy, modify, merge, publish,
13
+ # distribute, sublicense, and/or sell copies of the Software, and to
14
+ # permit persons to whom the Software is furnished to do so, subject to
15
+ # the following conditions:
16
+ #
17
+ # The above copyright notice and this permission notice shall be
18
+ # included in all copies or substantial portions of the Software.
19
+ #
20
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ #
28
+ # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
29
+ # with permission of Minero Aoki.
33
30
 
31
+ #
34
32
  module TMail
35
33
 
36
34
  module Base64
37
35
 
38
36
  module_function
39
37
 
40
- def rb_folding_encode( str, eol = "\n", limit = 60 )
38
+ def folding_encode( str, eol = "\n", limit = 60 )
41
39
  [str].pack('m')
42
40
  end
43
41
 
44
- def rb_encode( str )
42
+ def encode( str )
45
43
  [str].pack('m').tr( "\r\n", '' )
46
44
  end
47
45
 
48
- def rb_decode( str, strict = false )
46
+ def decode( str, strict = false )
49
47
  str.unpack('m').first
50
48
  end
51
49
 
52
- begin
53
- require_arch('base64') #require 'tmail/base64.so'
54
- alias folding_encode c_folding_encode
55
- alias encode c_encode
56
- alias decode c_decode
57
- class << self
58
- alias folding_encode c_folding_encode
59
- alias encode c_encode
60
- alias decode c_decode
61
- end
62
- rescue LoadError
63
- alias folding_encode rb_folding_encode
64
- alias encode rb_encode
65
- alias decode rb_decode
66
- class << self
67
- alias folding_encode rb_folding_encode
68
- alias encode rb_encode
69
- alias decode rb_decode
70
- end
71
- end
72
-
73
50
  end
74
51
 
75
52
  end
@@ -1,36 +1,35 @@
1
- =begin rdoc
2
-
3
- = Text Encoding class
4
-
5
- =end
6
- #--
7
- # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
1
+ # = TITLE:
2
+ #
3
+ # Text Encoding class
4
+ #
5
+ # = COPYRIGHT:
8
6
  #
9
- # Permission is hereby granted, free of charge, to any person obtaining
10
- # a copy of this software and associated documentation files (the
11
- # "Software"), to deal in the Software without restriction, including
12
- # without limitation the rights to use, copy, modify, merge, publish,
13
- # distribute, sublicense, and/or sell copies of the Software, and to
14
- # permit persons to whom the Software is furnished to do so, subject to
15
- # the following conditions:
7
+ # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
16
8
  #
17
- # The above copyright notice and this permission notice shall be
18
- # included in all copies or substantial portions of the Software.
9
+ # Permission is hereby granted, free of charge, to any person obtaining
10
+ # a copy of this software and associated documentation files (the
11
+ # "Software"), to deal in the Software without restriction, including
12
+ # without limitation the rights to use, copy, modify, merge, publish,
13
+ # distribute, sublicense, and/or sell copies of the Software, and to
14
+ # permit persons to whom the Software is furnished to do so, subject to
15
+ # the following conditions:
19
16
  #
20
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+ # The above copyright notice and this permission notice shall be
18
+ # included in all copies or substantial portions of the Software.
27
19
  #
28
- # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
29
- # with permission of Minero Aoki.
30
- #++
20
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ #
28
+ # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
29
+ # with permission of Minero Aoki.
31
30
 
32
31
  require 'nkf'
33
- require 'tmail/base64.rb'
32
+ require 'tmail/base64'
34
33
  require 'tmail/stringio'
35
34
  require 'tmail/utils'
36
35
 
@@ -52,25 +51,25 @@ module TMail
52
51
  end
53
52
  end
54
53
  module_function :create_dest
55
-
54
+
56
55
  def encoded( eol = "\r\n", charset = 'j', dest = nil )
57
56
  accept_strategy Encoder, eol, charset, dest
58
57
  end
59
-
58
+
60
59
  def decoded( eol = "\n", charset = 'e', dest = nil )
61
60
  # Turn the E-Mail into a string and return it with all
62
61
  # encoded characters decoded. alias for to_s
63
62
  accept_strategy Decoder, eol, charset, dest
64
63
  end
65
-
64
+
66
65
  alias to_s decoded
67
-
66
+
68
67
  def accept_strategy( klass, eol, charset, dest = nil )
69
68
  dest ||= ''
70
69
  accept klass.new( create_dest(dest), charset, eol )
71
70
  dest
72
71
  end
73
-
72
+
74
73
  end
75
74
 
76
75
 
@@ -121,7 +120,7 @@ module TMail
121
120
  def header_body( str )
122
121
  @f << decode(str)
123
122
  end
124
-
123
+
125
124
  def space
126
125
  @f << ' '
127
126
  end
@@ -131,7 +130,7 @@ module TMail
131
130
  def lwsp( str )
132
131
  @f << str
133
132
  end
134
-
133
+
135
134
  def meta( str )
136
135
  @f << str
137
136
  end
@@ -203,7 +202,7 @@ module TMail
203
202
  def preserve_quotes=( bool )
204
203
  @preserve_quotes
205
204
  end
206
-
205
+
207
206
  def preserve_quotes
208
207
  @preserve_quotes
209
208
  end
@@ -379,7 +378,7 @@ module TMail
379
378
  i += 1
380
379
  end
381
380
  end
382
-
381
+
383
382
  METHOD_ID = {
384
383
  ?j => :extract_J,
385
384
  ?e => :extract_E,
@@ -488,7 +487,7 @@ module TMail
488
487
  # if it has text, fold there
489
488
  # check the remaining text, if too long, fold again
490
489
  # if it doesn't, then don't fold unless the line goes beyond 998 chars
491
-
490
+
492
491
  # Check the text to see if there is whitespace, or if not
493
492
  @wrapped_text = []
494
493
  until @text == ''
@@ -500,7 +499,7 @@ module TMail
500
499
  def fold_the_string
501
500
  whitespace_location = @text =~ /\s/ || @text.length
502
501
  # Is the location of the whitespace shorter than the RCF_2822_MAX_LENGTH?
503
- # if there is no whitespace in the string, then this
502
+ # if there is no whitespace in the string, then this
504
503
  unless mazsize(whitespace_location) <= 0
505
504
  @wrapped_text << @text.slice!(0...whitespace_location)
506
505
  # If it is not less, we have to wrap it destructively