Skip to content

Commit

Permalink
Merged in latest changes from rails/master
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel committed Dec 17, 2009
1 parent 418639b commit 63b124b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion actionmailer/lib/action_mailer.rb
Expand Up @@ -34,11 +34,12 @@ module ActionMailer
autoload :DeprecatedBody
autoload :Base
autoload :DeliveryMethod
autoload :MailHelper
autoload :Part
autoload :PartContainer
autoload :Quoting
autoload :TestCase
autoload :TestHelper

end

module Text
Expand Down
3 changes: 2 additions & 1 deletion actionmailer/lib/action_mailer/base.rb
Expand Up @@ -258,7 +258,8 @@ class Base
include AbstractController::Layouts

include AbstractController::Helpers

helper ActionMailer::MailHelper

if Object.const_defined?(:ActionController)
include ActionController::UrlWriter
end
Expand Down
19 changes: 19 additions & 0 deletions actionmailer/lib/action_mailer/mail_helper.rb
@@ -0,0 +1,19 @@
module ActionMailer
module MailHelper
# Uses Text::Format to take the text and format it, indented two spaces for
# each line, and wrapped at 72 columns.
def block_format(text)
formatted = text.split(/\n\r\n/).collect { |paragraph|
Text::Format.new(
:columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph
).format
}.join("\n")

# Make list points stand on their own line
formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| " #{$1} #{$2.strip}\n" }
formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { |s| " #{$1} #{$2.strip}\n" }

formatted
end
end
end
2 changes: 1 addition & 1 deletion actionmailer/test/mail_helper_test.rb
Expand Up @@ -56,7 +56,7 @@ def name_of_the_mailer_class
class MailerHelperTest < Test::Unit::TestCase
def new_mail( charset="utf-8" )
mail = Mail.new
mail.content_type(["text", "plain", { "charset" => charset }])
mail.set_content_type "text", "plain", { "charset" => charset } if charset
mail
end

Expand Down

0 comments on commit 63b124b

Please sign in to comment.