postmortem 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d675b984abb71e212b6c7f3e190c9bf8d17282ed0741b260cf06891cff5b70d
4
- data.tar.gz: 408e888943fe644d76b686d3693588378c513138ea88d82da633bf0c2367f19e
3
+ metadata.gz: 3e05359d9e039f6e44c0e89decaac3c5c72fe3447f7a96fdb8ac1667fe93d537
4
+ data.tar.gz: 651d2b986f6b9b07e8fe311cd163865490005da3376c95c4ce05a4110a313e62
5
5
  SHA512:
6
- metadata.gz: c6cddb8f06e21fd028b7531d79efabf8320e86a22670cfed45901b189d563249cd1a420859ff8cbf1a7a542a15d8c908018a6fb8477ec023407997e7d51338e9
7
- data.tar.gz: cfda5e45b5302a36cbd7503b418142c13f5c0e458ca0ba1e705503513b9549e5c41d440af485bade2db280a1890fffef5df33bfd487250e38762ee7a811b4992
6
+ metadata.gz: 66a929b9cfa7043ebce54eda09c4168e4adfd485d24e32720dc68238c6ea578030c89ad90181d770b22b33d358c2945bae12cc5df9a8f3d3019989b6a72cc8ca
7
+ data.tar.gz: 82478c5ef6a04531776023947b39b3c1c04a003185a602199a4460e2ba4b6759a87493475666f4056d0bcc759b7de3a5765db8b3356d28e863e71ed445ca7e2a
data/README.md CHANGED
@@ -10,7 +10,8 @@ _Postmortem_ should only be enabled in test or development environments.
10
10
 
11
11
  ## Features
12
12
 
