rmail 0.17 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/NEWS +10 -0
  2. data/Rakefile +186 -0
  3. data/TODO +3 -0
  4. data/lib/rmail/header.rb +3 -9
  5. data/{tests → test}/addrgrammar.txt +0 -0
  6. data/{tests → test}/data/mbox.odd +0 -0
  7. data/{tests → test}/data/mbox.simple +0 -0
  8. data/{tests → test}/data/multipart/data.1 +0 -0
  9. data/{tests → test}/data/multipart/data.10 +0 -0
  10. data/{tests → test}/data/multipart/data.11 +0 -0
  11. data/{tests → test}/data/multipart/data.12 +0 -0
  12. data/{tests → test}/data/multipart/data.13 +0 -0
  13. data/{tests → test}/data/multipart/data.14 +0 -0
  14. data/{tests → test}/data/multipart/data.15 +0 -0
  15. data/{tests → test}/data/multipart/data.16 +0 -0
  16. data/{tests → test}/data/multipart/data.17 +0 -0
  17. data/{tests → test}/data/multipart/data.2 +0 -0
  18. data/{tests → test}/data/multipart/data.3 +0 -0
  19. data/{tests → test}/data/multipart/data.4 +0 -0
  20. data/{tests → test}/data/multipart/data.5 +0 -0
  21. data/{tests → test}/data/multipart/data.6 +0 -0
  22. data/{tests → test}/data/multipart/data.7 +0 -0
  23. data/{tests → test}/data/multipart/data.8 +0 -0
  24. data/{tests → test}/data/multipart/data.9 +0 -0
  25. data/{tests → test}/data/parser.badmime1 +0 -0
  26. data/{tests → test}/data/parser.badmime2 +0 -0
  27. data/{tests → test}/data/parser.nested-multipart +0 -0
  28. data/{tests → test}/data/parser.nested-simple +0 -0
  29. data/{tests → test}/data/parser.nested-simple2 +0 -0
  30. data/{tests → test}/data/parser.nested-simple3 +0 -0
  31. data/{tests → test}/data/parser.rfc822 +0 -0
  32. data/{tests → test}/data/parser.simple-mime +0 -0
  33. data/{tests → test}/data/parser/multipart.1 +0 -0
  34. data/{tests → test}/data/parser/multipart.10 +0 -0
  35. data/{tests → test}/data/parser/multipart.11 +0 -0
  36. data/{tests → test}/data/parser/multipart.12 +0 -0
  37. data/{tests → test}/data/parser/multipart.13 +0 -0
  38. data/{tests → test}/data/parser/multipart.14 +0 -0
  39. data/{tests → test}/data/parser/multipart.15 +0 -0
  40. data/{tests → test}/data/parser/multipart.16 +0 -0
  41. data/{tests → test}/data/parser/multipart.2 +0 -0
  42. data/{tests → test}/data/parser/multipart.3 +0 -0
  43. data/{tests → test}/data/parser/multipart.4 +0 -0
  44. data/{tests → test}/data/parser/multipart.5 +0 -0
  45. data/{tests → test}/data/parser/multipart.6 +0 -0
  46. data/{tests → test}/data/parser/multipart.7 +0 -0
  47. data/{tests → test}/data/parser/multipart.8 +0 -0
  48. data/{tests → test}/data/parser/multipart.9 +0 -0
  49. data/{tests → test}/data/transparency/absolute.1 +0 -0
  50. data/{tests → test}/data/transparency/absolute.2 +0 -0
  51. data/{tests → test}/data/transparency/absolute.3 +0 -0
  52. data/{tests → test}/data/transparency/absolute.4 +0 -0
  53. data/{tests → test}/data/transparency/absolute.5 +0 -0
  54. data/{tests → test}/data/transparency/absolute.6 +0 -0
  55. data/{tests → test}/data/transparency/message.1 +0 -0
  56. data/{tests → test}/data/transparency/message.2 +0 -0
  57. data/{tests → test}/data/transparency/message.3 +0 -0
  58. data/{tests → test}/data/transparency/message.4 +0 -0
  59. data/{tests → test}/data/transparency/message.5 +0 -0
  60. data/{tests → test}/data/transparency/message.6 +0 -0
  61. data/{tests → test}/runtests.rb +1 -1
  62. data/{tests → test}/testaddress.rb +9 -9
  63. data/{tests → test}/testbase.rb +9 -12
  64. data/{tests → test}/testheader.rb +70 -52
  65. data/{tests → test}/testmailbox.rb +1 -1
  66. data/{tests → test}/testmboxreader.rb +1 -1
  67. data/{tests → test}/testmessage.rb +3 -3
  68. data/{tests → test}/testparser.rb +3 -3
  69. data/{tests → test}/testparsermultipart.rb +1 -1
  70. data/{tests → test}/testpushbackreader.rb +2 -2
  71. data/{tests → test}/testserialize.rb +1 -1
  72. data/{tests → test}/testtestbase.rb +8 -4
  73. data/{tests → test}/testtranspparency.rb +3 -3
  74. data/version +1 -0
  75. metadata +153 -135
  76. data/rmail.gemspec +0 -17
