postmortem 0.1.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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +50 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +126 -0
- data/LICENSE.txt +21 -0
- data/Makefile +5 -0
- data/README.md +40 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/layout/default.html.erb +49 -0
- data/lib/postmortem.rb +65 -0
- data/lib/postmortem/action_mailer.rb +5 -0
- data/lib/postmortem/adapters.rb +10 -0
- data/lib/postmortem/adapters/action_mailer.rb +21 -0
- data/lib/postmortem/adapters/base.rb +25 -0
- data/lib/postmortem/delivery.rb +38 -0
- data/lib/postmortem/layout.rb +15 -0
- data/lib/postmortem/version.rb +5 -0
- data/postmortem.gemspec +36 -0
- metadata +165 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 396ef931001e6084271eb46994b2f9ec65daa948f544cf75306e28c0aab1c6df
|
|
4
|
+
data.tar.gz: 851cd36f02f31b91152ffbcc7cad143c911078ac9f5dd991f9345f23728030d2
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 42a525ba6a1d6744177591da24b03585daab8476945dbbbfa7d3f6b3cc8202db19804507e40e5415b05c2edb8eefa793a9f7eb710094595b47d832b169f7055a
|
|
7
|
+
data.tar.gz: 7e8386b1af03787689640fb5ad812fadbe3e04429471c17f166220bfc6f6e57b18bc7eb8f722b9dd22d6031cae892c846941e48b9881fc5214c6f6332849c373
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metrics/BlockLength:
|
|
2
|
+
Exclude:
|
|
3
|
+
- 'spec/**/*_spec.rb'
|
|
4
|
+
|
|
5
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
6
|
+
Enabled: true
|
|
7
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
8
|
+
Enabled: true
|
|
9
|
+
Lint/DeprecatedOpenSSLConstant:
|
|
10
|
+
Enabled: true
|
|
11
|
+
Lint/DuplicateElsifCondition:
|
|
12
|
+
Enabled: true
|
|
13
|
+
Lint/MixedRegexpCaptureTypes:
|
|
14
|
+
Enabled: true
|
|
15
|
+
Lint/RaiseException:
|
|
16
|
+
Enabled: true
|
|
17
|
+
Lint/StructNewOverride:
|
|
18
|
+
Enabled: true
|
|
19
|
+
Style/AccessorGrouping:
|
|
20
|
+
Enabled: true
|
|
21
|
+
Style/ArrayCoercion:
|
|
22
|
+
Enabled: true
|
|
23
|
+
Style/BisectedAttrAccessor:
|
|
24
|
+
Enabled: true
|
|
25
|
+
Style/CaseLikeIf:
|
|
26
|
+
Enabled: true
|
|
27
|
+
Style/ExponentialNotation:
|
|
28
|
+
Enabled: true
|
|
29
|
+
Style/HashAsLastArrayItem:
|
|
30
|
+
Enabled: true
|
|
31
|
+
Style/HashEachMethods:
|
|
32
|
+
Enabled: true
|
|
33
|
+
Style/HashLikeCase:
|
|
34
|
+
Enabled: true
|
|
35
|
+
Style/HashTransformKeys:
|
|
36
|
+
Enabled: true
|
|
37
|
+
Style/HashTransformValues:
|
|
38
|
+
Enabled: true
|
|
39
|
+
Style/RedundantAssignment:
|
|
40
|
+
Enabled: true
|
|
41
|
+
Style/RedundantFetchBlock:
|
|
42
|
+
Enabled: true
|
|
43
|
+
Style/RedundantFileExtensionInRequire:
|
|
44
|
+
Enabled: true
|
|
45
|
+
Style/RedundantRegexpCharacterClass:
|
|
46
|
+
Enabled: true
|
|
47
|
+
Style/RedundantRegexpEscape:
|
|
48
|
+
Enabled: true
|
|
49
|
+
Style/SlicingWithRange:
|
|
50
|
+
Enabled: true
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
postmortem (0.1.0)
|
|
5
|
+
mail (~> 2.7)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
actionmailer (6.0.3.2)
|
|
11
|
+
actionpack (= 6.0.3.2)
|
|
12
|
+
actionview (= 6.0.3.2)
|
|
13
|
+
activejob (= 6.0.3.2)
|
|
14
|
+
mail (~> 2.5, >= 2.5.4)
|
|
15
|
+
rails-dom-testing (~> 2.0)
|
|
16
|
+
actionpack (6.0.3.2)
|
|
17
|
+
actionview (= 6.0.3.2)
|
|
18
|
+
activesupport (= 6.0.3.2)
|
|
19
|
+
rack (~> 2.0, >= 2.0.8)
|
|
20
|
+
rack-test (>= 0.6.3)
|
|
21
|
+
rails-dom-testing (~> 2.0)
|
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
23
|
+
actionview (6.0.3.2)
|
|
24
|
+
activesupport (= 6.0.3.2)
|
|
25
|
+
builder (~> 3.1)
|
|
26
|
+
erubi (~> 1.4)
|
|
27
|
+
rails-dom-testing (~> 2.0)
|
|
28
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
29
|
+
activejob (6.0.3.2)
|
|
30
|
+
activesupport (= 6.0.3.2)
|
|
31
|
+
globalid (>= 0.3.6)
|
|
32
|
+
activesupport (6.0.3.2)
|
|
33
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
34
|
+
i18n (>= 0.7, < 2)
|
|
35
|
+
minitest (~> 5.1)
|
|
36
|
+
tzinfo (~> 1.1)
|
|
37
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
|
38
|
+
ast (2.4.1)
|
|
39
|
+
builder (3.2.4)
|
|
40
|
+
concurrent-ruby (1.1.7)
|
|
41
|
+
crass (1.0.6)
|
|
42
|
+
devpack (0.2.1)
|
|
43
|
+
diff-lcs (1.4.4)
|
|
44
|
+
erubi (1.9.0)
|
|
45
|
+
globalid (0.4.2)
|
|
46
|
+
activesupport (>= 4.2.0)
|
|
47
|
+
i18n (1.8.5)
|
|
48
|
+
concurrent-ruby (~> 1.0)
|
|
49
|
+
loofah (2.6.0)
|
|
50
|
+
crass (~> 1.0.2)
|
|
51
|
+
nokogiri (>= 1.5.9)
|
|
52
|
+
mail (2.7.1)
|
|
53
|
+
mini_mime (>= 0.1.1)
|
|
54
|
+
mini_mime (1.0.2)
|
|
55
|
+
mini_portile2 (2.4.0)
|
|
56
|
+
minitest (5.14.1)
|
|
57
|
+
nokogiri (1.10.10)
|
|
58
|
+
mini_portile2 (~> 2.4.0)
|
|
59
|
+
paint (2.2.0)
|
|
60
|
+
parallel (1.19.2)
|
|
61
|
+
parser (2.7.1.4)
|
|
62
|
+
ast (~> 2.4.1)
|
|
63
|
+
rack (2.2.3)
|
|
64
|
+
rack-test (1.1.0)
|
|
65
|
+
rack (>= 1.0, < 3)
|
|
66
|
+
rails-dom-testing (2.0.3)
|
|
67
|
+
activesupport (>= 4.2.0)
|
|
68
|
+
nokogiri (>= 1.6)
|
|
69
|
+
rails-html-sanitizer (1.3.0)
|
|
70
|
+
loofah (~> 2.3)
|
|
71
|
+
rainbow (3.0.0)
|
|
72
|
+
regexp_parser (1.7.1)
|
|
73
|
+
rexml (3.2.4)
|
|
74
|
+
rspec (3.9.0)
|
|
75
|
+
rspec-core (~> 3.9.0)
|
|
76
|
+
rspec-expectations (~> 3.9.0)
|
|
77
|
+
rspec-mocks (~> 3.9.0)
|
|
78
|
+
rspec-core (3.9.2)
|
|
79
|
+
rspec-support (~> 3.9.3)
|
|
80
|
+
rspec-expectations (3.9.2)
|
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
82
|
+
rspec-support (~> 3.9.0)
|
|
83
|
+
rspec-its (1.3.0)
|
|
84
|
+
rspec-core (>= 3.0.0)
|
|
85
|
+
rspec-expectations (>= 3.0.0)
|
|
86
|
+
rspec-mocks (3.9.1)
|
|
87
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
88
|
+
rspec-support (~> 3.9.0)
|
|
89
|
+
rspec-support (3.9.3)
|
|
90
|
+
rubocop (0.88.0)
|
|
91
|
+
parallel (~> 1.10)
|
|
92
|
+
parser (>= 2.7.1.1)
|
|
93
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
94
|
+
regexp_parser (>= 1.7)
|
|
95
|
+
rexml
|
|
96
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
|
97
|
+
ruby-progressbar (~> 1.7)
|
|
98
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
99
|
+
rubocop-ast (0.3.0)
|
|
100
|
+
parser (>= 2.7.1.4)
|
|
101
|
+
ruby-progressbar (1.10.1)
|
|
102
|
+
strong_versions (0.4.5)
|
|
103
|
+
i18n (>= 0.5)
|
|
104
|
+
paint (~> 2.0)
|
|
105
|
+
thread_safe (0.3.6)
|
|
106
|
+
timecop (0.9.1)
|
|
107
|
+
tzinfo (1.2.7)
|
|
108
|
+
thread_safe (~> 0.1)
|
|
109
|
+
unicode-display_width (1.7.0)
|
|
110
|
+
zeitwerk (2.4.0)
|
|
111
|
+
|
|
112
|
+
PLATFORMS
|
|
113
|
+
ruby
|
|
114
|
+
|
|
115
|
+
DEPENDENCIES
|
|
116
|
+
actionmailer (~> 6.0)
|
|
117
|
+
devpack (~> 0.2.0)
|
|
118
|
+
postmortem!
|
|
119
|
+
rspec (~> 3.9)
|
|
120
|
+
rspec-its (~> 1.3)
|
|
121
|
+
rubocop (~> 0.88.0)
|
|
122
|
+
strong_versions (~> 0.4.5)
|
|
123
|
+
timecop (~> 0.9.1)
|
|
124
|
+
|
|
125
|
+
BUNDLED WITH
|
|
126
|
+
2.1.4
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Bob Farrell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/Makefile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Postmortem
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/postmortem`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'postmortem'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle install
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install postmortem
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
+
|
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/postmortem.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'postmortem'
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require 'irb'
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<link rel="stylesheet"
|
|
4
|
+
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
|
|
5
|
+
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
|
|
6
|
+
crossorigin="anonymous">
|
|
7
|
+
</head>
|
|
8
|
+
<body style="background-color: #efefef; padding: 2rem; height: 100%">
|
|
9
|
+
<div style="height: 100%; display: flex; flex-direction: column">
|
|
10
|
+
<table class="table table-hover table-bordered" style="background-color: #fff">
|
|
11
|
+
<tbody>
|
|
12
|
+
<tr>
|
|
13
|
+
<th style="width: 7rem;">From:</th>
|
|
14
|
+
<td><%= mail.from&.join(', ') %></td>
|
|
15
|
+
</tr>
|
|
16
|
+
|
|
17
|
+
<tr>
|
|
18
|
+
<th>To:</th>
|
|
19
|
+
<td><%= mail.to&.join(', ') %></td>
|
|
20
|
+
</tr>
|
|
21
|
+
|
|
22
|
+
<tr>
|
|
23
|
+
<th>Cc:</th>
|
|
24
|
+
<td><%= mail.cc&.join(', ') %></td>
|
|
25
|
+
</tr>
|
|
26
|
+
|
|
27
|
+
<tr>
|
|
28
|
+
<th>Bcc:</th>
|
|
29
|
+
<td><%= mail.bcc&.join(', ') %></td>
|
|
30
|
+
</tr>
|
|
31
|
+
|
|
32
|
+
<tr>
|
|
33
|
+
<th>Subject:</th>
|
|
34
|
+
<td><%= mail.subject %></td>
|
|
35
|
+
</tr>
|
|
36
|
+
</tbody>
|
|
37
|
+
</table>
|
|
38
|
+
|
|
39
|
+
<div style="background-color: #ffffff; padding: 2rem; height: 100%; flex-grow: 1">
|
|
40
|
+
<iframe id="mail-iframe" src="" style="border-style: none; width: 100%; height: 100%"></iframe>
|
|
41
|
+
</div>
|
|
42
|
+
<script>
|
|
43
|
+
var mailContent = <%= mail.html_body.to_json %>;
|
|
44
|
+
var iframeDocument = document.querySelector("#mail-iframe").contentDocument;
|
|
45
|
+
iframeDocument.write(mailContent);
|
|
46
|
+
iframeDocument.close();
|
|
47
|
+
</script>
|
|
48
|
+
</body>
|
|
49
|
+
</html>
|
data/lib/postmortem.rb
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'tempfile'
|
|
4
|
+
require 'pathname'
|
|
5
|
+
require 'time'
|
|
6
|
+
require 'fileutils'
|
|
7
|
+
require 'mail'
|
|
8
|
+
require 'erb'
|
|
9
|
+
require 'json'
|
|
10
|
+
|
|
11
|
+
require 'postmortem/version'
|
|
12
|
+
require 'postmortem/adapters'
|
|
13
|
+
require 'postmortem/delivery'
|
|
14
|
+
require 'postmortem/layout'
|
|
15
|
+
|
|
16
|
+
# HTML email inspection tool.
|
|
17
|
+
module Postmortem
|
|
18
|
+
class Error < StandardError; end
|
|
19
|
+
|
|
20
|
+
class << self
|
|
21
|
+
attr_reader :output_directory, :layout
|
|
22
|
+
attr_accessor :output_file
|
|
23
|
+
|
|
24
|
+
def output_directory=(val)
|
|
25
|
+
@output_directory = Pathname.new(val)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def layout=(val)
|
|
29
|
+
@layout = Pathname.new(val)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def record_delivery(mail)
|
|
33
|
+
Delivery.new(mail)
|
|
34
|
+
.tap(&:record)
|
|
35
|
+
.tap { |delivery| log_delivery(delivery) }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def try_load(*args)
|
|
39
|
+
args.each { |arg| require arg }
|
|
40
|
+
rescue LoadError
|
|
41
|
+
false
|
|
42
|
+
else
|
|
43
|
+
yield
|
|
44
|
+
true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def log_delivery(delivery)
|
|
50
|
+
output_file.write(colorized(delivery.path.to_s) + "\n")
|
|
51
|
+
output_file.flush
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def colorized(val)
|
|
55
|
+
return val unless output_file.tty?
|
|
56
|
+
|
|
57
|
+
"\e[34m[postmortem]\e[36m #{val}\e[0m"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
Postmortem.output_directory = File.join(Dir.tmpdir, 'postmortem')
|
|
63
|
+
Postmortem.output_file = STDOUT
|
|
64
|
+
Postmortem.layout = File.expand_path(File.join(__dir__, '..', 'layout', 'default.html.erb'))
|
|
65
|
+
Postmortem.try_load('action_mailer', 'active_support') { require 'postmortem/action_mailer' }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Postmortem
|
|
4
|
+
module Adapters
|
|
5
|
+
# Rails ActionMailer adapter.
|
|
6
|
+
class ActionMailer < Base
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
def adapted(data)
|
|
10
|
+
{
|
|
11
|
+
from: data[:from],
|
|
12
|
+
to: data[:to],
|
|
13
|
+
cc: data[:cc],
|
|
14
|
+
bcc: data[:bcc],
|
|
15
|
+
subject: data[:subject],
|
|
16
|
+
html_body: Mail.new(data[:mail]).html_part.decoded.strip
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Postmortem
|
|
4
|
+
module Adapters
|
|
5
|
+
# Base interface implementation for all Postmortem adapters.
|
|
6
|
+
class Base
|
|
7
|
+
def initialize(data)
|
|
8
|
+
@mail = adapted(data)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
%i[from to cc bcc subject html_body].each do |method_name|
|
|
12
|
+
define_method method_name do
|
|
13
|
+
@mail[method_name]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def adapted(_data)
|
|
20
|
+
raise NotImplementedError,
|
|
21
|
+
'Adapter must be a child class of Base which implements #adapted'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Postmortem
|
|
4
|
+
# Abstraction of an email delivery. Capable of writing email HTML body to disk.
|
|
5
|
+
class Delivery
|
|
6
|
+
attr_reader :path
|
|
7
|
+
|
|
8
|
+
def initialize(adapter)
|
|
9
|
+
@adapter = adapter
|
|
10
|
+
@path = Postmortem.output_directory.join(filename)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def record
|
|
14
|
+
path.parent.mkpath
|
|
15
|
+
File.write(path, Layout.new(@adapter).content)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def filename
|
|
21
|
+
"#{timestamp}__#{safe_subject}.html"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def timestamp
|
|
25
|
+
Time.now.strftime('%Y-%m-%d_%H-%M-%S')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def safe_subject
|
|
29
|
+
return 'no-subject' if @adapter.subject.empty?
|
|
30
|
+
|
|
31
|
+
@adapter.subject.tr(' ', '_').split('').select { |char| safe_chars.include?(char) }.join
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def safe_chars
|
|
35
|
+
('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + ['-', '_']
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Postmortem
|
|
4
|
+
# Wraps provided body in an enclosing layout for presentation purposes.
|
|
5
|
+
class Layout
|
|
6
|
+
def initialize(adapter)
|
|
7
|
+
@adapter = adapter
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def content
|
|
11
|
+
mail = @adapter
|
|
12
|
+
ERB.new(Postmortem.layout.read).result(binding)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/postmortem.gemspec
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/postmortem/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'postmortem'
|
|
7
|
+
spec.version = Postmortem::VERSION
|
|
8
|
+
spec.authors = ['Bob Farrell']
|
|
9
|
+
spec.email = ['git@bob.frl']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'Development HTML Email Inspection Tool'
|
|
12
|
+
spec.description = 'Preview HTML emails in your browser during development'
|
|
13
|
+
spec.homepage = 'https://github.com/bobf/postmortem'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/bobf/postmortem/blob/master/README.md'
|
|
20
|
+
|
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
23
|
+
end
|
|
24
|
+
spec.bindir = 'bin'
|
|
25
|
+
spec.executables = []
|
|
26
|
+
spec.require_paths = ['lib']
|
|
27
|
+
|
|
28
|
+
spec.add_runtime_dependency 'mail', '~> 2.7'
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency 'actionmailer', '~> 6.0'
|
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.9'
|
|
32
|
+
spec.add_development_dependency 'rspec-its', '~> 1.3'
|
|
33
|
+
spec.add_development_dependency 'rubocop', '~> 0.88.0'
|
|
34
|
+
spec.add_development_dependency 'strong_versions', '~> 0.4.5'
|
|
35
|
+
spec.add_development_dependency 'timecop', '~> 0.9.1'
|
|
36
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: postmortem
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Bob Farrell
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-08-15 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: mail
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.7'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.7'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: actionmailer
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '6.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '6.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.9'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.9'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec-its
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.3'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.3'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rubocop
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.88.0
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.88.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: strong_versions
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 0.4.5
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 0.4.5
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: timecop
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: 0.9.1
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 0.9.1
|
|
111
|
+
description: Preview HTML emails in your browser during development
|
|
112
|
+
email:
|
|
113
|
+
- git@bob.frl
|
|
114
|
+
executables: []
|
|
115
|
+
extensions: []
|
|
116
|
+
extra_rdoc_files: []
|
|
117
|
+
files:
|
|
118
|
+
- ".gitignore"
|
|
119
|
+
- ".rspec"
|
|
120
|
+
- ".rubocop.yml"
|
|
121
|
+
- Gemfile
|
|
122
|
+
- Gemfile.lock
|
|
123
|
+
- LICENSE.txt
|
|
124
|
+
- Makefile
|
|
125
|
+
- README.md
|
|
126
|
+
- Rakefile
|
|
127
|
+
- bin/console
|
|
128
|
+
- bin/setup
|
|
129
|
+
- layout/default.html.erb
|
|
130
|
+
- lib/postmortem.rb
|
|
131
|
+
- lib/postmortem/action_mailer.rb
|
|
132
|
+
- lib/postmortem/adapters.rb
|
|
133
|
+
- lib/postmortem/adapters/action_mailer.rb
|
|
134
|
+
- lib/postmortem/adapters/base.rb
|
|
135
|
+
- lib/postmortem/delivery.rb
|
|
136
|
+
- lib/postmortem/layout.rb
|
|
137
|
+
- lib/postmortem/version.rb
|
|
138
|
+
- postmortem.gemspec
|
|
139
|
+
homepage: https://github.com/bobf/postmortem
|
|
140
|
+
licenses:
|
|
141
|
+
- MIT
|
|
142
|
+
metadata:
|
|
143
|
+
homepage_uri: https://github.com/bobf/postmortem
|
|
144
|
+
source_code_uri: https://github.com/bobf/postmortem
|
|
145
|
+
changelog_uri: https://github.com/bobf/postmortem/blob/master/README.md
|
|
146
|
+
post_install_message:
|
|
147
|
+
rdoc_options: []
|
|
148
|
+
require_paths:
|
|
149
|
+
- lib
|
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
|
+
requirements:
|
|
152
|
+
- - ">="
|
|
153
|
+
- !ruby/object:Gem::Version
|
|
154
|
+
version: 2.3.0
|
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0'
|
|
160
|
+
requirements: []
|
|
161
|
+
rubygems_version: 3.1.2
|
|
162
|
+
signing_key:
|
|
163
|
+
specification_version: 4
|
|
164
|
+
summary: Development HTML Email Inspection Tool
|
|
165
|
+
test_files: []
|