13
- * Seamless integration with [_ActionMailer_](https://guides.rubyonrails.org/action_mailer_basics.html) and [_Pony_](https://github.com/benprew/pony) (with automatic delivery skipping when using _Pony_).
13
+ * Seamless integration with [_ActionMailer_](https://guides.rubyonrails.org/action_mailer_basics.html), [_Pony_](https://github.com/benprew/pony), [_Mail_](https://github.com/mikel/mail), etc.
14
+ * Email deliveries are always intercepted (can be configured to pass through).
14
15
  * Preview email content as well as typical email headers (recipients, subject, etc.).
15
16
  * View rendered _HTML_, plaintext, or _HTML_ source with syntax highlighting (courtesy of [highlight.js](https://highlightjs.org/)).
16
17
  * Dual or single column view to suit your requirements.
@@ -22,7 +23,7 @@ Add the gem to your application's Gemfile:
22
23
 
23
24
  ```ruby
24
25
  group :development, :test do
25
- gem 'postmortem', '~> 0.1.1'
26
+ gem 'postmortem', '~> 0.1.2'
26
27
  end
27
28
  ```
28
29
 
@@ -80,8 +81,8 @@ Postmortem.configure do |config|
80
81
  # See `layout/default.html.erb` for implementation reference.
81
82
  config.layout = '/path/to/layout'
82
83
 
83
- # Skip delivery of emails when using Pony (default: true).
84
- config.pony_skip_delivery = true
84
+ # Skip delivery of emails when using Pony, Mail, etc. (default: true).
85
+ config.mail_skip_delivery = true
85
86
  end
86
87
  ```
87
88
 
@@ -66,3 +66,4 @@ end
66
66
  Postmortem.configure
67
67
  Postmortem.try_load('action_mailer', 'active_support', plugin: 'action_mailer')
68
68
  Postmortem.try_load('pony', plugin: 'pony')
69
+ Postmortem.try_load('mail', plugin: 'mail')
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'postmortem/adapters/base'
4
4
  require 'postmortem/adapters/action_mailer'
5
+ require 'postmortem/adapters/mail'
5
6
  require 'postmortem/adapters/pony'
6
7
 
7
8
  module Postmortem
@@ -34,11 +34,11 @@ module Postmortem
34
34
  end
35
35
 
36
36
  def mail
37
- @mail ||= Mail.new(@data[:mail])
37
+ @mail ||= ::Mail.new(@data[:mail])
38
38
  end
39
39
 
40
40
  def normalized_bcc
41
- Mail.new(to: @data[:bcc]).to
41
+ ::Mail.new(to: @data[:bcc]).to
42
42
  end
43
43
 
44
44
  def text?
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Postmortem
4
+ module Adapters
5
+ # Mail adapter.
6
+ class Mail < Base
7
+ private
8
+
9
+ def adapted
10
+ %i[from reply_to to cc bcc subject]
11
+ .map { |field| [field, @data.public_send(field)] }
12
+ .to_h
13
+ .merge({ text_body: @data.text_part, html_body: @data.html_part })
14
+ end
15
+
16
+ def mail
17
+ @mail ||= @data
18
+ end
19
+ end
20
+ end
21
+ end
@@ -20,7 +20,7 @@ module Postmortem
20
20
  end
21
21
 
22
22
  def mail
23
- @mail ||= Mail.new(@data.select { |key| keys.include?(key) })
23
+ @mail ||= ::Mail.new(@data.select { |key| keys.include?(key) })
24
24
  end
25
25
 
26
26
  def keys
@@ -3,7 +3,7 @@
3
3
  module Postmortem
4
4
  # Provides interface for configuring Postmortem and implements sensible defaults.
5
5
  class Configuration
6
- attr_writer :colorize, :timestamp, :pony_skip_delivery
6
+ attr_writer :colorize, :timestamp, :mail_skip_delivery
7
7
  attr_accessor :log_path
8
8
 
9
9
  def timestamp
@@ -32,8 +32,8 @@ module Postmortem
32
32
  @preview_directory ||= Pathname.new(File.join(Dir.tmpdir, 'postmortem'))
33
33
  end
34
34
 
35
- def pony_skip_delivery
36
- defined?(@pony_skip_delivery) ? @pony_skip_delivery : true
35
+ def mail_skip_delivery
36
+ defined?(@mail_skip_delivery) ? @mail_skip_delivery : true
37
37
  end
38
38
  end
39
39
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ Mail::SMTP.class_eval do
4
+ alias_method :_original_deliver!, :deliver!
5
+
6
+ def deliver!(mail)
7
+ result = _original_deliver!(mail) unless Postmortem.config.mail_skip_delivery
8
+ Postmortem.record_delivery(Postmortem::Adapters::Mail.new(mail))
9
+ result
10
+ end
11
+ end
@@ -3,10 +3,13 @@
3
3
  # Pony monkey-patch.
4
4
  module Pony
5
5
  class << self
6
- alias _pony_mail mail
6
+ alias _original_mail mail
7
7
 
8
8
  def mail(options)
9
- result = _pony_mail(options) unless Postmortem.config.pony_skip_delivery
9
+ # SMTP delivery is handled by Mail plugin further down the stack
10
+ return _original_mail(options) if options[:via].to_s == 'smtp'
11
+
12
+ result = _original_mail(options) unless Postmortem.config.mail_skip_delivery
10
13
  Postmortem.record_delivery(Postmortem::Adapters::Pony.new(options))
11
14
  result
12
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Postmortem
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postmortem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-16 00:00:00.000000000 Z
11
+ date: 2021-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -145,11 +145,13 @@ files:
145
145
  - lib/postmortem/adapters.rb
146
146
  - lib/postmortem/adapters/action_mailer.rb
147
147
  - lib/postmortem/adapters/base.rb
148
+ - lib/postmortem/adapters/mail.rb
148
149
  - lib/postmortem/adapters/pony.rb
149
150
  - lib/postmortem/configuration.rb
150
151
  - lib/postmortem/delivery.rb
151
152
  - lib/postmortem/layout.rb
152
153
  - lib/postmortem/plugins/action_mailer.rb
154
+ - lib/postmortem/plugins/mail.rb
153
155
  - lib/postmortem/plugins/pony.rb
154
156
  - lib/postmortem/version.rb
155
157
  - postmortem.gemspec
@@ -160,7 +162,7 @@ metadata:
160
162
  homepage_uri: https://github.com/bobf/postmortem
161
163
  source_code_uri: https://github.com/bobf/postmortem
162
164
  changelog_uri: https://github.com/bobf/postmortem/blob/master/README.md
163
- post_install_message:
165
+ post_install_message:
164
166
  rdoc_options: []
165
167
  require_paths:
166
168
  - lib
@@ -176,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
178
  version: '0'
177
179
  requirements: []
178
180
  rubygems_version: 3.1.2
179
- signing_key:
181
+ signing_key:
180
182
  specification_version: 4
181
183
  summary: Development HTML Email Inspection Tool
182
184
  test_files: []