Sha256: c09db5334a1b6403343b1af4640b9e8e133cfd5fbda327a13cb266e7ffef097a

Contents?: true

Size: 577 Bytes

Versions: 13

Compression:

Stored size: 577 Bytes

Contents

module Vmail
  module AddressQuoter

    def quote_addresses(input)
      parts = input.split /\s*,\s*/

      addrs = []
      savebin = ""

      #Group the parts together
      parts.each do |part|
        if part.include? "@"
          addrs << savebin + part
          savebin = ""
        else
          savebin = part + ", "
        end
      end

      #Quote the names
      addrs.map { |addr|
        # a little hackish
        if addr =~ /"/
          addr
        else
          addr.gsub(/^(.*) (<.*)/, '"\1" \2')
        end
      }.join(', ')
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
vmail-2.9.11 lib/vmail/address_quoter.rb
vmail-2.9.10 lib/vmail/address_quoter.rb
vmail-2.9.9 lib/vmail/address_quoter.rb
vmail-2.9.8 lib/vmail/address_quoter.rb
vmail-2.9.7 lib/vmail/address_quoter.rb
vmail-2.9.6 lib/vmail/address_quoter.rb
vmail-2.9.5 lib/vmail/address_quoter.rb
vmail-2.9.4 lib/vmail/address_quoter.rb
vmail-2.9.3 lib/vmail/address_quoter.rb
vmail-2.9.2 lib/vmail/address_quoter.rb
vmail-2.9.1 lib/vmail/address_quoter.rb
vmail-2.9.0 lib/vmail/address_quoter.rb
vmail-2.8.9 lib/vmail/address_quoter.rb