hanami-mailer 1.3.3 → 3.0.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 +4 -4
- data/CHANGELOG.md +154 -45
- data/LICENSE +20 -0
- data/README.md +518 -303
- data/hanami-mailer.gemspec +23 -18
- data/lib/hanami/mailer/attachment.rb +133 -0
- data/lib/hanami/mailer/attachment_set.rb +38 -0
- data/lib/hanami/mailer/delivery/result.rb +101 -0
- data/lib/hanami/mailer/delivery/smtp.rb +168 -0
- data/lib/hanami/mailer/delivery/test.rb +57 -0
- data/lib/hanami/mailer/dsl/attachments.rb +108 -0
- data/lib/hanami/mailer/dsl/exposure.rb +69 -0
- data/lib/hanami/mailer/dsl/exposures.rb +111 -0
- data/lib/hanami/mailer/dsl/plucky_proc.rb +135 -0
- data/lib/hanami/mailer/errors.rb +73 -0
- data/lib/hanami/mailer/message.rb +101 -0
- data/lib/hanami/mailer/version.rb +4 -3
- data/lib/hanami/mailer/view_integration.rb +205 -0
- data/lib/hanami/mailer.rb +372 -270
- data/lib/hanami-mailer.rb +1 -1
- metadata +40 -97
- data/LICENSE.md +0 -22
- data/lib/hanami/mailer/configuration.rb +0 -310
- data/lib/hanami/mailer/dsl.rb +0 -628
- data/lib/hanami/mailer/rendering/template_name.rb +0 -55
- data/lib/hanami/mailer/rendering/templates_finder.rb +0 -135
- data/lib/hanami/mailer/template.rb +0 -42
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "hanami/mailer/template"
|
|
4
|
-
|
|
5
|
-
module Hanami
|
|
6
|
-
module Mailer
|
|
7
|
-
module Rendering
|
|
8
|
-
# Find templates for a mailer
|
|
9
|
-
#
|
|
10
|
-
# @api private
|
|
11
|
-
# @since 0.1.0
|
|
12
|
-
#
|
|
13
|
-
# @see Mailer::Template
|
|
14
|
-
class TemplatesFinder
|
|
15
|
-
# Default format
|
|
16
|
-
#
|
|
17
|
-
# @api private
|
|
18
|
-
# @since 0.1.0
|
|
19
|
-
FORMAT = "*"
|
|
20
|
-
|
|
21
|
-
# Default template engines
|
|
22
|
-
#
|
|
23
|
-
# @api private
|
|
24
|
-
# @since 0.1.0
|
|
25
|
-
ENGINES = "*"
|
|
26
|
-
|
|
27
|
-
# Recursive pattern
|
|
28
|
-
#
|
|
29
|
-
# @api private
|
|
30
|
-
# @since 0.1.0
|
|
31
|
-
RECURSIVE = "**"
|
|
32
|
-
|
|
33
|
-
# Initialize a finder
|
|
34
|
-
#
|
|
35
|
-
# @param mailer [Class] the mailer class
|
|
36
|
-
#
|
|
37
|
-
# @api private
|
|
38
|
-
# @since 0.1.0
|
|
39
|
-
def initialize(mailer)
|
|
40
|
-
@mailer = mailer
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Find all the associated templates to the mailer.
|
|
44
|
-
# It recursively looks for templates under the root path of the mailer,
|
|
45
|
-
# that are matching the template name
|
|
46
|
-
#
|
|
47
|
-
# @return [Hash] the templates
|
|
48
|
-
#
|
|
49
|
-
# @api private
|
|
50
|
-
# @since 0.1.0
|
|
51
|
-
#
|
|
52
|
-
# @see Hanami::Mailer::Dsl#root
|
|
53
|
-
# @see Hanami::Mailer::Dsl#templates
|
|
54
|
-
#
|
|
55
|
-
# @example
|
|
56
|
-
# require 'hanami/mailer'
|
|
57
|
-
#
|
|
58
|
-
# module Mailers
|
|
59
|
-
# class Welcome
|
|
60
|
-
# include Hanami::Mailer
|
|
61
|
-
# end
|
|
62
|
-
# end
|
|
63
|
-
#
|
|
64
|
-
# Mailers::Welcome.root # => "/path/to/templates"
|
|
65
|
-
# Mailers::Welcome.templates # => {[:html] => "welcome"}
|
|
66
|
-
#
|
|
67
|
-
# # This mailer has a template:
|
|
68
|
-
# #
|
|
69
|
-
# # "/path/to/templates/welcome.html.erb"
|
|
70
|
-
#
|
|
71
|
-
# Hanami::Mailer::Rendering::TemplatesFinder.new(Mailers::Welcome).find
|
|
72
|
-
# # => [#<Hanami::Mailer::Template:0x007f8a0a86a970 ... @file="/path/to/templates/welcome.html.erb">]
|
|
73
|
-
def find
|
|
74
|
-
templates = Hash[]
|
|
75
|
-
_find.map do |template|
|
|
76
|
-
name = File.basename(template)
|
|
77
|
-
format = (name.split(".")[-2]).to_sym
|
|
78
|
-
templates[format] = Mailer::Template.new(template)
|
|
79
|
-
end
|
|
80
|
-
templates
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
protected
|
|
84
|
-
|
|
85
|
-
# @api private
|
|
86
|
-
# @since 0.1.0
|
|
87
|
-
def _find(lookup = search_path)
|
|
88
|
-
Dir.glob("#{[root, lookup, template_name].join(separator)}.#{format}.#{engines}")
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
# @api private
|
|
92
|
-
# @since 0.1.0
|
|
93
|
-
def template_name
|
|
94
|
-
Rendering::TemplateName.new(@mailer.template, @mailer.configuration.namespace).to_s
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# @api private
|
|
98
|
-
# @since 0.1.0
|
|
99
|
-
def root
|
|
100
|
-
@mailer.configuration.root
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
# @api private
|
|
104
|
-
# @since 0.1.0
|
|
105
|
-
def search_path
|
|
106
|
-
recursive
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# @api private
|
|
110
|
-
# @since 0.1.0
|
|
111
|
-
def recursive
|
|
112
|
-
RECURSIVE
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# @api private
|
|
116
|
-
# @since 0.1.0
|
|
117
|
-
def separator
|
|
118
|
-
::File::SEPARATOR
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# @api private
|
|
122
|
-
# @since 0.1.0
|
|
123
|
-
def format
|
|
124
|
-
FORMAT
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
# @api private
|
|
128
|
-
# @since 0.1.0
|
|
129
|
-
def engines
|
|
130
|
-
ENGINES
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "tilt"
|
|
4
|
-
|
|
5
|
-
module Hanami
|
|
6
|
-
module Mailer
|
|
7
|
-
# A logic-less template.
|
|
8
|
-
#
|
|
9
|
-
# @api private
|
|
10
|
-
# @since 0.1.0
|
|
11
|
-
#
|
|
12
|
-
# TODO this is identical to Hanami::View, consider to move into Hanami::Utils
|
|
13
|
-
class Template
|
|
14
|
-
def initialize(template, encoding = Encoding::UTF_8)
|
|
15
|
-
@_template = Tilt.new(template, default_encoding: encoding)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Render the template within the context of the given scope.
|
|
19
|
-
#
|
|
20
|
-
# @param scope [Class] the rendering scope
|
|
21
|
-
# @param locals [Hash] set of objects passed to the constructor
|
|
22
|
-
#
|
|
23
|
-
# @return [String] the output of the rendering process
|
|
24
|
-
#
|
|
25
|
-
# @api private
|
|
26
|
-
# @since 0.1.0
|
|
27
|
-
def render(scope = Object.new, locals = {})
|
|
28
|
-
@_template.render(scope, locals)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Get the path to the template
|
|
32
|
-
#
|
|
33
|
-
# @return [String] the pathname
|
|
34
|
-
#
|
|
35
|
-
# @api private
|
|
36
|
-
# @since 0.1.0
|
|
37
|
-
def file
|
|
38
|
-
@_template.file
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|