Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Extract comments from an address when it is part of a group #487

Merged
merged 1 commit into from

2 participants

Bob Potter Jeremy Kemper
Bob Potter

The current code does not add the #comments method to addresses which are part of a group

Jeremy Kemper
Collaborator

TIL about address comments. Looks good. Could you rebase against latest master?

Bob Potter

Rebased.

Jeremy Kemper jeremy merged commit 330b724 into from
Jeremy Kemper jeremy referenced this pull request from a commit
Jeremy Kemper jeremy Update CHANGELOG for #484, #487 0213e7f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 20, 2013
  1. Bob Potter
This page is out of date. Refresh to see the latest.
36 lib/mail/parsers/rfc2822.treetop
View
@@ -222,7 +222,22 @@ module Mail
end
rule mailbox
- name_addr / addr_spec
+ (name_addr / addr_spec) {
+ def dig_comments(comments, elements)
+ elements.each { |elem|
+ if elem.respond_to?(:comment)
+ comments << elem.comment
+ end
+ dig_comments(comments, elem.elements) if elem.elements
+ }
+ end
+
+ def comments
+ comments = []
+ dig_comments(comments, elements)
+ comments
+ end
+ }
end
rule address
@@ -244,24 +259,7 @@ module Mail
end
} /
- mailbox {
-
- def dig_comments(comments, elements)
- elements.each { |elem|
- if elem.respond_to?(:comment)
- comments << elem.comment
- end
- dig_comments(comments, elem.elements) if elem.elements
- }
- end
-
- def comments
- comments = []
- dig_comments(comments, elements)
- comments
- end
-
- }
+ mailbox
end
rule address_list
7 spec/mail/elements/address_list_spec.rb
View
@@ -75,6 +75,13 @@
a.addresses.map {|addr| addr.to_s }.should eq result
end
+ it "should extract comments in addreses which are part of a group" do
+ parse_text = "group: jimmy <jimmy@(comment)example.com>;";
+ result = ["comment"]
+ a = Mail::AddressList.new(parse_text)
+ a.addresses.first.comments.should eq result
+ end
+
end
describe "functionality" do
2  spec/mail/example_emails_spec.rb
View
@@ -187,7 +187,7 @@
it "should handle the rfc whitespace test email" do
mail = Mail.read(fixture('emails', 'rfc2822', 'example10.eml'))
mail.from.should eq ["pete(his account)@silly.test"]
- mail.to.should eq ["c@(Chris's host.)public.example", "joe@example.org", "jdoe@one.test"]
+ mail.to.should eq ["c@public.example", "joe@example.org", "jdoe@one.test"]
mail[:cc].group_names.should eq ['(Empty list)(start)Undisclosed recipients ']
mail.date.should eq ::DateTime.parse('Thu, 13 Feb 1969 23:32 -0330')
mail.message_id.should eq 'testabcd.1234@silly.test'
Something went wrong with that request. Please try again.