Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e201fc75
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e201fc75
编写于
11月 23, 2008
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use autoload instead of explicit requires for ActionMailer
上级
04d2d043
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
63 addition
and
33 deletion
+63
-33
actionmailer/lib/action_mailer.rb
actionmailer/lib/action_mailer.rb
+24
-14
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+8
-7
actionmailer/lib/action_mailer/mail_helper.rb
actionmailer/lib/action_mailer/mail_helper.rb
+0
-2
actionmailer/lib/action_mailer/part.rb
actionmailer/lib/action_mailer/part.rb
+2
-8
actionmailer/lib/action_mailer/test_case.rb
actionmailer/lib/action_mailer/test_case.rb
+1
-1
actionmailer/lib/action_mailer/test_helper.rb
actionmailer/lib/action_mailer/test_helper.rb
+1
-0
actionmailer/lib/action_mailer/utils.rb
actionmailer/lib/action_mailer/utils.rb
+0
-1
actionmailer/lib/action_mailer/vendor/text_format.rb
actionmailer/lib/action_mailer/vendor/text_format.rb
+10
-0
actionmailer/lib/action_mailer/vendor/tmail.rb
actionmailer/lib/action_mailer/vendor/tmail.rb
+17
-0
未找到文件。
actionmailer/lib/action_mailer.rb
浏览文件 @
e201fc75
...
...
@@ -31,22 +31,32 @@
end
end
require
'action_mailer/vendor'
require
'tmail'
require
'action_mailer/base'
require
'action_mailer/helpers'
require
'action_mailer/mail_helper'
require
'action_mailer/quoting'
require
'action_mailer/test_helper'
module
ActionMailer
def
self
.
load_all!
[
Base
,
Part
,
::
Text
::
Format
,
::
Net
::
SMTP
]
end
require
'net/smtp'
autoload
:AdvAttrAccessor
,
'action_mailer/adv_attr_accessor'
autoload
:Base
,
'action_mailer/base'
autoload
:Helpers
,
'action_mailer/helpers'
autoload
:Part
,
'action_mailer/part'
autoload
:PartContainer
,
'action_mailer/part_container'
autoload
:Quoting
,
'action_mailer/quoting'
autoload
:TestCase
,
'action_mailer/test_case'
autoload
:TestHelper
,
'action_mailer/test_helper'
autoload
:Utils
,
'action_mailer/utils'
end
ActionMailer
::
Base
.
class_eval
do
include
ActionMailer
::
Quoting
include
ActionMailer
::
Helpers
module
Text
autoload
:Format
,
'action_mailer/vendor/text_format'
end
helper
MailHelper
module
Net
autoload
:SMTP
,
'net/smtp'
end
silence_warnings
{
TMail
::
Encoder
.
const_set
(
"MAX_LINE_LEN"
,
200
)
}
autoload
:MailHelper
,
'action_mailer/mail_helper'
autoload
:TMail
,
'action_mailer/vendor/tmail'
# TODO: Don't explicitly load entire lib
ActionMailer
.
load_all!
actionmailer/lib/action_mailer/base.rb
浏览文件 @
e201fc75
require
'action_mailer/adv_attr_accessor'
require
'action_mailer/part'
require
'action_mailer/part_container'
require
'action_mailer/utils'
require
'tmail/net'
module
ActionMailer
#:nodoc:
...
...
@@ -245,7 +241,7 @@ module ActionMailer #:nodoc:
# and appear last in the mime encoded message. You can also pick a different order from inside a method with
# +implicit_parts_order+.
class
Base
include
AdvAttrAccessor
,
PartContainer
include
AdvAttrAccessor
,
PartContainer
,
Quoting
,
Utils
if
Object
.
const_defined?
(
:ActionController
)
include
ActionController
::
UrlWriter
include
ActionController
::
Layout
...
...
@@ -648,11 +644,11 @@ def create_mail
if
@parts
.
empty?
m
.
set_content_type
(
real_content_type
,
nil
,
ctype_attrs
)
m
.
body
=
Utils
.
normalize_new_lines
(
body
)
m
.
body
=
normalize_new_lines
(
body
)
else
if
String
===
body
part
=
TMail
::
Mail
.
new
part
.
body
=
Utils
.
normalize_new_lines
(
body
)
part
.
body
=
normalize_new_lines
(
body
)
part
.
set_content_type
(
real_content_type
,
nil
,
ctype_attrs
)
part
.
set_content_disposition
"inline"
m
.
parts
<<
part
...
...
@@ -698,4 +694,9 @@ def perform_delivery_test(mail)
deliveries
<<
mail
end
end
Base
.
class_eval
do
include
Helpers
helper
MailHelper
end
end
actionmailer/lib/action_mailer/mail_helper.rb
浏览文件 @
e201fc75
require
'text/format'
module
MailHelper
# Uses Text::Format to take the text and format it, indented two spaces for
# each line, and wrapped at 72 columns.
...
...
actionmailer/lib/action_mailer/part.rb
浏览文件 @
e201fc75
require
'action_mailer/adv_attr_accessor'
require
'action_mailer/part_container'
require
'action_mailer/utils'
module
ActionMailer
# Represents a subpart of an email message. It shares many similar
# attributes of ActionMailer::Base. Although you can create parts manually
# and add them to the +parts+ list of the mailer, it is easier
# to use the helper methods in ActionMailer::PartContainer.
class
Part
include
ActionMailer
::
AdvAttrAccessor
include
ActionMailer
::
PartContainer
include
AdvAttrAccessor
,
PartContainer
,
Utils
# Represents the body of the part, as a string. This should not be a
# Hash (like ActionMailer::Base), but if you want a template to be rendered
...
...
@@ -64,7 +59,7 @@ def to_mail(defaults)
when
"base64"
then
part
.
body
=
TMail
::
Base64
.
folding_encode
(
body
)
when
"quoted-printable"
part
.
body
=
[
Utils
.
normalize_new_lines
(
body
)].
pack
(
"M*"
)
part
.
body
=
[
normalize_new_lines
(
body
)].
pack
(
"M*"
)
else
part
.
body
=
body
end
...
...
@@ -102,7 +97,6 @@ def to_mail(defaults)
end
private
def
squish
(
values
=
{})
values
.
delete_if
{
|
k
,
v
|
v
.
nil?
}
end
...
...
actionmailer/lib/action_mailer/test_case.rb
浏览文件 @
e201fc75
...
...
@@ -10,7 +10,7 @@ def initialize(name)
end
class
TestCase
<
ActiveSupport
::
TestCase
include
ActionMailer
::
Quoting
include
Quoting
,
TestHelper
setup
:initialize_test_deliveries
setup
:set_expected_mail
...
...
actionmailer/lib/action_mailer/test_helper.rb
浏览文件 @
e201fc75
...
...
@@ -58,6 +58,7 @@ def assert_no_emails(&block)
end
end
# TODO: Deprecate this
module
Test
module
Unit
class
TestCase
...
...
actionmailer/lib/action_mailer/utils.rb
浏览文件 @
e201fc75
...
...
@@ -3,6 +3,5 @@ module Utils #:nodoc:
def
normalize_new_lines
(
text
)
text
.
to_s
.
gsub
(
/\r\n?/
,
"
\n
"
)
end
module_function
:normalize_new_lines
end
end
actionmailer/lib/action_mailer/vendor.rb
→
actionmailer/lib/action_mailer/vendor
/text_format
.rb
浏览文件 @
e201fc75
# Prefer gems to the bundled libs.
require
'rubygems'
begin
gem
'tmail'
,
'~> 1.2.3'
rescue
Gem
::
LoadError
$:
.
unshift
"
#{
File
.
dirname
(
__FILE__
)
}
/vendor/tmail-1.2.3"
end
begin
gem
'text-format'
,
'>= 0.6.3'
rescue
Gem
::
LoadError
$:
.
unshift
"
#{
File
.
dirname
(
__FILE__
)
}
/
vendor/
text-format-0.6.3"
$:
.
unshift
"
#{
File
.
dirname
(
__FILE__
)
}
/text-format-0.6.3"
end
require
'text/format'
actionmailer/lib/action_mailer/vendor/tmail.rb
0 → 100644
浏览文件 @
e201fc75
# Prefer gems to the bundled libs.
require
'rubygems'
begin
gem
'tmail'
,
'~> 1.2.3'
rescue
Gem
::
LoadError
$:
.
unshift
"
#{
File
.
dirname
(
__FILE__
)
}
/tmail-1.2.3"
end
module
TMail
end
require
'tmail'
silence_warnings
do
TMail
::
Encoder
.
const_set
(
"MAX_LINE_LEN"
,
200
)
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录