actionmailer 3.2.22.5 → 4.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -107
- data/MIT-LICENSE +1 -1
- data/README.rdoc +20 -18
- data/lib/action_mailer.rb +6 -8
- data/lib/action_mailer/base.rb +145 -100
- data/lib/action_mailer/collector.rb +4 -4
- data/lib/action_mailer/delivery_methods.rb +21 -24
- data/lib/action_mailer/log_subscriber.rb +5 -5
- data/lib/action_mailer/mail_helper.rb +6 -8
- data/lib/action_mailer/railtie.rb +2 -2
- data/lib/action_mailer/test_case.rb +7 -4
- data/lib/action_mailer/test_helper.rb +8 -9
- data/lib/action_mailer/version.rb +4 -4
- data/lib/rails/generators/mailer/USAGE +4 -5
- data/lib/rails/generators/mailer/mailer_generator.rb +1 -1
- data/lib/rails/generators/mailer/templates/mailer.rb +3 -3
- metadata +16 -17
@@ -2,7 +2,7 @@ require 'abstract_controller/collector'
|
|
2
2
|
require 'active_support/core_ext/hash/reverse_merge'
|
3
3
|
require 'active_support/core_ext/array/extract_options'
|
4
4
|
|
5
|
-
module ActionMailer
|
5
|
+
module ActionMailer
|
6
6
|
class Collector
|
7
7
|
include AbstractController::Collector
|
8
8
|
attr_reader :responses
|
@@ -15,13 +15,13 @@ module ActionMailer #:nodoc:
|
|
15
15
|
|
16
16
|
def any(*args, &block)
|
17
17
|
options = args.extract_options!
|
18
|
-
raise "You have to supply at least one format" if args.empty?
|
18
|
+
raise ArgumentError, "You have to supply at least one format" if args.empty?
|
19
19
|
args.each { |type| send(type, options.dup, &block) }
|
20
20
|
end
|
21
21
|
alias :all :any
|
22
22
|
|
23
|
-
def custom(mime, options={})
|
24
|
-
options.reverse_merge!(:
|
23
|
+
def custom(mime, options = {})
|
24
|
+
options.reverse_merge!(content_type: mime.to_s)
|
25
25
|
@context.formats = [mime.to_sym]
|
26
26
|
options[:body] = block_given? ? yield : @default_render.call
|
27
27
|
@responses << options
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'tmpdir'
|
2
2
|
|
3
3
|
module ActionMailer
|
4
|
-
# This module handles everything related to mail delivery, from registering
|
5
|
-
# delivery methods to configuring the mail object to be sent.
|
4
|
+
# This module handles everything related to mail delivery, from registering
|
5
|
+
# new delivery methods to configuring the mail object to be sent.
|
6
6
|
module DeliveryMethods
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
@@ -20,44 +20,41 @@ module ActionMailer
|
|
20
20
|
self.delivery_method = :smtp
|
21
21
|
|
22
22
|
add_delivery_method :smtp, Mail::SMTP,
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
23
|
+
address: "localhost",
|
24
|
+
port: 25,
|
25
|
+
domain: 'localhost.localdomain',
|
26
|
+
user_name: nil,
|
27
|
+
password: nil,
|
28
|
+
authentication: nil,
|
29
|
+
enable_starttls_auto: true
|
30
30
|
|
31
31
|
add_delivery_method :file, Mail::FileDelivery,
|
32
|
-
:
|
32
|
+
location: defined?(Rails.root) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails"
|
33
33
|
|
34
34
|
add_delivery_method :sendmail, Mail::Sendmail,
|
35
|
-
:
|
36
|
-
:
|
35
|
+
location: '/usr/sbin/sendmail',
|
36
|
+
arguments: '-i -t'
|
37
37
|
|
38
38
|
add_delivery_method :test, Mail::TestMailer
|
39
39
|
end
|
40
40
|
|
41
41
|
module ClassMethods
|
42
42
|
# Provides a list of emails that have been delivered by Mail::TestMailer
|
43
|
-
delegate :deliveries, :deliveries=, :
|
43
|
+
delegate :deliveries, :deliveries=, to: Mail::TestMailer
|
44
44
|
|
45
|
-
# Adds a new delivery method through the given class using the given
|
46
|
-
# as alias and the default options supplied
|
47
|
-
#
|
48
|
-
# Example:
|
45
|
+
# Adds a new delivery method through the given class using the given
|
46
|
+
# symbol as alias and the default options supplied.
|
49
47
|
#
|
50
48
|
# add_delivery_method :sendmail, Mail::Sendmail,
|
51
|
-
# :
|
52
|
-
# :
|
53
|
-
#
|
49
|
+
# location: '/usr/sbin/sendmail',
|
50
|
+
# arguments: '-i -t'
|
54
51
|
def add_delivery_method(symbol, klass, default_options={})
|
55
52
|
class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
|
56
53
|
send(:"#{symbol}_settings=", default_options)
|
57
54
|
self.delivery_methods = delivery_methods.merge(symbol.to_sym => klass).freeze
|
58
55
|
end
|
59
56
|
|
60
|
-
def wrap_delivery_behavior(mail, method=nil)
|
57
|
+
def wrap_delivery_behavior(mail, method=nil, options=nil) # :nodoc:
|
61
58
|
method ||= self.delivery_method
|
62
59
|
mail.delivery_handler = self
|
63
60
|
|
@@ -65,8 +62,8 @@ module ActionMailer
|
|
65
62
|
when NilClass
|
66
63
|
raise "Delivery method cannot be nil"
|
67
64
|
when Symbol
|
68
|
-
if klass = delivery_methods[method
|
69
|
-
mail.delivery_method(klass,
|
65
|
+
if klass = delivery_methods[method]
|
66
|
+
mail.delivery_method(klass,(send(:"#{method}_settings") || {}).merge!(options || {}))
|
70
67
|
else
|
71
68
|
raise "Invalid delivery method #{method.inspect}"
|
72
69
|
end
|
@@ -79,7 +76,7 @@ module ActionMailer
|
|
79
76
|
end
|
80
77
|
end
|
81
78
|
|
82
|
-
def wrap_delivery_behavior!(*args)
|
79
|
+
def wrap_delivery_behavior!(*args) # :nodoc:
|
83
80
|
self.class.wrap_delivery_behavior(message, *args)
|
84
81
|
end
|
85
82
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'active_support/core_ext/array/wrap'
|
2
|
-
|
3
1
|
module ActionMailer
|
4
2
|
class LogSubscriber < ActiveSupport::LogSubscriber
|
5
3
|
def deliver(event)
|
6
|
-
|
7
|
-
|
4
|
+
return unless logger.info?
|
5
|
+
recipients = Array(event.payload[:to]).join(', ')
|
6
|
+
info("\nSent mail to #{recipients} (#{event.duration.round(1)}ms)")
|
8
7
|
debug(event.payload[:mail])
|
9
8
|
end
|
10
9
|
|
11
10
|
def receive(event)
|
12
|
-
|
11
|
+
return unless logger.info?
|
12
|
+
info("\nReceived mail (#{event.duration.round(1)}ms)")
|
13
13
|
debug(event.payload[:mail])
|
14
14
|
end
|
15
15
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module ActionMailer
|
2
2
|
module MailHelper
|
3
|
-
#
|
4
|
-
#
|
3
|
+
# Take the text and format it, indented two spaces for each line, and
|
4
|
+
# wrapped at 72 columns.
|
5
5
|
def block_format(text)
|
6
|
-
formatted = text.split(/\n\r
|
6
|
+
formatted = text.split(/\n\r?\n/).collect { |paragraph|
|
7
7
|
format_paragraph(paragraph)
|
8
|
-
}.join("\n")
|
8
|
+
}.join("\n\n")
|
9
9
|
|
10
10
|
# Make list points stand on their own line
|
11
11
|
formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| " #{$1} #{$2.strip}\n" }
|
@@ -31,9 +31,7 @@ module ActionMailer
|
|
31
31
|
|
32
32
|
# Returns +text+ wrapped at +len+ columns and indented +indent+ spaces.
|
33
33
|
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# my_text = "Here is a sample text with more than 40 characters"
|
34
|
+
# my_text = 'Here is a sample text with more than 40 characters'
|
37
35
|
#
|
38
36
|
# format_paragraph(my_text, 25, 4)
|
39
37
|
# # => " Here is a sample text with\n more than 40 characters"
|
@@ -41,7 +39,7 @@ module ActionMailer
|
|
41
39
|
sentences = [[]]
|
42
40
|
|
43
41
|
text.split.each do |word|
|
44
|
-
if (sentences.last + [word]).join(' ').length > len
|
42
|
+
if sentences.first.present? && (sentences.last + [word]).join(' ').length > len
|
45
43
|
sentences << [word]
|
46
44
|
else
|
47
45
|
sentences.last << word
|
@@ -3,8 +3,9 @@ require "rails"
|
|
3
3
|
require "abstract_controller/railties/routes_helpers"
|
4
4
|
|
5
5
|
module ActionMailer
|
6
|
-
class Railtie < Rails::Railtie
|
6
|
+
class Railtie < Rails::Railtie # :nodoc:
|
7
7
|
config.action_mailer = ActiveSupport::OrderedOptions.new
|
8
|
+
config.eager_load_namespaces << ActionMailer
|
8
9
|
|
9
10
|
initializer "action_mailer.logger" do
|
10
11
|
ActiveSupport.on_load(:action_mailer) { self.logger ||= Rails.logger }
|
@@ -19,7 +20,6 @@ module ActionMailer
|
|
19
20
|
options.stylesheets_dir ||= paths["public/stylesheets"].first
|
20
21
|
|
21
22
|
# make sure readers methods get compiled
|
22
|
-
options.asset_path ||= app.config.asset_path
|
23
23
|
options.asset_host ||= app.config.asset_host
|
24
24
|
options.relative_url_root ||= app.config.relative_url_root
|
25
25
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'active_support/
|
1
|
+
require 'active_support/test_case'
|
2
2
|
|
3
3
|
module ActionMailer
|
4
4
|
class NonInferrableMailerError < ::StandardError
|
@@ -13,6 +13,7 @@ module ActionMailer
|
|
13
13
|
module Behavior
|
14
14
|
extend ActiveSupport::Concern
|
15
15
|
|
16
|
+
include ActiveSupport::Testing::ConstantLookup
|
16
17
|
include TestHelper
|
17
18
|
|
18
19
|
included do
|
@@ -42,9 +43,11 @@ module ActionMailer
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def determine_default_mailer(name)
|
45
|
-
name
|
46
|
-
|
47
|
-
|
46
|
+
mailer = determine_constant_from_test_name(name) do |constant|
|
47
|
+
Class === constant && constant < ActionMailer::Base
|
48
|
+
end
|
49
|
+
raise NonInferrableMailerError.new(name) if mailer.nil?
|
50
|
+
mailer
|
48
51
|
end
|
49
52
|
end
|
50
53
|
|
@@ -1,27 +1,26 @@
|
|
1
1
|
module ActionMailer
|
2
2
|
module TestHelper
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
3
|
# Asserts that the number of emails sent matches the given number.
|
6
4
|
#
|
7
5
|
# def test_emails
|
8
6
|
# assert_emails 0
|
9
|
-
# ContactMailer.
|
7
|
+
# ContactMailer.welcome.deliver
|
10
8
|
# assert_emails 1
|
11
|
-
# ContactMailer.
|
9
|
+
# ContactMailer.welcome.deliver
|
12
10
|
# assert_emails 2
|
13
11
|
# end
|
14
12
|
#
|
15
|
-
# If a block is passed, that block should cause the specified number of
|
13
|
+
# If a block is passed, that block should cause the specified number of
|
14
|
+
# emails to be sent.
|
16
15
|
#
|
17
16
|
# def test_emails_again
|
18
17
|
# assert_emails 1 do
|
19
|
-
# ContactMailer.
|
18
|
+
# ContactMailer.welcome.deliver
|
20
19
|
# end
|
21
20
|
#
|
22
21
|
# assert_emails 2 do
|
23
|
-
# ContactMailer.
|
24
|
-
# ContactMailer.
|
22
|
+
# ContactMailer.welcome.deliver
|
23
|
+
# ContactMailer.welcome.deliver
|
25
24
|
# end
|
26
25
|
# end
|
27
26
|
def assert_emails(number)
|
@@ -39,7 +38,7 @@ module ActionMailer
|
|
39
38
|
#
|
40
39
|
# def test_emails
|
41
40
|
# assert_no_emails
|
42
|
-
# ContactMailer.
|
41
|
+
# ContactMailer.welcome.deliver
|
43
42
|
# assert_emails 1
|
44
43
|
# end
|
45
44
|
#
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Description:
|
2
2
|
============
|
3
|
-
Stubs out a new mailer and its views.
|
3
|
+
Stubs out a new mailer and its views. Passes the mailer name, either
|
4
4
|
CamelCased or under_scored, and an optional list of emails as arguments.
|
5
5
|
|
6
6
|
This generates a mailer class in app/mailers and invokes your template
|
@@ -10,9 +10,8 @@ Example:
|
|
10
10
|
========
|
11
11
|
rails generate mailer Notifications signup forgot_password invoice
|
12
12
|
|
13
|
-
creates a Notifications mailer class, views,
|
13
|
+
creates a Notifications mailer class, views, and test:
|
14
14
|
Mailer: app/mailers/notifications.rb
|
15
|
-
Views: app/views/notifications/signup.erb [...]
|
16
|
-
Test: test/
|
17
|
-
Fixtures: test/fixtures/notifications/signup [...]
|
15
|
+
Views: app/views/notifications/signup.text.erb [...]
|
16
|
+
Test: test/mailers/notifications_test.rb
|
18
17
|
|
@@ -3,7 +3,7 @@ module Rails
|
|
3
3
|
class MailerGenerator < NamedBase
|
4
4
|
source_root File.expand_path("../templates", __FILE__)
|
5
5
|
|
6
|
-
argument :actions, :
|
6
|
+
argument :actions, type: :array, default: [], banner: "method method"
|
7
7
|
check_class_collision
|
8
8
|
|
9
9
|
def create_mailer_file
|
@@ -1,17 +1,17 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
2
|
class <%= class_name %> < ActionMailer::Base
|
3
|
-
default
|
3
|
+
default from: "from@example.com"
|
4
4
|
<% actions.each do |action| -%>
|
5
5
|
|
6
6
|
# Subject can be set in your I18n file at config/locales/en.yml
|
7
7
|
# with the following lookup:
|
8
8
|
#
|
9
|
-
# en.<%= file_path.
|
9
|
+
# en.<%= file_path.tr("/",".") %>.<%= action %>.subject
|
10
10
|
#
|
11
11
|
def <%= action %>
|
12
12
|
@greeting = "Hi"
|
13
13
|
|
14
|
-
mail
|
14
|
+
mail to: "to@example.org"
|
15
15
|
end
|
16
16
|
<% end -%>
|
17
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionmailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.0.beta1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.0.0.beta1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mail
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.5.
|
33
|
+
version: 2.5.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.5.
|
40
|
+
version: 2.5.3
|
41
41
|
description: Email on Rails. Compose, deliver, receive, and test emails using the
|
42
42
|
familiar controller/view pattern. First-class support for multipart email and attachments.
|
43
43
|
email: david@loudthinking.com
|
@@ -46,9 +46,8 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- CHANGELOG.md
|
49
|
-
- MIT-LICENSE
|
50
49
|
- README.rdoc
|
51
|
-
-
|
50
|
+
- MIT-LICENSE
|
52
51
|
- lib/action_mailer/base.rb
|
53
52
|
- lib/action_mailer/collector.rb
|
54
53
|
- lib/action_mailer/delivery_methods.rb
|
@@ -58,9 +57,10 @@ files:
|
|
58
57
|
- lib/action_mailer/test_case.rb
|
59
58
|
- lib/action_mailer/test_helper.rb
|
60
59
|
- lib/action_mailer/version.rb
|
61
|
-
- lib/
|
60
|
+
- lib/action_mailer.rb
|
62
61
|
- lib/rails/generators/mailer/mailer_generator.rb
|
63
62
|
- lib/rails/generators/mailer/templates/mailer.rb
|
63
|
+
- lib/rails/generators/mailer/USAGE
|
64
64
|
homepage: http://www.rubyonrails.org
|
65
65
|
licenses:
|
66
66
|
- MIT
|
@@ -71,20 +71,19 @@ require_paths:
|
|
71
71
|
- lib
|
72
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 1.
|
76
|
+
version: 1.9.3
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - '>'
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
81
|
+
version: 1.3.1
|
82
82
|
requirements:
|
83
83
|
- none
|
84
84
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.0.0
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Email composition, delivery, and receiving framework (part of Rails).
|
89
89
|
test_files: []
|
90
|
-
has_rdoc:
|