File: ruby.rb

package info (click to toggle)
ruby-mail 2.6.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,092 kB
  • ctags: 1,281
  • sloc: ruby: 43,919; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module Mail
  module Parsers
    module Ragel
      module Ruby
        def self.silence_warnings
          original_verbose = $VERBOSE
          $VERBOSE = nil
          yield
          $VERBOSE = original_verbose
        end
        # Ragel-generated parsers give a lot of warnings
        # and may cause logs to balloon in size
        silence_warnings do
          Mail::Parsers::Ragel::FIELD_PARSERS.each do |field_parser|
            require "mail/parsers/ragel/ruby/machines/#{field_parser}_machine"
          end
        end

        MACHINE_LIST = {
          :address_lists => AddressListsMachine,
          :phrase_lists => PhraseListsMachine,
          :date_time => DateTimeMachine,
          :received => ReceivedMachine,
          :message_ids => MessageIdsMachine,
          :envelope_from => EnvelopeFromMachine,
          :mime_version => MimeVersionMachine,
          :content_type => ContentTypeMachine,
          :content_disposition => ContentDispositionMachine,
          :content_transfer_encoding => ContentTransferEncodingMachine,
          :content_location => ContentLocationMachine
        }

        def self.parse(machine, string)
          MACHINE_LIST[machine].parse(string)
        end
      end
    end
  end
end