vmail 1.3.0 → 1.3.2

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/Rakefile CHANGED
@@ -35,10 +35,13 @@ desc "Run tests"
35
35
  task :test do
36
36
  $:.unshift File.expand_path("test")
37
37
  require 'test_helper'
38
- require 'time_format_test'
39
- require 'message_formatter_test'
40
- require 'reply_template_test'
41
- require 'base64_test'
38
+ Dir.chdir("test") do
39
+ Dir['*_test.rb'].each do |x|
40
+ puts "requiring #{x}"
41
+ require x
42
+ end
43
+ end
44
+
42
45
  MiniTest::Unit.autorun
43
46
  end
44
47
 
data/lib/vmail.rb CHANGED
@@ -12,7 +12,7 @@ module Vmail
12
12
  puts "starting vmail #{Vmail::VERSION}"
13
13
 
14
14
  vim = ENV['VMAIL_VIM'] || 'vim'
15
- ENV['VMAIL_BROWSER'] ||= 'open'
15
+ ENV['VMAIL_BROWSER'] ||= RUBY_PLATFORM.downcase.include?('linux') ? 'gnome-open' : 'open'
16
16
 
17
17
  check_lynx
18
18
 
data/lib/vmail.vim CHANGED
@@ -766,6 +766,7 @@ func! s:message_window_mappings()
766
766
  noremap <silent> <buffer> <Leader>c :call <SID>compose_message()<CR>
767
767
  noremap <silent> <buffer> <Leader>h :call <SID>open_html_part()<CR><cr>
768
768
  nnoremap <silent> <buffer> q :call <SID>close_message_window()<cr>
769
+ nmap <silent> <buffer> <leader>q q
769
770
 
770
771
  nnoremap <silent> <buffer> <leader># :close<cr>:call <SID>focus_list_window()<cr>:call <SID>delete_messages("Deleted")<cr>
771
772
  nnoremap <silent> <buffer> <leader>* :call <SID>focus_list_window()<cr>:call <SID>toggle_star()<cr>
@@ -793,6 +794,7 @@ func! s:message_list_window_mappings()
793
794
  noremap <silent> <buffer> <LeftMouse> :call <SID>show_message(0)<CR>
794
795
  nnoremap <silent> <buffer> l :call <SID>show_message(1)<CR>
795
796
  noremap <silent> <buffer> q :qal!<cr>
797
+ nmap <silent> <buffer> <leader>q q
796
798
 
797
799
  noremap <silent> <buffer> <leader>* :call <SID>toggle_star()<CR>
798
800
  noremap <silent> <buffer> <leader># :call <SID>delete_messages("Deleted")<CR>
@@ -826,7 +828,6 @@ endfunc
826
828
 
827
829
  func! s:compose_window_mappings()
828
830
  noremap <silent> <buffer> <leader>q :call <SID>cancel_compose()<cr>
829
- "nmap <silent> <buffer> q <leader>q
830
831
  setlocal ai
831
832
  " setlocal textwidth=72
832
833
  autocmd CursorMoved <buffer> call <SID>toggle_textwidth()
@@ -0,0 +1,16 @@
1
+ module Vmail
2
+ module AddressQuoter
3
+
4
+ def quote_addresses(string)
5
+ email_addrs = []
6
+ string.scan(/\s*(.*?)\s*<(.+?)>(?:,|\Z)/) do |match|
7
+ # yields ["Bob Smith", "bobsmith@gmail.com"]
8
+ # then ["Jones, Rich A.", "richjones@gmail.com"]
9
+ email_addrs << "\"#{match.first}\" <#{match.last}>"
10
+ end
11
+ res = email_addrs.join(", ")
12
+ res
13
+ end
14
+
15
+ end
16
+ end
@@ -6,9 +6,12 @@ require 'mail'
6
6
  require 'net/imap'
7
7
  require 'time'
8
8
  require 'logger'
9
+ require 'vmail/address_quoter'
9
10
 
10
11
  module Vmail
11
12
  class ImapClient
13
+ include Vmail::AddressQuoter
14
+
12
15
  DIVIDER_WIDTH = 46
13
16
 
14
17
  MailboxAliases = { 'sent' => '[Gmail]/Sent Mail',
@@ -672,6 +675,10 @@ EOF
672
675
  headers = {}
673
676
  raw_headers.split("\n").each do |line|
674
677
  key, value = *line.split(/:\s*/, 2)
678
+ log [key, value].join(':')
679
+ if %w(from to cc bcc).include?(key)
680
+ value = quote_addresses(value)
681
+ end
675
682
  headers[key] = value
676
683
  end
677
684
  log "delivering message with headers: #{headers.to_yaml}"
data/lib/vmail/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vmail
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.2"
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+ require 'vmail/address_quoter'
3
+
4
+ class AddressQuoterTest < MiniTest::Unit::TestCase
5
+ include Vmail::AddressQuoter
6
+
7
+ def setup
8
+ @string = "Bob Smith <bobsmith@gmail.com>, Jones, Rich A. <richjones@gmail.com>"
9
+ @expected = '"Bob Smith" <bobsmith@gmail.com>, "Jones, Rich A." <richjones@gmail.com>'
10
+ @string2 = "Jones, Rich A. <richjones@gmail.com>, Bob Smith <bobsmith@gmail.com>"
11
+ @expected2 = '"Jones, Rich A." <richjones@gmail.com>, "Bob Smith" <bobsmith@gmail.com>'
12
+ end
13
+
14
+ def test_quoting
15
+ assert_equal @expected, quote_addresses(@string) #=> "Bob Smith" <bobsmith@gmail.com>, "Jones, Rich A." <richjones@gmail.com>
16
+ assert_equal @expected2, quote_addresses(@string2) #=> "Bob Smith" <bobsmith@gmail.com>, "Jones, Rich A." <richjones@gmail.com>
17
+ end
18
+
19
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 3
8
- - 0
9
- version: 1.3.0
8
+ - 2
9
+ version: 1.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi
@@ -69,6 +69,7 @@ files:
69
69
  - bin/vmailsend
70
70
  - lib/vmail.rb
71
71
  - lib/vmail.vim
72
+ - lib/vmail/address_quoter.rb
72
73
  - lib/vmail/contacts_extractor.rb
73
74
  - lib/vmail/imap_client.rb
74
75
  - lib/vmail/message_formatter.rb
@@ -79,6 +80,7 @@ files:
79
80
  - lib/vmail/sender.rb
80
81
  - lib/vmail/string_ext.rb
81
82
  - lib/vmail/version.rb
83
+ - test/address_quoter_test.rb
82
84
  - test/base64_test.rb
83
85
  - test/fixtures/euc-kr-header.eml
84
86
  - test/fixtures/euc-kr-html.eml
@@ -161,6 +163,7 @@ signing_key:
161
163
  specification_version: 3
162
164
  summary: A Vim interface to Gmail
163
165
  test_files:
166
+ - test/address_quoter_test.rb
164
167
  - test/base64_test.rb
165
168
  - test/fixtures/euc-kr-header.eml
166
169
  - test/fixtures/euc-kr-html.eml