File: mime.rb

package info (click to toggle)
ruby-mime 0.4.4-2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 284 kB
  • sloc: ruby: 1,187; xml: 17; makefile: 2
file content (55 lines) | stat: -rw-r--r-- 1,333 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# = Construct Multipurpose Internet Mail Extensions (MIME) messages.
#
# ---
#
# RFCs referenced during the implementation of this library:
#
# * RFC-2822 Internet Message Format (obsoletes 822)
# * RFC-2045 MIME Part 1: Format of Internet Message Bodies
# * RFC-2046 MIME Part 2: Media Types
# * RFC-2047 MIME Part 3: Message Header Extensions for Non-ASCII Text
# * RFC-2048 MIME Part 4: Registration Procedures
# * RFC-2049 MIME Part 5: Conformance Criteria and Examples
#
# ---
#
# See SOAP::MIMEMessage for other implementation ideas.
#
module MIME

  VERSION = '0.4.4'

  # Defined in RFC: https://tools.ietf.org/html/rfc5322#section-2.1.1
  MAX_LINE_LENGTH = 998

  module ID
    #
    # Generate local ID.
    #
    def self.generate_id
      timestamp = (Time.now.to_f * 1E7).to_i
      rand(1E9).to_s(36) +
      object_id.to_s(36) +
      timestamp.to_s(36)
    end

    #
    # Generate global ID for "Message-ID" or "Content-ID" header.
    #
    def self.generate_gid domain = nil
      generate_id + "@" + (domain || "#{generate_id}.local")
    end
  end

end

require 'mime/content_types'
require 'mime/content_formats/text_flowed'
require 'mime/error'
require 'mime/header'
require 'mime/media'
require 'mime/composite_media'
require 'mime/discrete_media'
require 'mime/discrete_media_factory'
require 'mime/mail'