Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 1862 Bytes
1 | =begin rdoc |
2 | |
3 | = Attachment handling file |
4 | |
5 | =end |
6 | |
7 | require 'kconv' |
8 | require 'stringio' |
9 | |
10 | module TMail |
11 | class Attachment < StringIO |
12 | attr_accessor :original_filename, :content_type |
13 | alias quoted_filename original_filename |
14 | end |
15 | |
16 | class Mail |
17 | def has_attachments? |
18 | attachment?(self) || multipart? && parts.any? { |part| attachment?(part) } |
19 | end |
20 | |
21 | # Returns true if this part's content main type is text, else returns false. |
22 | # By main type is meant "text/plain" is text. "text/html" is text |
23 | def text_content_type? |
24 | self.header['content-type'] && (self.header['content-type'].main_type == 'text') |
25 | end |
26 | |
27 | def inline_attachment?(part) |
28 | part['content-id'] || (part['content-disposition'] && part['content-disposition'].disposition == 'inline' && !part.text_content_type?) |
29 | end |
30 | |
31 | def attachment?(part) |
32 | part.disposition_is_attachment? || (!part.content_type.nil? && !part.text_content_type?) unless part.multipart? |
33 | end |
34 | |
35 | def attachments |
36 | if multipart? |
37 | parts.collect { |part| attachment(part) }.flatten.compact |
38 | elsif attachment?(self) |
39 | [attachment(self)] |
40 | end |
41 | end |
42 | |
43 | private |
44 | |
45 | def attachment(part) |
46 | if part.multipart? |
47 | part.attachments |
48 | elsif attachment?(part) |
49 | content = part.body # unquoted automatically by TMail#body |
50 | file_name = (part['content-location'] && part['content-location'].body) || |
51 | part.sub_header('content-type', 'name') || |
52 | part.sub_header('content-disposition', 'filename') || |
53 | 'noname' |
54 | |
55 | return if content.blank? |
56 | |
57 | attachment = TMail::Attachment.new(content) |
58 | attachment.original_filename = file_name.strip unless file_name.blank? |
59 | attachment.content_type = part.content_type |
60 | attachment |
61 | end |
62 | end |
63 | |
64 | end |
65 | end |