data/NEWS CHANGED
@@ -1,3 +1,13 @@
1
+ = Changes in RubyMail 1.0.0 (released 2008-01-05)
2
+
3
+ - This version differs *only* in the changes required for Ruby 1.9
4
+ support. It is otherwise "bug compatible" with version 0.17. Users
5
+ of version 0.17 can safely upgrade to 1.0.0. You will lose the
6
+ ability to run the tests if you are using Ruby 1.6 (but who is doing
7
+ that these days?).
8
+
9
+ - Add a Rakefile. Add a gem hosted on rubyforge.org.
10
+
1
11
  = Changes in RubyMail 0.17 (released 2004-04-27)
2
12
 
3
13
  - Handle parsing addresses with non-ASCII display names. We don't do
@@ -0,0 +1,186 @@
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'
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 = "Matt Armstrong"
167
+ s.email = "matt@rfc20.org"
168
+ s.homepage = "http://www.rfc20.org/rubymail"
169
+
170
+ s.rubyforge_project = "rubymail"
171
+ end
172
+
173
+ #
174
+ # Use our Gem::Specification to make some package tasks.
175
+ #
176
+ Rake::GemPackageTask.new(spec) do |pkg|
177
+ pkg.need_zip = true
178
+ pkg.need_tar = true
179
+ end
180
+ end
181
+
182
+ desc "Install RubyMail using the standard install.rb script"
183
+ task :install do
184
+ ruby "install.rb"
185
+ end
186
+
data/TODO CHANGED
@@ -6,6 +6,9 @@ is missing.
6
6
  - StreamHandler should get preamble_begin and preamble_end callbacks.
7
7
  Same for epilogue_begin, epilogue_end.
8
8
 
9
+ - Add a Rakefile rule to run the tests in the super anal way (against
10
+ multiple versions of Ruby).
11
+
9
12
  = STOLEN
10
13
 
11
14
  - Header continuation issue:
@@ -263,7 +263,7 @@ module RMail
263
263
 
264
264
  # Deletes the field at the specified index and returns its value.
265
265
  def delete_at(index)
266
- @fields[index, 1] = nil
266
+ @fields.delete_at(index)
267
267
  self
268
268
  end
269
269
 
@@ -282,7 +282,7 @@ module RMail
282
282
  # Returns self.
283
283
  def each # yields: name, value
284
284
  @fields.each { |i|
285
- yield(i.name, i.value)
285
+ yield [i.name, i.value]
286
286
  }
287
287
  end
288
288
  alias each_pair each
@@ -832,15 +832,9 @@ module RMail
832
832
  # of this message. This uses the contents of the To, Cc, and Bcc
833
833
  # fields. Duplicate addresses are eliminated.
834
834
  def recipients
835
- retval = RMail::Address::List.new
836
- retval.concat(to)
837
- retval.concat(cc)
838
- retval.concat(bcc)
839
- retval.uniq
835
+ RMail::Address::List.new([ to, cc, bcc ].flatten.uniq)
840
836
  end
841
837
 
842
- # recipients
843
-
844
838
  # Retrieve a given field's value as an RMail::Address::List of
845
839
  # RMail::Address objects.
846
840
  #
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -30,6 +30,6 @@ path = File.expand_path(File.join(File.dirname($0), '..', 'lib'))
30
30
  puts "Prepending #{path} to the $LOAD_PATH"
31
31
  $LOAD_PATH.unshift(path) # get our stuff first
32
32
 
33
- Dir['tests/test*.rb'].each {|f|
33
+ Dir['test/test*.rb'].each {|f|
34
34
  require f
35
35
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #--
3
- # Copyright (C) 2001, 2002, 2003 Matt Armstrong. All rights reserved.
3
+ # Copyright (C) 2001, 2002, 2003, 2007 Matt Armstrong. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without
6
6
  # modification, are permitted provided that the following conditions are met:
@@ -25,7 +25,7 @@
25
25
  # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
26
  #
27
27
 
28
- require 'tests/testbase'
28
+ require 'test/testbase'
29
29
  require 'rmail/address'
30
30
 
31
31
  class TestRMailAddress < TestBase
@@ -44,7 +44,7 @@ class TestRMailAddress < TestBase
44
44
  def validate_method(object, method, *args)
45
45
  assert(method_list.include?(method),
46
46
  "#{method.inspect} not in #{method_list.inspect}")
47
- assert_respond_to(method, object)
47
+ assert_respond_to(object, method)
48
48
  ret = nil
49
49
  ret = object.send(method, *args)
50
50
  if block_given?
@@ -1079,7 +1079,7 @@ class TestRMailAddress < TestBase
1079
1079
  end
1080
1080
  }.to_s ]
