easy_multipart 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright 2010 ZephirWorks. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are
4
+ permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of
7
+ conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
10
+ of conditions and the following disclaimer in the documentation and/or other materials
11
+ provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY ZephirWorks ``AS IS'' AND ANY EXPRESS OR IMPLIED
14
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
15
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ZephirWorks OR
16
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
21
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,138 @@
1
+ easy_multipart
2
+ =============
3
+
4
+ A Ruby gem to send multipart email--the easy way.
5
+
6
+
7
+ Installation
8
+ -----------
9
+
10
+ First install the gem:
11
+
12
+ gem install easy_multipart
13
+
14
+ Then you can just include easy_multipart in your mailers:
15
+
16
+ include EasyMultipart::Base
17
+
18
+ Alternatively, to make it available to all your mailers, put this line in an
19
+ initializer:
20
+
21
+ ActiveMailer::Base.extend EasyMultipart::Base
22
+
23
+
24
+ Rationale
25
+ ---------
26
+
27
+ If you use Rails you probably know ActiveMailer, the core gem that
28
+ provides all necessary functionality to send and receive email.
29
+ ActiveMailer does let you build and send a multipart message,
30
+ with support for such features as alternative text (plain text,
31
+ HTML etc) and attachments.
32
+
33
+ However, using ActiveMailer in a practical way requires a working
34
+ understanding of the ins and outs of MIME, the relevant RFCs and
35
+ most troubling of all--the quirks of different email clients.
36
+ For instance, sending a newsletter that can be reliably rendered
37
+ by all popular email clients can be a daunting task.
38
+
39
+ easy_multipart aims to help with that; it provides a small (but
40
+ hopefully growing) set of tools to deal with the most common
41
+ tasks. It doesn't try to do too much; it does a few things, but
42
+ it tries to do them in an easy and pleasant way that should feel
43
+ familiar.
44
+
45
+
46
+ Features
47
+ --------
48
+
49
+ *Note: at this time, easy_mailer has only been tested on Rails 2.3.8
50
+ with Ruby 1.8.7, and the documentation reflects that. Expect that to
51
+ change in the near future.*
52
+
53
+ With easy_multipart you write your ActiveMailer model like you are
54
+ used to. You must not include a `body` or `part`; instead you should
55
+ invoke `easy_multipart`.
56
+
57
+ class TestModel
58
+ def test
59
+ from 'billing@example.com'
60
+ recipients 'dear.customer@some.big.company'
61
+ subject 'Your monthly invoice'
62
+
63
+ easy_multipart :body => { :name => 'Dear Customer',
64
+ :amount => '9.99' }
65
+ end
66
+ end
67
+
68
+ Your views and layouts don't need to change either; easy_multipart
69
+ respects conventions from ActiveMailer and will find them.
70
+
71
+ With this basic support in place, you are ready to take advantage of
72
+ easy_multipart features.
73
+
74
+ ### Embedded images
75
+
76
+ Embedded images are a way of sending HTML email messages that
77
+ images inside your email are loaded from the same message, instead
78
+ of off a website.
79
+
80
+ Technically, this functionality is achieved using a MIME type
81
+ of multipart/related. The concept is quite easy; however, getting
82
+ the details right can be tricky.
83
+
84
+ easy_multipart provides a very convenient helper that hides all this
85
+ complexity from you:
86
+
87
+ <%= related_image_tag 'logo.png', :file => 'email/logo.png' %>
88
+
89
+ The path is assumed to be relative to your `public/images` folder
90
+ (in fact, `image_tag` is used internally).
91
+
92
+ This helper will attach the image to the email and generate an
93
+ appropriate HTML tag:
94
+
95
+ <img src="cid:some-random-string">
96
+
97
+ The email messages generated by easy_multipart have been tested to
98
+ display correctly with:
99
+
100
+ * Apple Mail
101
+ * Gmail
102
+ * Thunderbird
103
+ * Postbox
104
+
105
+
106
+ Testing
107
+ -------
108
+
109
+ To run the tests:
110
+
111
+ **TODO**
112
+
113
+
114
+ Maintainers
115
+ -----------
116
+
117
+ * Andrea Campi (http://github.com/andreacampi)
118
+
119
+
120
+ Bugs and Feedback
121
+ -----------------
122
+
123
+ If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.
124
+
125
+ http://github.com/zephirworks/easy_multipart/issues
126
+
127
+ BSD License. Copyright 2010 ZephirWorks. http://www.zephirworks.com
128
+
129
+
130
+ Contributing
131
+ ------------
132
+
133
+ 1. Fork it.
134
+ 2. Create a branch
135
+ 3. Commit your changes
136
+ 4. Push to the branch
137
+ 5. Send a pull request
138
+
@@ -0,0 +1,89 @@
1
+ require 'easy_multipart/helper'
2
+
3
+ module EasyMultipart #:nodoc:
4
+ # This module enables EasyMultipart functionality for the mailers it is
5
+ # included in.
6
+ #
7
+ # ==== Examples
8
+ # Import easy_mailer in one mailer:
9
+ #
10
+ # class MyMailer
11
+ # import EasyMultipart::Base
12
+ # end
13
+ #
14
+ # Import easy_mailer in all the mailers of a Rails application:
15
+ #
16
+ # ActiveMailer::Base.extend EasyMultipart::Base
17
+ #
18
+ module Base
19
+
20
+ def self.included(klass) #:nodoc:
21
+ klass.helper EasyMultipart::Helper
22
+ end
23
+
24
+ protected
25
+ # Prepares the content of a multipart email.
26
+ # You can pass a +options+ hash with one key:
27
+ #
28
+ # * <tt>body</tt> - a hash which generates an instance variable named
29
+ # after each key in the hash containing the value that that key points to.
30
+ def easy_multipart(options = {}, &block)
31
+ content_type 'multipart/alternative'
32
+ TMail::HeaderField::FNAME_TO_CLASS.delete 'content-id'
33
+
34
+ if options.has_key?(:body)
35
+ body options.delete(:body)
36
+ end
37
+
38
+ add_plain_part
39
+ add_html_part
40
+ end
41
+
42
+ def add_plain_part #:nodoc:
43
+ template = find_template_for("text.plain")
44
+ return unless template
45
+
46
+ part :content_type => "text/plain",
47
+ :body => render_message(template, @body)
48
+ end
49
+
50
+ def add_html_part #:nodoc:
51
+ template = find_template_for("text.html")
52
+ return unless template
53
+
54
+ @related = {}
55
+ body = render_message(template, @body)
56
+
57
+ if @related.empty?
58
+ part :content_type => "text/html",
59
+ :body => body
60
+ return
61
+ end
62
+
63
+ part :content_type => 'multipart/related' do |related|
64
+ related.part :content_type => "text/html",
65
+ :body => body
66
+
67
+ @related.each_pair do |content_id, img|
68
+ related.part(:content_type => img[0],
69
+ :headers => {'Content-ID' => format_content_id(content_id)}) do |image|
70
+ img[1].call(image)
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ def find_template_for(format) #:nodoc:
77
+ Dir.glob("#{template_path}/#{@template}.*").select do |path|
78
+ template = template_root["#{mailer_name}/#{File.basename(path)}"]
79
+ return template if template.format == format
80
+ end
81
+ nil
82
+ end
83
+
84
+ # XXX This should generate a globally-unique Content-Id.
85
+ def format_content_id(content_id) #:nodoc:
86
+ "<#{content_id}>"
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,66 @@
1
+ module EasyMultipart #:nodoc:
2
+ # This module provides methods for generating HTML body parts that include
3
+ # embedded images.
4
+ module Helper
5
+ # Returns an HTML image tag for the +source+. The +source+ can be a full
6
+ # path or a file that exists in your public images directory.
7
+ # Alternatively, it can be a hash with these mandatory keys:
8
+ #
9
+ # * <tt>:body</tt> - An object representing the image content. Any kind of
10
+ # object can be used, as long as it responds to :to_s.
11
+ # * <tt>:content_id</tt> - A string that uniquely identifies the image
12
+ # within the current document.
13
+ #
14
+ # ==== Options
15
+ # You can add HTML attributes using the +image_options+. You can pass
16
+ # any option accepted by +image_tag+.
17
+ #
18
+ # You can pass additional options through +related_options+:
19
+ #
20
+ # * <tt>:content_type</tt> - The value to use for the Content-Type
21
+ # MIME header. If not provided it defaults to 'image/png'.
22
+ # * <tt>:transfer_encoding</tt> - The value to use for the
23
+ # Transfer-Encoding MIME header. If not provided it defaults
24
+ # to 'base64'. Unless you have special requirements, you should not
25
+ # provide a value for this key.
26
+ # * <tt>:content_disposition</tt> - The value to use for the
27
+ # Content-Disposition MIME header. If not provided it defaults to
28
+ # not generating a Content-Disposition header.
29
+ def related_image_tag(source, image_options = {}, related_options = {})
30
+ related_options.reverse_merge! :content_type => 'image/png',
31
+ :transfer_encoding => 'base64'
32
+
33
+ if source.is_a?(Hash)
34
+ unless source.has_key?(:content_id)
35
+ raise "You must specify a :content_id if you provide a :body"
36
+ end
37
+
38
+ content_id = source[:content_id]
39
+ source = source[:body].to_s
40
+ else
41
+ if source.first != '/'
42
+ assets_dir = defined?(Rails.public_path) ? Rails.public_path : "public"
43
+ source = File.join(assets_dir, "images", source)
44
+ end
45
+
46
+ content_id = File.basename(source)
47
+ source = File.read(source)
48
+ end
49
+ content_id = normalize_content_id(content_id)
50
+
51
+ @related[content_id] = [related_options[:content_type], lambda do |image|
52
+ image.body = source
53
+ image.transfer_encoding = related_options[:transfer_encoding]
54
+ image.content_disposition = related_options[:content_disposition] # default is none
55
+ end]
56
+
57
+ @template.tag(:img, image_options.merge(:src => "cid:#{content_id}"))
58
+ end
59
+
60
+ # XXX We should use a method in EasyMultipart::Base so we can share code
61
+ # with format_content_id.
62
+ def normalize_content_id(content_id) #:nodoc:
63
+ "#{content_id}"
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module EasyMultipart
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1 @@
1
+ require 'easy_multipart/base'
@@ -0,0 +1,163 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: EasyMultipart::Base</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">EasyMultipart::Base</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/easy_multipart/base_rb.html">
59
+ easy_multipart/base.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ This module enables EasyMultipart functionality for the mailers it is
78
+ included in.
79
+ </p>
80
+ <h4>Examples</h4>
81
+ <p>
82
+ Import easy_mailer in one mailer:
83
+ </p>
84
+ <pre>
85
+ class MyMailer
86
+ import EasyMultipart::Base
87
+ end
88
+ </pre>
89
+ <p>
90
+ Import easy_mailer in all the mailers of a Rails application:
91
+ </p>
92
+ <pre>
93
+ ActiveMailer::Base.extend EasyMultipart::Base
94
+ </pre>
95
+
96
+ </div>
97
+
98
+
99
+ </div>
100
+
101
+ <div id="method-list">
102
+ <h3 class="section-bar">Methods</h3>
103
+
104
+ <div class="name-list">
105
+ <a href="#M000001">easy_multipart</a>&nbsp;&nbsp;
106
+ </div>
107
+ </div>
108
+
109
+ </div>
110
+
111
+
112
+ <!-- if includes -->
113
+
114
+ <div id="section">
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ <!-- if method_list -->
124
+ <div id="methods">
125
+ <h3 class="section-bar">Protected Instance methods</h3>
126
+
127
+ <div id="method-M000001" class="method-detail">
128
+ <a name="M000001"></a>
129
+
130
+ <div class="method-heading">
131
+ <a href="Base.src/M000001.html" target="Code" class="method-signature"
132
+ onclick="popupCode('Base.src/M000001.html');return false;">
133
+ <span class="method-name">easy_multipart</span><span class="method-args">(options = {}, &amp;block)</span>
134
+ </a>
135
+ </div>
136
+
137
+ <div class="method-description">
138
+ <p>
139
+ Prepares the content of a multipart email. You can pass a <tt>options</tt>
140
+ hash with one key:
141
+ </p>
142
+ <ul>
143
+ <li><tt>body</tt> - a hash which generates an instance variable named after
144
+ each key in the hash containing the value that that key points to.
145
+
146
+ </li>
147
+ </ul>
148
+ </div>
149
+ </div>
150
+
151
+
152
+ </div>
153
+
154
+
155
+ </div>
156
+
157
+
158
+ <div id="validator-badges">
159
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
160
+ </div>
161
+
162
+ </body>
163
+ </html>
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>easy_multipart (EasyMultipart::Base)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File easy_multipart/base.rb, line 30</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">easy_multipart</span>(<span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
15
+ <span class="ruby-identifier">content_type</span> <span class="ruby-value str">'multipart/alternative'</span>
16
+ <span class="ruby-constant">TMail</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderField</span><span class="ruby-operator">::</span><span class="ruby-constant">FNAME_TO_CLASS</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">'content-id'</span>
17
+
18
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">:body</span>)
19
+ <span class="ruby-identifier">body</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:body</span>)
20
+ <span class="ruby-keyword kw">end</span>
21
+
22
+ <span class="ruby-identifier">add_plain_part</span>
23
+ <span class="ruby-identifier">add_html_part</span>
24
+ <span class="ruby-keyword kw">end</span></pre>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>easy_multipart (EasyMultipart::Base)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File easy_multipart/base.rb, line 25</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">easy_multipart</span>(<span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
15
+ <span class="ruby-identifier">content_type</span> <span class="ruby-value str">'multipart/alternative'</span>
16
+ <span class="ruby-constant">TMail</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderField</span><span class="ruby-operator">::</span><span class="ruby-constant">FNAME_TO_CLASS</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">'content-id'</span>
17
+
18
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">:body</span>)
19
+ <span class="ruby-identifier">body</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:body</span>)
20
+ <span class="ruby-keyword kw">end</span>
21
+
22
+ <span class="ruby-identifier">add_plain_part</span>
23
+ <span class="ruby-identifier">add_html_part</span>
24
+ <span class="ruby-keyword kw">end</span></pre>
25
+ </body>
26
+ </html>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>add_plain_part (EasyMultipart::Base)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File easy_multipart/base.rb, line 37</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_plain_part</span>
15
+ <span class="ruby-identifier">template</span> = <span class="ruby-identifier">find_template_for</span>(<span class="ruby-value str">&quot;text.plain&quot;</span>)
16
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">template</span>
17
+
18
+ <span class="ruby-identifier">part</span> <span class="ruby-identifier">:content_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/plain&quot;</span>,
19
+ <span class="ruby-identifier">:body</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">render_message</span>(<span class="ruby-identifier">template</span>, <span class="ruby-ivar">@body</span>)
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>add_html_part (EasyMultipart::Base)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File easy_multipart/base.rb, line 45</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_html_part</span>
15
+ <span class="ruby-identifier">template</span> = <span class="ruby-identifier">find_template_for</span>(<span class="ruby-value str">&quot;text.html&quot;</span>)
16
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">template</span>
17
+
18
+ <span class="ruby-ivar">@related</span> = {}
19
+ <span class="ruby-identifier">body</span> = <span class="ruby-identifier">render_message</span>(<span class="ruby-identifier">template</span>, <span class="ruby-ivar">@body</span>)
20
+
21
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@related</span>.<span class="ruby-identifier">empty?</span>
22
+ <span class="ruby-identifier">part</span> <span class="ruby-identifier">:content_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/html&quot;</span>,
23
+ <span class="ruby-identifier">:body</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">body</span>
24
+ <span class="ruby-keyword kw">return</span>
25
+ <span class="ruby-keyword kw">end</span>
26
+
27
+ <span class="ruby-identifier">part</span> <span class="ruby-identifier">:content_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'multipart/related'</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">related</span><span class="ruby-operator">|</span>
28
+ <span class="ruby-identifier">related</span>.<span class="ruby-identifier">part</span> <span class="ruby-identifier">:content_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/html&quot;</span>,
29
+ <span class="ruby-identifier">:body</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">body</span>
30
+
31
+ <span class="ruby-ivar">@related</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">content_id</span>, <span class="ruby-identifier">img</span><span class="ruby-operator">|</span>
32
+ <span class="ruby-identifier">related</span>.<span class="ruby-identifier">part</span>(<span class="ruby-identifier">:content_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">img</span>[<span class="ruby-value">0</span>],
33
+ <span class="ruby-identifier">:headers</span> =<span class="ruby-operator">&gt;</span> {<span class="ruby-value str">'Content-ID'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">format_content_id</span>(<span class="ruby-identifier">content_id</span>)}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">image</span><span class="ruby-operator">|</span>
34
+ <span class="ruby-identifier">img</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">call</span>(<span class="ruby-identifier">image</span>)
35
+ <span class="ruby-keyword kw">end</span>
36
+ <span class="ruby-keyword kw">end</span>
37
+ <span class="ruby-keyword kw">end</span>
38
+ <span class="ruby-keyword kw">end</span></pre>
39
+ </body>
40
+ </html>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>find_template_for (EasyMultipart::Base)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File easy_multipart/base.rb, line 71</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find_template_for</span>(<span class="ruby-identifier">format</span>)
15
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-node">&quot;#{template_path}/#{@template}.*&quot;</span>).<span class="ruby-identifier">select</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
16
+ <span class="ruby-identifier">template</span> = <span class="ruby-identifier">template_root</span>[<span class="ruby-node">&quot;#{mailer_name}/#{File.basename(path)}&quot;</span>]
17
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">template</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">format</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">format</span>
18
+ <span class="ruby-keyword kw">end</span>
19
+ <span class="ruby-keyword kw">nil</span>
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>format_content_id (EasyMultipart::Base)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File easy_multipart/base.rb, line 80</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">format_content_id</span>(<span class="ruby-identifier">content_id</span>)
15
+ <span class="ruby-node">&quot;&lt;#{content_id}&gt;&quot;</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>