aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2009-12-17 12:23:08 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2009-12-17 12:23:08 +1100
commit63b124b043dec036403f9a88aeafdf99669064e0 (patch)
tree6eae80842608d223f0eebae957dab1b8822555c8 /actionmailer
parent418639b4cfe477d7309fa53e8b8e2472b44bda80 (diff)
downloadrails-63b124b043dec036403f9a88aeafdf99669064e0.tar.gz
rails-63b124b043dec036403f9a88aeafdf99669064e0.tar.bz2
rails-63b124b043dec036403f9a88aeafdf99669064e0.zip
Merged in latest changes from rails/master
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/lib/action_mailer.rb3
-rw-r--r--actionmailer/lib/action_mailer/base.rb3
-rw-r--r--actionmailer/lib/action_mailer/mail_helper.rb19
-rw-r--r--actionmailer/test/mail_helper_test.rb2
4 files changed, 24 insertions, 3 deletions
diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb
index e8adbf0eff..e7d396aca5 100644
--- a/actionmailer/lib/action_mailer.rb
+++ b/actionmailer/lib/action_mailer.rb
@@ -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
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index ab00bbba3c..9862c2265b 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -258,7 +258,8 @@ module ActionMailer #:nodoc:
include AbstractController::Layouts
include AbstractController::Helpers
-
+ helper ActionMailer::MailHelper
+
if Object.const_defined?(:ActionController)
include ActionController::UrlWriter
end
diff --git a/actionmailer/lib/action_mailer/mail_helper.rb b/actionmailer/lib/action_mailer/mail_helper.rb
new file mode 100644
index 0000000000..f4eeed0e42
--- /dev/null
+++ b/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
diff --git a/actionmailer/test/mail_helper_test.rb b/actionmailer/test/mail_helper_test.rb
index d04215171d..2d3565d159 100644
--- a/actionmailer/test/mail_helper_test.rb
+++ b/actionmailer/test/mail_helper_test.rb
@@ -56,7 +56,7 @@ end
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