1081
1081
  strings.each {|string|
1082
- assert_no_exception("failed for string #{string.inspect}") {
1082
+ assert_nothing_raised("failed for string #{string.inspect}") {
1083
1083
  addrs = RMail::Address.parse(string)
1084
1084
  addrs.each {|address|
1085
1085
  method_list.each {|method|
@@ -1117,13 +1117,13 @@ class TestRMailAddress < TestBase
1117
1117
  assert_equal(nil, addr.domain)
1118
1118
  assert_equal(nil, addr.local)
1119
1119
 
1120
- e = assert_exception(ArgumentError) {
1120
+ e = assert_raise(ArgumentError) {
1121
1121
  RMail::Address.new(["bob"])
1122
1122
  }
1123
- e = assert_exception(ArgumentError) {
1123
+ e = assert_raise(ArgumentError) {
1124
1124
  RMail::Address.new(Object.new)
1125
1125
  }
1126
- e = assert_exception(ArgumentError) {
1126
+ e = assert_raise(ArgumentError) {
1127
1127
  RMail::Address.new(Hash.new)
1128
1128
  }
1129
1129
  end
@@ -1176,13 +1176,13 @@ class TestRMailAddress < TestBase
1176
1176
  assert(a1.eql?(a2))
1177
1177
 
1178
1178
  a1 = RMail::Address.new("Zeus <bob@example.com>")
1179
- assert_exception(TypeError) {
1179
+ assert_raise(TypeError) {
1180
1180
  a1.eql?("bob@eaxample.com")
1181
1181
  }
1182
1182
  end
1183
1183
 
1184
1184
  def test_rmail_address_hash
1185
- assert_no_exception {
1185
+ assert_nothing_raised {
1186
1186
  RMail::Address.new.hash
1187
1187
  }
1188
1188
  a1 = RMail::Address.new("Zeus <bob@example.com>")
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #--
3
- # Copyright (C) 2001, 2002, 2003 Matt Armstrong. All rights reserved.
3
+ # Copyright (C) 2001, 2002, 2003, 2007 Matt Armstrong. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without
6
6
  # modification, are permitted provided that the following conditions are met:
@@ -27,28 +27,25 @@
27
27
 
28
28
  # Base for all the test cases, providing a default setup and teardown
29
29
 
30
- require 'rubyunit'
30
+ require 'test/unit'
31
31
  require 'rbconfig.rb'
32
32
  require 'tempfile'
33
33
  require 'find'
34
- require 'ftools'
34
+ require 'fileutils'
35
35
 
36
36
  begin
37
37
  require 'pp'
38
38
  rescue LoadError
39
39
  end
40
40
 
41
- class TestBase < RUNIT::TestCase
41
+ class TestBase < Test::Unit::TestCase
42
42
  include Config
43
43
 
44
44
  attr_reader :scratch_dir
45
45
 
46
- # NoMethodError was introduced in ruby 1.7
47
- NO_METHOD_ERROR = if RUBY_VERSION >= "1.7"
48
- NoMethodError
49
- else
50
- NameError
51
- end
46
+ def test_nothing
47
+ assert(true) # Appease Test::Unit
48
+ end
52
49
 
53
50
  # Print a string to a temporary file and return the file opened.
54
51
  # This lets you have some test data in a string, but access it with
@@ -107,7 +104,7 @@ class TestBase < RUNIT::TestCase
107
104
 
108
105
  def setup
109
106
  @scratch_dir = File.join(Dir.getwd, "_scratch_" + name)
110
- @data_dir = File.join(Dir.getwd, "tests", "data")
107
+ @data_dir = File.join(Dir.getwd, "test", "data")
111
108
  @scratch_hash = {}
112
109
 
113
110
  cleandir(@scratch_dir)
@@ -131,7 +128,7 @@ class TestBase < RUNIT::TestCase
131
128
  yield f
132
129
  }
133
130
  rescue Errno::ENOENT
134
- assert_fail("data file #{name.inspect} does not exist")
131
+ flunk("data file #{name.inspect} does not exist")
135
132
  end
136
133
 
137
134
  def data_as_string(name)