aiwilliams-mlist 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,7 @@
1
+ *0.1.2 [] (January 7, 2009)
2
+
3
+ * Added references header when creating a reply post.
4
+ * Including display_name in from address of EmailPost.
5
+ * Improved extraction of text when it is nested inside parts.
6
+
7
+ *0.1.1 [First Working Release] (January 5, 2009)
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 1
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 0
@@ -10,6 +10,8 @@ module MList
10
10
  # list outside of the methods provided herein.
11
11
  #
12
12
  class EmailPost
13
+ include MList::Util::EmailHelpers
14
+
13
15
  ATTRIBUTE_NAMES = %w(html text mailer subject subscriber)
14
16
  ATTRIBUTE_NAMES.each do |attribute_name|
15
17
  define_method(attribute_name) do
@@ -63,9 +65,15 @@ module MList
63
65
  builder.mime_version = "1.0"
64
66
  builder.mailer = mailer
65
67
 
66
- builder.in_reply_to = parent_identifier if parent_identifier
68
+ if parent_identifier
69
+ builder.in_reply_to = parent_identifier
70
+ builder.references = [bracket(parent_identifier)]
71
+ end
72
+
73
+ from = subscriber.email_address
74
+ from = "#{subscriber.display_name} #{bracket(from)}" if subscriber.respond_to?(:display_name)
75
+ builder.from = from
67
76
 
68
- builder.from = subscriber.email_address
69
77
  builder.subject = subject
70
78
 
71
79
  if html
data/lib/mlist/list.rb CHANGED
@@ -7,7 +7,8 @@ module MList
7
7
  #
8
8
  module List
9
9
 
10
- # Answers whether this list is active or not.
10
+ # Answers whether this list is active or not. All lists are active all the
11
+ # time by default.
11
12
  #
12
13
  def active?
13
14
  true
@@ -41,8 +42,19 @@ module MList
41
42
  address
42
43
  end
43
44
 
45
+ # A list is responsible for answering the recipient subscribers.
46
+
47
+ # The subscriber of the incoming message is provided if the list would
48
+ # like to exclude it from the returned list. It is not assumed that it
49
+ # will be included or excluded, thereby allowing the list to decide. This
50
+ # default implementation does not include the sending subscriber in the
51
+ # list of recipients.
52
+ #
53
+ # Your 'subscriber' instance MUST respond to :email_address. They may
54
+ # optionally respond to :display_name.
55
+ #
44
56
  def recipients(subscriber)
45
- subscribers.collect(&:email_address) - [subscriber.email_address]
57
+ subscribers.reject {|s| s.email_address == subscriber.email_address}
46
58
  end
47
59
 
48
60
  def subscriber(email_address)
@@ -116,7 +116,7 @@ module MList
116
116
  prepare_list_headers(delivery)
117
117
  delivery.subject = list_subject(message)
118
118
  delivery.to = address
119
- delivery.bcc = message.recipients
119
+ delivery.bcc = message.recipients.collect(&:email_address)
120
120
  delivery.reply_to = "#{label} <#{post_url}>"
121
121
  end
122
122
 
@@ -14,8 +14,14 @@ module MList
14
14
  text.to_s.gsub(/\r\n?/, "\n")
15
15
  end
16
16
 
17
+ BRACKETS_RE = /\A<(.*?)>\Z/
18
+
19
+ def bracket(string)
20
+ string.blank? || string =~ BRACKETS_RE ? string : "<#{string}>"
21
+ end
22
+
17
23
  def remove_brackets(string)
18
- string =~ /\A<(.*?)>\Z/ ? $1 : string
24
+ string =~ BRACKETS_RE ? $1 : string
19
25
  end
20
26
 
21
27
  def remove_regard(string)
@@ -33,14 +33,21 @@ module MList
33
33
  end
34
34
 
35
35
  def text
36
- case tmail.content_type
37
- when 'text/plain'
38
- tmail.body.strip
39
- when 'multipart/alternative'
40
- text_part = tmail.parts.detect {|part| part.content_type == 'text/plain'}
41
- text_part.body.strip if text_part
42
- end
36
+ returning('') {|content| extract_text_content(tmail, content)}
43
37
  end
38
+
39
+ private
40
+ def extract_text_content(part, collector)
41
+ case part.content_type
42
+ when 'text/plain'
43
+ collector << part.body.strip
44
+ when 'multipart/alternative'
45
+ text_part = part.parts.detect {|part| part.content_type == 'text/plain'}
46
+ collector << text_part.body.strip if text_part
47
+ when 'multipart/mixed', 'multipart/related'
48
+ part.parts.each {|mixed_part| extract_text_content(mixed_part, collector)}
49
+ end
50
+ end
44
51
  end
45
52
 
46
53
  module TMailWriters
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aiwilliams-mlist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Williams
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-05 00:00:00 -08:00
12
+ date: 2009-02-07 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -22,6 +22,7 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
+ - CHANGELOG
25
26
  - Rakefile
26
27
  - README
27
28
  - VERSION.yml