rails_courrier 0.5.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1c27079a012b10a2af5545069b4fd95df7fee48f90ca676d556f6fbe0e5c14c0
4
+ data.tar.gz: 7624375dfacce56335d8cd31a4a896be095fdd23bc1d66e7238470221661cad5
5
+ SHA512:
6
+ metadata.gz: 79f5e0e925e3d9513422e749b390a5e4e57f2d423f062657aae3b1fd4ac13214725fa5ae7fb098885a928db77b9c6297b9493d65f88d3283e13e6ff0273ac006
7
+ data.tar.gz: 706a198bc22cf183ba6cd02581c622c0d3b790c17bd5e8c6f7a8b7d60809d38bf22a22920feab28e4fe46045660436a1ec050b144063ffc1db648556c3b58544
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ group :development do
8
+ gem "standard", "~> 1.49"
9
+ end
10
+
11
+ group :development, :test do
12
+ gem "rake", "~> 13.2", ">= 13.2.1"
13
+ gem "minitest", "~> 5.25", ">= 5.25.5"
14
+ gem "debug", "~> 1.9", ">= 1.9.2"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,214 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails_courrier (0.5.0)
5
+ actionpack (>= 7.0)
6
+ actionview (>= 7.0)
7
+ activejob (>= 7.0)
8
+ courrier (~> 0.11.0)
9
+ launchy (>= 3.1, < 4)
10
+ railties (>= 7.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actionpack (8.1.3)
16
+ actionview (= 8.1.3)
17
+ activesupport (= 8.1.3)
18
+ nokogiri (>= 1.8.5)
19
+ rack (>= 2.2.4)
20
+ rack-session (>= 1.0.1)
21
+ rack-test (>= 0.6.3)
22
+ rails-dom-testing (~> 2.2)
23
+ rails-html-sanitizer (~> 1.6)
24
+ useragent (~> 0.16)
25
+ actionview (8.1.3)
26
+ activesupport (= 8.1.3)
27
+ builder (~> 3.1)
28
+ erubi (~> 1.11)
29
+ rails-dom-testing (~> 2.2)
30
+ rails-html-sanitizer (~> 1.6)
31
+ activejob (8.1.3)
32
+ activesupport (= 8.1.3)
33
+ globalid (>= 0.3.6)
34
+ activesupport (8.1.3)
35
+ base64
36
+ bigdecimal
37
+ concurrent-ruby (~> 1.0, >= 1.3.1)
38
+ connection_pool (>= 2.2.5)
39
+ drb
40
+ i18n (>= 1.6, < 2)
41
+ json
42
+ logger (>= 1.4.2)
43
+ minitest (>= 5.1)
44
+ securerandom (>= 0.3)
45
+ tzinfo (~> 2.0, >= 2.0.5)
46
+ uri (>= 0.13.1)
47
+ addressable (2.9.0)
48
+ public_suffix (>= 2.0.2, < 8.0)
49
+ ast (2.4.3)
50
+ base64 (0.3.0)
51
+ bigdecimal (4.1.2)
52
+ builder (3.3.0)
53
+ childprocess (5.1.0)
54
+ logger (~> 1.5)
55
+ concurrent-ruby (1.3.6)
56
+ connection_pool (3.0.2)
57
+ courrier (0.11.0)
58
+ logger (>= 1.5, < 3)
59
+ nokogiri (>= 1.18, < 2)
60
+ crass (1.0.6)
61
+ date (3.5.1)
62
+ debug (1.11.1)
63
+ irb (~> 1.10)
64
+ reline (>= 0.3.8)
65
+ drb (2.2.3)
66
+ erb (6.0.4)
67
+ erubi (1.13.1)
68
+ globalid (1.3.0)
69
+ activesupport (>= 6.1)
70
+ i18n (1.14.8)
71
+ concurrent-ruby (~> 1.0)
72
+ io-console (0.8.2)
73
+ irb (1.18.0)
74
+ pp (>= 0.6.0)
75
+ prism (>= 1.3.0)
76
+ rdoc (>= 4.0.0)
77
+ reline (>= 0.4.2)
78
+ json (2.19.8)
79
+ language_server-protocol (3.17.0.5)
80
+ launchy (3.1.1)
81
+ addressable (~> 2.8)
82
+ childprocess (~> 5.0)
83
+ logger (~> 1.6)
84
+ lint_roller (1.1.0)
85
+ logger (1.7.0)
86
+ loofah (2.25.1)
87
+ crass (~> 1.0.2)
88
+ nokogiri (>= 1.12.0)
89
+ minitest (5.27.0)
90
+ nokogiri (1.19.3-aarch64-linux-gnu)
91
+ racc (~> 1.4)
92
+ nokogiri (1.19.3-aarch64-linux-musl)
93
+ racc (~> 1.4)
94
+ nokogiri (1.19.3-arm-linux-gnu)
95
+ racc (~> 1.4)
96
+ nokogiri (1.19.3-arm-linux-musl)
97
+ racc (~> 1.4)
98
+ nokogiri (1.19.3-arm64-darwin)
99
+ racc (~> 1.4)
100
+ nokogiri (1.19.3-x86_64-darwin)
101
+ racc (~> 1.4)
102
+ nokogiri (1.19.3-x86_64-linux-gnu)
103
+ racc (~> 1.4)
104
+ nokogiri (1.19.3-x86_64-linux-musl)
105
+ racc (~> 1.4)
106
+ parallel (1.28.0)
107
+ parser (3.3.11.1)
108
+ ast (~> 2.4.1)
109
+ racc
110
+ pp (0.6.3)
111
+ prettyprint
112
+ prettyprint (0.2.0)
113
+ prism (1.9.0)
114
+ psych (5.4.0)
115
+ date
116
+ stringio
117
+ public_suffix (7.0.5)
118
+ racc (1.8.1)
119
+ rack (3.2.6)
120
+ rack-session (2.1.2)
121
+ base64 (>= 0.1.0)
122
+ rack (>= 3.0.0)
123
+ rack-test (2.2.0)
124
+ rack (>= 1.3)
125
+ rackup (2.3.1)
126
+ rack (>= 3)
127
+ rails-dom-testing (2.3.0)
128
+ activesupport (>= 5.0.0)
129
+ minitest
130
+ nokogiri (>= 1.6)
131
+ rails-html-sanitizer (1.7.0)
132
+ loofah (~> 2.25)
133
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
134
+ railties (8.1.3)
135
+ actionpack (= 8.1.3)
136
+ activesupport (= 8.1.3)
137
+ irb (~> 1.13)
138
+ rackup (>= 1.0.0)
139
+ rake (>= 12.2)
140
+ thor (~> 1.0, >= 1.2.2)
141
+ tsort (>= 0.2)
142
+ zeitwerk (~> 2.6)
143
+ rainbow (3.1.1)
144
+ rake (13.4.2)
145
+ rdoc (7.2.0)
146
+ erb
147
+ psych (>= 4.0.0)
148
+ tsort
149
+ regexp_parser (2.12.0)
150
+ reline (0.6.3)
151
+ io-console (~> 0.5)
152
+ rubocop (1.84.2)
153
+ json (~> 2.3)
154
+ language_server-protocol (~> 3.17.0.2)
155
+ lint_roller (~> 1.1.0)
156
+ parallel (~> 1.10)
157
+ parser (>= 3.3.0.2)
158
+ rainbow (>= 2.2.2, < 4.0)
159
+ regexp_parser (>= 2.9.3, < 3.0)
160
+ rubocop-ast (>= 1.49.0, < 2.0)
161
+ ruby-progressbar (~> 1.7)
162
+ unicode-display_width (>= 2.4.0, < 4.0)
163
+ rubocop-ast (1.49.1)
164
+ parser (>= 3.3.7.2)
165
+ prism (~> 1.7)
166
+ rubocop-performance (1.26.1)
167
+ lint_roller (~> 1.1)
168
+ rubocop (>= 1.75.0, < 2.0)
169
+ rubocop-ast (>= 1.47.1, < 2.0)
170
+ ruby-progressbar (1.13.0)
171
+ securerandom (0.4.1)
172
+ standard (1.54.0)
173
+ language_server-protocol (~> 3.17.0.2)
174
+ lint_roller (~> 1.0)
175
+ rubocop (~> 1.84.0)
176
+ standard-custom (~> 1.0.0)
177
+ standard-performance (~> 1.8)
178
+ standard-custom (1.0.2)
179
+ lint_roller (~> 1.0)
180
+ rubocop (~> 1.50)
181
+ standard-performance (1.9.0)
182
+ lint_roller (~> 1.1)
183
+ rubocop-performance (~> 1.26.0)
184
+ stringio (3.2.0)
185
+ thor (1.5.0)
186
+ tsort (0.2.0)
187
+ tzinfo (2.0.6)
188
+ concurrent-ruby (~> 1.0)
189
+ unicode-display_width (3.2.0)
190
+ unicode-emoji (~> 4.1)
191
+ unicode-emoji (4.2.0)
192
+ uri (1.1.1)
193
+ useragent (0.16.11)
194
+ zeitwerk (2.8.2)
195
+
196
+ PLATFORMS
197
+ aarch64-linux-gnu
198
+ aarch64-linux-musl
199
+ arm-linux-gnu
200
+ arm-linux-musl
201
+ arm64-darwin
202
+ x86_64-darwin
203
+ x86_64-linux-gnu
204
+ x86_64-linux-musl
205
+
206
+ DEPENDENCIES
207
+ debug (~> 1.9, >= 1.9.2)
208
+ minitest (~> 5.25, >= 5.25.5)
209
+ rails_courrier!
210
+ rake (~> 13.2, >= 13.2.1)
211
+ standard (~> 1.49)
212
+
213
+ BUNDLED WITH
214
+ 2.6.8
data/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # Rails Courrier
2
+
3
+ Rails-specific features for [Courrier](https://github.com/Rails-Designer/courrier), the API-powered email delivery gem for Ruby.
4
+
5
+ ![Preview of the Rails Courrier inbox with a list of images on the left and preview of an email on the right](https://raw.githubusercontent.com/Rails-Designer/rails_courrier/HEAD/.github/rails_courrier_inbox.jpg)
6
+
7
+
8
+ ## Installation
9
+
10
+ Add to your Gemfile:
11
+ ```bash
12
+ bundle add rails_courrier
13
+ ```
14
+
15
+ <a href="https://railsdesigner.com/" target="_blank">
16
+ <picture>
17
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Rails-Designer/courrier/HEAD/.github/logo-dark.svg">
18
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Rails-Designer/courrier/HEAD/.github/logo-light.svg">
19
+ <img alt="Rails Designer logo" src="https://raw.githubusercontent.com/Rails-Designer/courrier/HEAD/.github/logo-light.svg" width="240" style="max-width: 100%;">
20
+ </picture>
21
+ </a>
22
+
23
+ **Sponsored By [Rails Designer](https://railsdesigner.com/)**
24
+
25
+
26
+ ## Setup
27
+
28
+ Generate the initializer:
29
+ ```bash
30
+ bin/rails generate courrier:install
31
+ ```
32
+
33
+ This creates `config/initializers/courrier.rb`.
34
+
35
+ Generate an email:
36
+ ```bash
37
+ bin/rails generate courrier:email Order
38
+ ```
39
+
40
+ This creates `app/emails/order_email.rb`.
41
+
42
+ Mount the engine for inbox previews:
43
+ ```ruby
44
+ # config/routes.rb
45
+ mount Courrier::Engine => "/courrier"
46
+ ```
47
+
48
+
49
+ ## Usage
50
+
51
+ ### Send emails
52
+
53
+ ```ruby
54
+ OrderEmail.deliver to: "recipient@example.com"
55
+ ```
56
+
57
+
58
+ ### Deliver later via ActiveJob
59
+
60
+ ```ruby
61
+ OrderEmail.deliver_later to: "recipient@example.com"
62
+ ```
63
+
64
+ Configure queue options in the email class:
65
+ ```ruby
66
+ class OrderEmail < Courrier::Email
67
+ enqueue queue: "emails", wait: 5.minutes
68
+
69
+ def subject = "Your order is ready!"
70
+ # …
71
+ end
72
+ ```
73
+
74
+
75
+ ### Inbox provider
76
+
77
+ Preview emails in your browser:
78
+ ```ruby
79
+ # config/initializers/courrier.rb
80
+ Courrier.configure do |config|
81
+ config.email = { provider: "inbox" }
82
+ end
83
+ ```
84
+
85
+ Enable auto-open:
86
+
87
+ ```ruby
88
+ config.email = { provider: "inbox" }
89
+ config.inbox.auto_open = true
90
+ ```
91
+
92
+ Clear inbox files:
93
+
94
+ ```bash
95
+ bin/rails courrier:clear
96
+ ```
97
+
98
+
99
+ ### URL helpers
100
+
101
+ Rails Courrier automatically includes Rails URL helpers in your email classes:
102
+ ```ruby
103
+ class OrderEmail < Courrier::Email
104
+ def text
105
+ "View your order: #{order_url(token: "abc123")}"
106
+ end
107
+ end
108
+ ```
109
+
110
+
111
+ ## Documentation
112
+
113
+ See the [Courrier README](https://github.com/Rails-Designer/courrier) for full configuration, providers, layouts, templates and more.
114
+
115
+
116
+ ## Contributing
117
+
118
+ This project uses [Standard](https://github.com/testdouble/standard) for formatting Ruby code. Please make sure to run `rake` before submitting pull requests.
119
+
120
+
121
+ ## License
122
+
123
+ Courrier is released under the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+ require "standard/rake"
6
+
7
+ Minitest::TestTask.create
8
+
9
+ task default: %i[test standard]
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courrier
4
+ module Previews
5
+ class CleanupsController < ActionController::Base
6
+ def create
7
+ system("bin/rails courrier:clear")
8
+
9
+ redirect_to root_path
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courrier
4
+ class PreviewsController < ActionController::Base
5
+ def index
6
+ @emails = emails.map { Courrier::Email::Providers::Inbox::Email.from_file(it) }
7
+ end
8
+
9
+ def show
10
+ file_path = File.join(Courrier.configuration.inbox.destination, params[:id])
11
+ content = File.read(file_path)
12
+
13
+ render html: content.html_safe, layout: false
14
+ end
15
+
16
+ private
17
+
18
+ def emails
19
+ @emails ||= Dir.glob("#{Courrier.configuration.inbox.destination}/*.html")
20
+ .sort_by { -File.basename(it, ".html").to_i }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,167 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Courrier Inbox</title>
6
+
7
+ <style>
8
+ *, *::before, *::after { box-sizing: border-box; }
9
+ * { margin: 0; padding: 0; }
10
+ body { margin: 0; padding: 0; font-size: 16px; line-height: 1.5; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; background-color: rgb(241 245 249); }
11
+
12
+ .sidebar {
13
+ display: flex;
14
+ flex-direction: column;
15
+ position: sticky;
16
+ top: 0;
17
+ padding: .5rem;
18
+ width: min(350px, 33.3333%); height: 100dvh;
19
+ border-right: 1px solid rgb(226 232 240);
20
+ }
21
+
22
+ .sidebar__options {
23
+ position: sticky;
24
+ bottom: 0;
25
+ padding: .5rem;
26
+ background-color: rgb(241 245 249);
27
+ }
28
+
29
+ .sidebar__btn-clear {
30
+ border: none;
31
+ display: flex;
32
+ align-items: center;
33
+ justify-content: center;
34
+ column-gap: .25rem;
35
+ width: 100%;
36
+ padding: .5rem;
37
+ font-size: .875rem; line-height: 1.25rem;
38
+ font-weight: 500;
39
+ color: rgb(71 85 105);
40
+ background-color: rgb(226 232 240);
41
+ border-radius: .5rem;
42
+ cursor: default;
43
+
44
+ &:hover { background-color: rgb(203 213 225); }
45
+ &:active { transform: scale(.98); }
46
+
47
+ [data-slot="icon"] { width: .875rem; height: .875rem; }
48
+ }
49
+
50
+ .email-previews {
51
+ display: flex;
52
+ flex-direction: column;
53
+ flex: 1;
54
+ row-gap: .5rem;
55
+ overflow-y: auto;
56
+ width: 100%;
57
+ }
58
+
59
+ .email-preview {
60
+ display: flex;
61
+ flex-direction: row;
62
+ column-gap: .5rem;
63
+ width: 100%;
64
+ padding: .5rem .75rem;
65
+ text-decoration: none;
66
+ border-radius: .5rem;
67
+
68
+ &:hover { background-color: rgb(226 232 240 / .75); }
69
+ }
70
+
71
+ .email-preview--empty {
72
+ display: none;
73
+ text-align: center;
74
+
75
+ &:only-child { display: block; }
76
+ }
77
+
78
+ .email-preview__avatar {
79
+ flex-shrink: 0;
80
+ padding: .25rem;
81
+ width: 1.5rem; height: 1.5rem;
82
+ background-color: rgb(203 213 225);
83
+ color: rgb(51, 65, 85);
84
+ border-radius: 9999px;
85
+ }
86
+
87
+ .email-preview__content {
88
+ font-size: .875rem;
89
+ line-height: 1.25rem;
90
+ }
91
+
92
+ .email-preview__recipient {
93
+ font-size: 1rem; line-height: 1.5rem;
94
+ font-weight: 600;
95
+ letter-spacing: -.025em;
96
+ color: rgb(51 65 85);
97
+ }
98
+
99
+ .email-preview__subject {
100
+ margin-top: .125rem;
101
+ overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1;
102
+ color: rgb(100 116 139);
103
+ }
104
+ </style>
105
+ </head>
106
+
107
+ <body>
108
+ <div style="display: flex; column-gap: 1rem;">
109
+ <aside class="sidebar">
110
+ <ul class="email-previews">
111
+ <li class="email-preview--empty">
112
+ <p class="email-preview__subject">
113
+ No emails yet…
114
+ </p>
115
+ </li>
116
+
117
+ <% @emails.each do |email| %>
118
+ <li>
119
+ <%= link_to courrier.preview_path(email.filename), data: {remote: true}, class: "email-preview" do %>
120
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" data-slot="icon" class="email-preview__avatar">
121
+ <path fill-rule="evenodd" d="M7.5 6a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0ZM3.751 20.105a8.25 8.25 0 0 1 16.498 0 .75.75 0 0 1-.437.695A18.683 18.683 0 0 1 12 22.5c-2.786 0-5.433-.608-7.812-1.7a.75.75 0 0 1-.437-.695Z" clip-rule="evenodd"/>
122
+ </svg>
123
+
124
+ <div class="email-preview__content">
125
+ <small class="email-preview__recipient">
126
+ <%= email.metadata.to %>
127
+ </small>
128
+
129
+ <p class="email-preview__subject">
130
+ <%= email.metadata.subject || "No subject" %>
131
+ </p>
132
+ </div>
133
+ <% end %>
134
+ </li>
135
+ <% end %>
136
+ </ul>
137
+
138
+ <div class="sidebar__options">
139
+ <%= button_to courrier.cleanup_path, class: "sidebar__btn-clear" do %>
140
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" data-slot="icon">
141
+ <path fill-rule="evenodd" d="M16.5 4.478v.227a48.816 48.816 0 0 1 3.878.512.75.75 0 1 1-.256 1.478l-.209-.035-1.005 13.07a3 3 0 0 1-2.991 2.77H8.084a3 3 0 0 1-2.991-2.77L4.087 6.66l-.209.035a.75.75 0 0 1-.256-1.478A48.567 48.567 0 0 1 7.5 4.705v-.227c0-1.564 1.213-2.9 2.816-2.951a52.662 52.662 0 0 1 3.369 0c1.603.051 2.815 1.387 2.815 2.951Zm-6.136-1.452a51.196 51.196 0 0 1 3.273 0C14.39 3.05 15 3.684 15 4.478v.113a49.488 49.488 0 0 0-6 0v-.113c0-.794.609-1.428 1.364-1.452Zm-.355 5.945a.75.75 0 1 0-1.5.058l.347 9a.75.75 0 1 0 1.499-.058l-.346-9Zm5.48.058a.75.75 0 1 0-1.498-.058l-.347 9a.75.75 0 0 0 1.5.058l.345-9Z" clip-rule="evenodd"/>
142
+ </svg>
143
+
144
+ Clear inbox
145
+ <% end %>
146
+ </div>
147
+ </aside>
148
+
149
+ <article style="flex: 1;" id="email-preview">
150
+ </article>
151
+ </div>
152
+
153
+ <script>
154
+ document.querySelectorAll("a[data-remote]").forEach(link => {
155
+ link.addEventListener("click", (event) => {
156
+ event.preventDefault();
157
+
158
+ fetch(link.href)
159
+ .then(response => response.text())
160
+ .then(html => {
161
+ document.getElementById("email-preview").innerHTML = html;
162
+ });
163
+ });
164
+ });
165
+ </script>
166
+ </body>
167
+ </html>
data/bin/release ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+
3
+ VERSION=$1
4
+
5
+ if [ -z "$VERSION" ]; then
6
+ echo "Error: Version number or bump type is required."
7
+ echo "Usage: $0 <major|minor|patch|version-number>"
8
+
9
+ exit 1
10
+ fi
11
+
12
+ if [[ "$VERSION" =~ ^(major|minor|patch)$ ]]; then
13
+ CURRENT=$(grep -o '"[^"]*"' ./lib/rails_courrier/version.rb | tr -d '"')
14
+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
15
+
16
+ case $VERSION in
17
+ major) VERSION="$((MAJOR + 1)).0.0" ;;
18
+ minor) VERSION="$MAJOR.$((MINOR + 1)).0" ;;
19
+ patch) VERSION="$MAJOR.$MINOR.$((PATCH + 1))" ;;
20
+ esac
21
+ fi
22
+
23
+ printf "module RailsCourrier\n VERSION = \"$VERSION\"\nend\n" > ./lib/rails_courrier/version.rb
24
+
25
+ bundle
26
+
27
+ git add Gemfile.lock lib/rails_courrier/version.rb
28
+ git commit -m "Bump version for $VERSION"
29
+ git push
30
+ git tag v$VERSION
31
+ git push --tags
32
+
33
+ bundle exec rake build
34
+ gem push "pkg/rails_courrier-$VERSION.gem"
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ Courrier::Engine.routes.draw do
4
+ resources :previews, only: %w[show], constraints: {id: /.*\.html/}
5
+ resource :cleanup, only: %w[create], module: "previews"
6
+
7
+ root "previews#index"
8
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courrier
4
+ class Configuration
5
+ class Inbox
6
+ attr_accessor :destination, :auto_open, :template_path
7
+
8
+ def initialize
9
+ @destination = default_destination
10
+ @auto_open = false
11
+ @template_path = File.expand_path("../email/providers/inbox/default.html.erb", __dir__)
12
+ end
13
+
14
+ private
15
+
16
+ def default_destination
17
+ Rails.root.join("tmp", "courrier", "emails").to_s
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courrier
4
+ class Email
5
+ class DeliveryJob < ActiveJob::Base
6
+ def perform(email_class_name, **options)
7
+ Object.const_get(email_class_name).new(**options).deliver_now
8
+ end
9
+ end
10
+ end
11
+ end