kelredd-mailer 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -153,6 +153,10 @@ Mailer provides a file cache object to abstract caching your mail to the file sy
153
153
  test_at_example.delete(key)
154
154
  end
155
155
 
156
+ # or yet even better, get Mailer::Email object (which are just special TMail::Mail objects)
157
+ emails = test_at_example.emails
158
+ email = test_at_example.email(test_at_example.keys.first)
159
+
156
160
 
157
161
  # test if the cache has any entries
158
162
  test_at_example.empty? # => false
@@ -0,0 +1,20 @@
1
+ require 'mailer/exceptions'
2
+ require 'tmail'
3
+
4
+ module Mailer
5
+
6
+ # this class inherits from TMail::Mail and just adds some niceties to it
7
+ class Email < TMail::Mail
8
+
9
+ # a way to return just a part of a multipart body, if it is multipart
10
+ def part_of_body(part_content_type)
11
+ if multipart? && (part = parts.select{|part| part.content_type == part_content_type}.try(:first))
12
+ part.body
13
+ else
14
+ body
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -1,6 +1,7 @@
1
1
  require 'useful/ruby_extensions/object'
2
2
  require 'mailer/exceptions'
3
3
  require 'mailer/mailbox'
4
+ require 'mailer/email'
4
5
 
5
6
  module Mailer
6
7
 
@@ -30,14 +31,19 @@ module Mailer
30
31
  end
31
32
 
32
33
  def read(key)
33
- returning self.key_path(key) do |path|
34
- if File.exists?(path)
35
- File.open(path, 'r') do |file|
36
- yield(file) if block_given?
37
- end
38
- else
39
- raise ArgumentError, "the file '#{path}' does not exists"
34
+ path = self.key_path(key)
35
+ if File.exists?(path)
36
+ File.open(path, 'r') do |file|
37
+ yield(file) if block_given?
40
38
  end
39
+ else
40
+ raise ArgumentError, "the file '#{path}' does not exists"
41
+ end
42
+ end
43
+
44
+ def email(key)
45
+ read(key) do |file|
46
+ Mailer::Email.parse(file.read)
41
47
  end
42
48
  end
43
49
 
@@ -79,6 +85,12 @@ module Mailer
79
85
  self.entries.collect{|file| File.basename(file)}
80
86
  end
81
87
 
88
+ def emails
89
+ self.collect do |file|
90
+ Mailer::Email.parse(file.read)
91
+ end
92
+ end
93
+
82
94
  def length
83
95
  self.entries.length
84
96
  end
@@ -3,7 +3,7 @@ module Mailer
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 3
6
+ TINY = 4
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
data/lib/mailer.rb CHANGED
@@ -9,6 +9,7 @@ require 'mailer/deliveries'
9
9
 
10
10
  require 'mailer/mailbox'
11
11
  require 'mailer/file_cache'
12
+ require 'mailer/email'
12
13
 
13
14
  # move SMTP code into abstracted SMTP class that is proxied by the Mailer module
14
15
  require 'mailer/ssl/tls'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelredd-mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-18 00:00:00 -08:00
12
+ date: 2009-11-24 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -55,6 +55,7 @@ files:
55
55
  - Rakefile
56
56
  - lib/mailer/config.rb
57
57
  - lib/mailer/deliveries.rb
58
+ - lib/mailer/email.rb
58
59
  - lib/mailer/exceptions.rb
59
60
  - lib/mailer/file_cache.rb
60
61
  - lib/mailer/mailbox.rb