Update actionmailer with new hash syntax. #7869

Merged
merged 1 commit into from Oct 7, 2012
@@ -3,7 +3,7 @@ require 'rake/packagetask'
require 'rubygems/package_task'
desc "Default Task"
-task :default => [ :test ]
+task default: [ :test ]
# Run the unit tests
Rake::TestTask.new { |t|
@@ -29,7 +29,7 @@ Gem::PackageTask.new(spec) do |p|
end
desc "Release to gemcutter"
-task :release => :package do
+task release: :package do
require 'rake/gemcutter'
Rake::Gemcutter::Tasks.new(spec).define
Rake::Task['gem:push'].invoke
@@ -23,13 +23,13 @@ module ActionMailer
# Examples:
#
# class Notifier < ActionMailer::Base
- # default :from => 'no-reply@example.com',
- # :return_path => 'system@example.com'
+ # default from: 'no-reply@example.com',
+ # return_path: 'system@example.com'
#
# def welcome(recipient)
# @account = recipient
- # mail(:to => recipient.email_address_with_name,
- # :bcc => ["bcc@example.com", "Order Watcher <watcher@example.com>"])
+ # mail(to: recipient.email_address_with_name,
+ # bcc: ["bcc@example.com", "Order Watcher <watcher@example.com>"])
# end
# end
#
@@ -62,21 +62,21 @@ module ActionMailer
#
# If you want to explicitly render only certain templates, pass a block:
#
- # mail(:to => user.email) do |format|
+ # mail(to: user.email) do |format|
# format.text
# format.html
# end
#
# The block syntax is also useful in providing information specific to a part:
#
- # mail(:to => user.email) do |format|
+ # mail(to: user.email) do |format|
# format.text(:content_transfer_encoding => "base64")
# format.html
# end
#
# Or even to render a special view:
#
- # mail(:to => user.email) do |format|
+ # mail(to: user.email) do |format|
# format.text
# format.html { render "some_other_template" }
# end
@@ -100,12 +100,12 @@ module ActionMailer
# You can even use Action Pack helpers in these views. For example:
#
# You got a new note!
- # <%= truncate(@note.body, :length => 25) %>
+ # <%= truncate(@note.body, length: 25) %>
#
# If you need to access the subject, from or the recipients in the view, you can do that through message object:
#
# You got a new note from <%= message.from %>!
- # <%= truncate(@note.body, :length => 25) %>
+ # <%= truncate(@note.body, length: 25) %>
#
#
# = Generating URLs
@@ -116,11 +116,11 @@ module ActionMailer
#
# When using <tt>url_for</tt> you'll need to provide the <tt>:host</tt>, <tt>:controller</tt>, and <tt>:action</tt>:
#
- # <%= url_for(:host => "example.com", :controller => "welcome", :action => "greeting") %>
+ # <%= url_for(host: "example.com", controller: "welcome", action: "greeting") %>
#
# When using named routes you only need to supply the <tt>:host</tt>:
#
- # <%= users_url(:host => "example.com") %>
+ # <%= users_url(host: "example.com") %>
#
# You should use the <tt>named_route_url</tt> style (which generates absolute URLs) and avoid using the
# <tt>named_route_path</tt> style (which generates relative URLs), since clients reading the mail will
@@ -176,7 +176,7 @@ module ActionMailer
# class ApplicationMailer < ActionMailer::Base
# def welcome(recipient)
# attachments['free_book.pdf'] = File.read('path/to/file.pdf')
- # mail(:to => recipient, :subject => "New account information")
+ # mail(to: recipient, subject: "New account information")
# end
# end
#
@@ -192,7 +192,7 @@ module ActionMailer
# class ApplicationMailer < ActionMailer::Base
# def welcome(recipient)
# attachments['free_book.pdf'] = File.read('path/to/file.pdf')
- # mail(:to => recipient, :subject => "New account information", :body => "")
+ # mail(to: recipient, subject: "New account information", body: "")
# end
# end
#
@@ -204,7 +204,7 @@ module ActionMailer
# class ApplicationMailer < ActionMailer::Base
# def welcome(recipient)
# attachments.inline['photo.png'] = File.read('path/to/photo.png')
- # mail(:to => recipient, :subject => "Here is what we look like")
+ # mail(to: recipient, subject: "Here is what we look like")
# end
# end
#
@@ -220,7 +220,7 @@ module ActionMailer
#
# <h1>Please Don't Cringe</h1>
#
- # <%= image_tag attachments['photo.png'].url, :alt => 'Our Photo', :class => 'photo' -%>
+ # <%= image_tag attachments['photo.png'].url, alt: 'Our Photo', class: 'photo' -%>
#
# = Observing and Intercepting Mails
#
@@ -241,7 +241,7 @@ module ActionMailer
# default method inside the class definition:
#
# class Notifier < ActionMailer::Base
- # default :sender => 'system@example.com'
+ # default sender: 'system@example.com'
# end
#
# You can pass in any header value that a <tt>Mail::Message</tt> accepts. Out of the box,
@@ -260,7 +260,7 @@ module ActionMailer
#
# class Notifier < ActionMailer::Base
# default 'Content-Transfer-Encoding' => '7bit',
- # :content_description => 'This is a description'
+ # content_description: 'This is a description'
# end
#
# Finally, Action Mailer also supports passing <tt>Proc</tt> objects into the default hash, so you
@@ -386,10 +386,10 @@ class Base < AbstractController::Base
class_attribute :default_params
self.default_params = {
- :mime_version => "1.0",
- :charset => "UTF-8",
- :content_type => "text/plain",
- :parts_order => [ "text/plain", "text/enriched", "text/html" ]
+ mime_version: "1.0",
+ charset: "UTF-8",
+ content_type: "text/plain",
+ parts_order: [ "text/plain", "text/enriched", "text/html" ]
}.freeze
class_attribute :queue
@@ -549,17 +549,17 @@ def headers(args=nil)
#
# You can also specify overrides if you want by passing a hash instead of a string:
#
- # mail.attachments['filename.jpg'] = {:mime_type => 'application/x-gzip',
- # :content => File.read('/path/to/filename.jpg')}
+ # mail.attachments['filename.jpg'] = {mime_type: 'application/x-gzip',
+ # content: File.read('/path/to/filename.jpg')}
#
# If you want to use a different encoding than Base64, you can pass an encoding in,
# but then it is up to you to pass in the content pre-encoded, and don't expect
# Mail to know how to decode this data:
#
# file_content = SpecialEncode(File.read('/path/to/filename.jpg'))
- # mail.attachments['filename.jpg'] = {:mime_type => 'application/x-gzip',
- # :encoding => 'SpecialEncoding',
- # :content => file_content }
+ # mail.attachments['filename.jpg'] = {mime_type: 'application/x-gzip',
+ # encoding: 'SpecialEncoding',
+ # content: file_content }
#
# You can also search for specific attachments:
#
@@ -597,9 +597,9 @@ def attachments
# class method:
#
# class Notifier < ActionMailer::Base
- # self.default :from => 'no-reply@test.lindsaar.net',
- # :bcc => 'email_logger@test.lindsaar.net',
- # :reply_to => 'bounces@test.lindsaar.net'
+ # self.default from: 'no-reply@test.lindsaar.net',
+ # bcc: 'email_logger@test.lindsaar.net',
+ # reply_to: 'bounces@test.lindsaar.net'
# end
#
# If you need other headers not listed above, you can either pass them in
@@ -621,10 +621,10 @@ def attachments
# For example:
#
# class Notifier < ActionMailer::Base
- # default :from => 'no-reply@test.lindsaar.net',
+ # default from: 'no-reply@test.lindsaar.net',
#
# def welcome
- # mail(:to => 'mikel@test.lindsaar.net')
+ # mail(to: 'mikel@test.lindsaar.net')
# end
# end
#
@@ -633,22 +633,22 @@ def attachments
#
# However, those can be customized:
#
- # mail(:template_path => 'notifications', :template_name => 'another')
+ # mail(template_path: 'notifications', template_name: 'another')
#
# And now it will look for all templates at "app/views/notifications" with name "another".
#
# If you do pass a block, you can render specific templates of your choice:
#
- # mail(:to => 'mikel@test.lindsaar.net') do |format|
+ # mail(to: 'mikel@test.lindsaar.net') do |format|
# format.text
# format.html
# end
#
# You can even render text directly without using a template:
#
- # mail(:to => 'mikel@test.lindsaar.net') do |format|
- # format.text { render :text => "Hello Mikel!" }
- # format.html { render :text => "<h1>Hello Mikel!</h1>" }
+ # mail(to: 'mikel@test.lindsaar.net') do |format|
+ # format.text { render text: "Hello Mikel!" }
+ # format.html { render text: "<h1>Hello Mikel!</h1>" }
# end
#
# Which will render a <tt>multipart/alternative</tt> email with <tt>text/plain</tt> and
@@ -657,7 +657,7 @@ def attachments
# The block syntax also allows you to customize the part headers if desired:
#
# mail(:to => 'mikel@test.lindsaar.net') do |format|
- # format.text(:content_transfer_encoding => "base64")
+ # format.text(content_transfer_encoding: "base64")
# format.html
# end
#
@@ -730,7 +730,7 @@ def set_content_type(m, user_content_type, class_default)
# humanized version of the <tt>action_name</tt>.
def default_i18n_subject #:nodoc:
mailer_scope = self.class.mailer_name.tr('/', '.')
- I18n.t(:subject, :scope => [mailer_scope, action_name], :default => action_name.humanize)
+ I18n.t(:subject, scope: [mailer_scope, action_name], default: action_name.humanize)
end
def collect_responses_and_parts_order(headers) #:nodoc:
@@ -743,8 +743,8 @@ def collect_responses_and_parts_order(headers) #:nodoc:
responses = collector.responses
elsif headers[:body]
responses << {
- :body => headers.delete(:body),
- :content_type => self.class.default[:content_type] || "text/plain"
+ body: headers.delete(:body),
+ content_type: self.class.default[:content_type] || "text/plain"
}
else
templates_path = headers.delete(:template_path) || self.class.mailer_name
@@ -754,8 +754,8 @@ def collect_responses_and_parts_order(headers) #:nodoc:
self.formats = template.formats
responses << {
- :body => render(:template => template),
- :content_type => template.type.to_s
+ body: render(template: template),
+ content_type: template.type.to_s
}
end
end
@@ -21,7 +21,7 @@ def any(*args, &block)
alias :all :any
def custom(mime, options={})
- options.reverse_merge!(:content_type => mime.to_s)
+ options.reverse_merge!(content_type: mime.to_s)
@context.formats = [mime.to_sym]
options[:body] = block_given? ? yield : @default_render.call
@responses << options
@@ -20,27 +20,27 @@ module DeliveryMethods
self.delivery_method = :smtp
add_delivery_method :smtp, Mail::SMTP,
- :address => "localhost",
- :port => 25,
- :domain => 'localhost.localdomain',
- :user_name => nil,
- :password => nil,
- :authentication => nil,
- :enable_starttls_auto => true
+ address: "localhost",
+ port: 25,
+ domain: 'localhost.localdomain',
+ user_name: nil,
+ password: nil,
+ authentication: nil,
+ enable_starttls_auto: true
add_delivery_method :file, Mail::FileDelivery,
- :location => defined?(Rails.root) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails"
+ location: defined?(Rails.root) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails"
add_delivery_method :sendmail, Mail::Sendmail,
- :location => '/usr/sbin/sendmail',
- :arguments => '-i -t'
+ location: '/usr/sbin/sendmail',
+ arguments: '-i -t'
add_delivery_method :test, Mail::TestMailer
end
module ClassMethods
# Provides a list of emails that have been delivered by Mail::TestMailer
- delegate :deliveries, :deliveries=, :to => Mail::TestMailer
+ delegate :deliveries, :deliveries=, to: Mail::TestMailer
# Adds a new delivery method through the given class using the given
# symbol as alias and the default options supplied.
@@ -3,7 +3,7 @@ module Generators
class MailerGenerator < NamedBase
source_root File.expand_path("../templates", __FILE__)
- argument :actions, :type => :array, :default => [], :banner => "method method"
+ argument :actions, type: :array, default: [], banner: "method method"
check_class_collision
def create_mailer_file
@@ -3,9 +3,9 @@
class AssetHostMailer < ActionMailer::Base
def email_with_asset
- mail :to => 'test@localhost',
- :subject => 'testing email containing asset path while asset_host is set',
- :from => 'tester@example.com'
+ mail to: 'test@localhost',
+ subject: 'testing email containing asset path while asset_host is set',
+ from: 'tester@example.com'
end
end
Oops, something went wrong.