supermail 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ab203ffd27a2af74aa3f64e1d0f82fda4263ee4c818072cabd6e9daa5e8afe73
|
|
4
|
+
data.tar.gz: 2ea834cd01184581f56de63a9e03a708e51c036e37536588bc3143014fe57277
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71dd7876ad4759ab40022e6950366f9aad994cfe0e9cbd5f3baeba709de6b40ba4d804b8d864710a7138c9203273caaa61d67955cdaada57a2eb5f0496080a9d
|
|
7
|
+
data.tar.gz: 4d879602a5ba9fc46ea510428d9ab798f8fb9a0c0c4110b4c002d054737cf0816406cdac30f9edda02bc8640e93b84bc028df931f28516804c23597d2b623f12
|
data/README.md
CHANGED
|
@@ -5,16 +5,16 @@ Organize emails with plain 'ol Ruby objects in a Rails application, like this:
|
|
|
5
5
|
```ruby
|
|
6
6
|
# ./app/email/user/welcome.rb
|
|
7
7
|
class User::WelcomeEmail < ApplicationEmail
|
|
8
|
-
def initialize(
|
|
9
|
-
@
|
|
8
|
+
def initialize(user:)
|
|
9
|
+
@user = user
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def to = @
|
|
12
|
+
def to = @user.email
|
|
13
13
|
def subject = "Welcome to Beautiful Ruby"
|
|
14
14
|
def body
|
|
15
15
|
super do
|
|
16
16
|
<<~_
|
|
17
|
-
Hi #{@
|
|
17
|
+
Hi #{@user.name},
|
|
18
18
|
|
|
19
19
|
You're going to learn a ton at https://beautifulruby.com.
|
|
20
20
|
_
|
|
@@ -88,16 +88,16 @@ You can customize the email by overriding the `to`, `from`, `subject`, and `body
|
|
|
88
88
|
```ruby
|
|
89
89
|
# ./app/email/user/welcome.rb
|
|
90
90
|
class User::WelcomeEmail < ApplicationEmail
|
|
91
|
-
def initialize(
|
|
92
|
-
@
|
|
91
|
+
def initialize(user:)
|
|
92
|
+
@user = user
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
def to = @
|
|
95
|
+
def to = @user.email
|
|
96
96
|
def subject = "Welcome to the website"
|
|
97
97
|
def body
|
|
98
98
|
super do
|
|
99
99
|
<<~_
|
|
100
|
-
Hi #{@
|
|
100
|
+
Hi #{@user.name},
|
|
101
101
|
|
|
102
102
|
Welcome to the website We're excited to have you on board.
|
|
103
103
|
_
|
|
@@ -9,17 +9,22 @@ module Supermail
|
|
|
9
9
|
desc "Generate a new email class"
|
|
10
10
|
|
|
11
11
|
def create_email_file
|
|
12
|
-
template 'email.rb', "app/emails/#{file_path}
|
|
12
|
+
template 'email.rb', "app/emails/#{file_path}.rb"
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
private
|
|
16
16
|
|
|
17
17
|
def file_path
|
|
18
|
-
|
|
18
|
+
"#{base_name.underscore}_email"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def class_name
|
|
22
|
-
|
|
22
|
+
"#{base_name.camelize}Email"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def base_name
|
|
26
|
+
stripped = name.to_s.sub(/_?email\z/i, '')
|
|
27
|
+
stripped.empty? ? name : stripped
|
|
23
28
|
end
|
|
24
29
|
end
|
|
25
30
|
end
|
data/lib/supermail/version.rb
CHANGED
data/lib/supermail.rb
CHANGED
|
@@ -8,13 +8,25 @@ module Supermail
|
|
|
8
8
|
class Error < StandardError; end
|
|
9
9
|
|
|
10
10
|
module Rails
|
|
11
|
+
# This is a bizzare work around for a commit that broke https://github.com/rails/rails/commit/c594ba4ffdb016c7b2a22055f41dfb2c4409594d
|
|
12
|
+
# further proving the bewildering maze of indirection in Rails ActionMailer.
|
|
13
|
+
class Mailer < ActionMailer::Base
|
|
14
|
+
def mail(...)
|
|
15
|
+
super(...)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.message_delivery(**)
|
|
19
|
+
ActionMailer::MessageDelivery.new self, :mail, **
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
11
23
|
class Base
|
|
12
24
|
delegate \
|
|
13
25
|
:deliver,
|
|
14
26
|
:deliver_now,
|
|
15
27
|
:deliver_later,
|
|
16
28
|
:message,
|
|
17
|
-
to: :
|
|
29
|
+
to: :message_delivery
|
|
18
30
|
|
|
19
31
|
def to = nil
|
|
20
32
|
def from = nil
|
|
@@ -27,8 +39,15 @@ module Supermail
|
|
|
27
39
|
def mailto = MailTo.href(to:, from:, cc:, bcc:, subject:, body:)
|
|
28
40
|
alias :mail_to :mailto
|
|
29
41
|
|
|
30
|
-
private def
|
|
31
|
-
|
|
42
|
+
private def message_delivery
|
|
43
|
+
Rails::Mailer.message_delivery(
|
|
44
|
+
to:,
|
|
45
|
+
from:,
|
|
46
|
+
cc:,
|
|
47
|
+
bcc:,
|
|
48
|
+
subject:,
|
|
49
|
+
body:
|
|
50
|
+
)
|
|
32
51
|
end
|
|
33
52
|
end
|
|
34
53
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: supermail
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brad Gessler
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-
|
|
10
|
+
date: 2025-11-05 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: actionmailer
|