mailer-log 0.1.0 → 0.1.1
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/lib/mailer_log/mail_interceptor.rb +28 -3
- data/lib/mailer_log/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 52399851c17f2044f03e9faa07bf77e61c3bbc25e524719a22a0269979841327
|
|
4
|
+
data.tar.gz: 210e8dc06f619b9e60bcd1307b6d380624d8f11f3ac41b38f422c76150a7fcb8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c989cf7eab1d62089278de10b5507279e155cdde1dbac23f8a4f47dd9d7ed628d927d27a124445a3694c8233079b9635ce973ac150c10336db2468a533b39cc
|
|
7
|
+
data.tar.gz: af478fb60e1e7e4276f064d1ff2d9dc0733a1e97a5de60f626f0b51e761114c35c41cc4e518a29e49137b46d02d3fbe3372446496b765a8f07578cd51eeb2c7e
|
|
@@ -41,17 +41,42 @@ module MailerLog
|
|
|
41
41
|
|
|
42
42
|
def extract_mailer_action(message)
|
|
43
43
|
handler = message.delivery_handler
|
|
44
|
-
return 'unknown' unless handler
|
|
44
|
+
return extract_action_from_call_stack(handler) || 'unknown' unless handler
|
|
45
45
|
|
|
46
|
-
if handler.respond_to?(:action_name)
|
|
46
|
+
if handler.respond_to?(:action_name) && !handler.is_a?(Class)
|
|
47
47
|
handler.action_name.to_s
|
|
48
48
|
elsif message['X-Mailer-Action']
|
|
49
49
|
message['X-Mailer-Action'].to_s
|
|
50
50
|
else
|
|
51
|
-
|
|
51
|
+
# Parse action name from call stack
|
|
52
|
+
extract_action_from_call_stack(handler) || 'unknown'
|
|
52
53
|
end
|
|
53
54
|
end
|
|
54
55
|
|
|
56
|
+
def extract_action_from_call_stack(handler)
|
|
57
|
+
return nil unless handler
|
|
58
|
+
|
|
59
|
+
mailer_class_name = handler.is_a?(Class) ? handler.name : handler.class.name
|
|
60
|
+
mailer_file_pattern = mailer_class_name.underscore
|
|
61
|
+
|
|
62
|
+
# Look through call stack for the mailer file
|
|
63
|
+
caller.each do |line|
|
|
64
|
+
next unless line.include?(mailer_file_pattern) || line.include?('/mailers/')
|
|
65
|
+
|
|
66
|
+
# Extract method name from call stack line: "path/file.rb:123:in `method_name'"
|
|
67
|
+
match = line.match(/in [`']([^']+)'/)
|
|
68
|
+
next unless match
|
|
69
|
+
|
|
70
|
+
method_name = match[1]
|
|
71
|
+
# Skip Rails internal methods
|
|
72
|
+
next if %w[mail initialize block].any? { |skip| method_name.include?(skip) }
|
|
73
|
+
|
|
74
|
+
return method_name
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
nil
|
|
78
|
+
end
|
|
79
|
+
|
|
55
80
|
def extract_html_body(message)
|
|
56
81
|
if message.multipart?
|
|
57
82
|
message.html_part&.body&.decoded
|
data/lib/mailer_log/version.rb
CHANGED