catch_mail 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.
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>CatchMail - Email Catcher</title>
5
+ <%= stylesheet_link_tag "catch_mail" %>
6
+ <%= javascript_include_tag "catch_mail/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body class="bg-light">
10
+ <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
11
+ <div class="container">
12
+ <a class="navbar-brand" href="<%= catch_mail.messages_path %>">
13
+ <i class="fas fa-envelope"></i> CatchMail
14
+ </a>
15
+ <span class="navbar-text">
16
+ <%= CatchMail::Message.count %> emails caught
17
+ </span>
18
+ </div>
19
+ </nav>
20
+
21
+ <div class="container mt-4">
22
+ <%= yield %>
23
+ </div>
24
+ </body>
25
+ </html>
@@ -0,0 +1,9 @@
1
+ CatchMail::Engine.routes.draw do
2
+ resources :messages do
3
+ collection do
4
+ delete :clear_all
5
+ end
6
+ end
7
+
8
+ root to: 'messages#index'
9
+ end
@@ -0,0 +1,18 @@
1
+ require 'action_mailer'
2
+
3
+ module CatchMail
4
+ class DeliveryMethod
5
+ def deliver!(mail)
6
+ message = CatchMail::Message.create(
7
+ from: mail.from.join(', '),
8
+ to: mail.to.join(', '),
9
+ subject: mail.subject,
10
+ body: mail.body.decoded,
11
+ raw_message: mail.to_s
12
+ )
13
+ Rails.logger.info "CatchMail: Email intercepted and stored with ID #{message.id}"
14
+ end
15
+ end
16
+ end
17
+
18
+ ActionMailer::Base.add_delivery_method :catch_mail, CatchMail::DeliveryMethod
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CatchMail
4
+ VERSION = "0.1.0"
5
+ end
data/lib/catch_mail.rb ADDED
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require_relative "catch_mail/version"
5
+ require_relative "catch_mail/delivery_method"
6
+ require_relative "catch_mail/app/models/catch_mail/message"
7
+ require "rails/engine"
8
+
9
+ module CatchMail
10
+ class Error < StandardError; end
11
+
12
+ class Engine < ::Rails::Engine
13
+ isolate_namespace CatchMail
14
+
15
+ config.generators do |g|
16
+ g.test_framework :rspec
17
+ g.fixture_replacement :factory_bot
18
+ g.factory_bot dir: "spec/factories"
19
+ end
20
+
21
+ config.paths['db/migrate'] = 'lib/catch_mail/db/migrate'
22
+
23
+ initializer "catch_mail.assets.precompile" do |app|
24
+ # Only add assets if sprockets is available
25
+ if app.config.respond_to?(:assets)
26
+ app.config.assets.precompile += %w[
27
+ catch_mail/application.css
28
+ catch_mail/application.js
29
+ vendor/bootstrap.min.css
30
+ vendor/fontawesome.min.css
31
+ vendor/bootstrap.bundle.min.js
32
+ ]
33
+ end
34
+ end
35
+
36
+ initializer "catch_mail.setup_delivery_method" do |app|
37
+ if Rails.env.development? && app.config.action_mailer.delivery_method == :smtp
38
+ app.config.action_mailer.delivery_method = :catch_mail
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,4 @@
1
+ module SolidMail
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
Binary file
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: catch_mail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sami Dghim
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rails
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '7.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '7.0'
26
+ description: CatchMail is a Rails engine that intercepts emails in development, stores
27
+ them in memory, and provides a web interface to view, search, and filter them in
28
+ real-time.
29
+ email:
30
+ - samidghim@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - README.md
36
+ - Rakefile
37
+ - lib/catch_mail.rb
38
+ - lib/catch_mail/app/assets/javascripts/catch_mail/application.js
39
+ - lib/catch_mail/app/assets/javascripts/vendor/bootstrap.bundle.min.js
40
+ - lib/catch_mail/app/assets/stylesheets/catch_mail/application.css
41
+ - lib/catch_mail/app/assets/stylesheets/vendor/bootstrap.min.css
42
+ - lib/catch_mail/app/assets/stylesheets/vendor/fontawesome.min.css
43
+ - lib/catch_mail/app/controllers/catch_mail/messages_controller.rb
44
+ - lib/catch_mail/app/models/catch_mail/message.rb
45
+ - lib/catch_mail/app/views/catch_mail/messages/_messages.html.erb
46
+ - lib/catch_mail/app/views/catch_mail/messages/index.html.erb
47
+ - lib/catch_mail/app/views/catch_mail/messages/show.html.erb
48
+ - lib/catch_mail/app/views/layouts/catch_mail/application.html.erb
49
+ - lib/catch_mail/config/routes.rb
50
+ - lib/catch_mail/delivery_method.rb
51
+ - lib/catch_mail/version.rb
52
+ - sig/catch_mail.rbs
53
+ - solid_mail-0.1.0.gem
54
+ homepage: https://github.com/samydghim/catch_mail
55
+ licenses: []
56
+ metadata:
57
+ allowed_push_host: https://rubygems.org
58
+ homepage_uri: https://github.com/samydghim/catch_mail
59
+ source_code_uri: https://github.com/samydghim/catch_mail
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 3.2.0
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.6.9
75
+ specification_version: 4
76
+ summary: A simple email catcher for Rails development
77
+ test_files: []