vmail 1.3.4 → 1.3.5

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.
@@ -1,17 +1,25 @@
1
1
  module Vmail
2
2
  module AddressQuoter
3
3
 
4
- def quote_addresses(string)
5
- return string
6
- email_addrs = []
7
- string.scan(/\s*(.*?)\s*<(.+?)>(?:,|\Z)/) do |match|
8
- # yields ["Bob Smith", "bobsmith@gmail.com"]
9
- # then ["Jones, Rich A.", "richjones@gmail.com"]
10
- email_addrs << "\"#{match.first}\" <#{match.last}>"
4
+ def quote_addresses(input)
5
+ parts = input.split /\s*,\s*/
6
+
7
+ addrs = []
8
+ savebin = ""
9
+
10
+ #Group the parts together
11
+ parts.each do |part|
12
+ if part.include? "@"
13
+ addrs << savebin + part
14
+ savebin = ""
15
+ else
16
+ savebin = part + ", "
17
+ end
11
18
  end
12
- res = email_addrs.join(", ")
13
- res
19
+
20
+ #Quote the names
21
+ addrs.map { |addr| addr.gsub(/^(.*) (<.*)/, '"\1" \2') }.join(', ')
14
22
  end
15
-
23
+
16
24
  end
17
25
  end
@@ -1,3 +1,3 @@
1
1
  module Vmail
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
3
  end
@@ -15,5 +15,13 @@ class AddressQuoterTest < MiniTest::Unit::TestCase
15
15
  assert_equal @expected, quote_addresses(@string) #=> "Bob Smith" <bobsmith@gmail.com>, "Jones, Rich A." <richjones@gmail.com>
16
16
  assert_equal @expected2, quote_addresses(@string2) #=> "Bob Smith" <bobsmith@gmail.com>, "Jones, Rich A." <richjones@gmail.com>
17
17
  end
18
+
19
+ def test_quoting_with_bare_email_address
20
+ string = "richjones@gmail.com"
21
+ assert_equal string, quote_addresses(string)
18
22
 
23
+ string = "Bob Smith <bobsmith@gmail.com>, Jones, Rich A. <richjones@gmail.com>, peterbaker@gmail.com"
24
+ expected = %q("Bob Smith" <bobsmith@gmail.com>, "Jones, Rich A." <richjones@gmail.com>, peterbaker@gmail.com)
25
+ assert_equal expected, quote_addresses(string)
26
+ end
19
27
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 3
8
- - 4
9
- version: 1.3.4
8
+ - 5
9
+ version: 1.3.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-12 00:00:00 -05:00
17
+ date: 2011-01-14 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -162,5 +162,20 @@ rubygems_version: 1.3.7
162
162
  signing_key:
163
163
  specification_version: 3
164
164
  summary: A Vim interface to Gmail
165
- test_files: []
166
-
165
+ test_files:
166
+ - test/address_quoter_test.rb
167
+ - test/base64_test.rb
168
+ - test/fixtures/euc-kr-header.eml
169
+ - test/fixtures/euc-kr-html.eml
170
+ - test/fixtures/google-affiliate.eml
171
+ - test/fixtures/htmlbody.eml
172
+ - test/fixtures/moleskine-html.eml
173
+ - test/fixtures/reply-template-encoding-test.eml
174
+ - test/fixtures/reply_all.eml
175
+ - test/fixtures/rfc_part.eml
176
+ - test/fixtures/textbody-nocontenttype.eml
177
+ - test/fixtures/with-attachments.eml
178
+ - test/message_formatter_test.rb
179
+ - test/reply_template_test.rb
180
+ - test/test_helper.rb
181
+ - test/time_format_test.rb