mail_plugger 1.0.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +63 -3
  3. data/README.md +33 -22
  4. data/lib/fake_plugger/delivery_method.rb +186 -0
  5. data/lib/fake_plugger/railtie.rb +14 -0
  6. data/lib/mail_plugger.rb +9 -1
  7. data/lib/mail_plugger/version.rb +1 -1
  8. metadata +15 -46
  9. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -22
  10. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -16
  11. data/.gitignore +0 -11
  12. data/.rspec +0 -3
  13. data/.rubocop.yml +0 -53
  14. data/.travis.yml +0 -22
  15. data/Appraisals +0 -13
  16. data/CODE_OF_CONDUCT.md +0 -14
  17. data/CONTRIBUTING.md +0 -26
  18. data/Gemfile +0 -18
  19. data/Gemfile.lock +0 -81
  20. data/Rakefile +0 -11
  21. data/bin/console +0 -17
  22. data/bin/setup +0 -8
  23. data/docs/usage_in_ruby_on_rails.md +0 -182
  24. data/docs/usage_in_script_or_console.md +0 -158
  25. data/docs/usage_of_attachments_in_ruby_on_rails.md +0 -110
  26. data/docs/usage_of_aws_ses_in_ruby_on_rails.md +0 -136
  27. data/docs/usage_of_delivery_method.md +0 -104
  28. data/docs/usage_of_mailgun_in_ruby_on_rails.md +0 -58
  29. data/docs/usage_of_mandrill_in_ruby_on_rails.md +0 -104
  30. data/docs/usage_of_more_delivery_system_in_ruby_on_rails.md +0 -332
  31. data/docs/usage_of_one_delivery_system_with_more_send_methods_in_ruby_on_rails.md +0 -119
  32. data/docs/usage_of_plug_in_method.md +0 -62
  33. data/docs/usage_of_postmark_in_ruby_on_rails.md +0 -59
  34. data/docs/usage_of_secial_options_in_ruby_on_rails.md +0 -90
  35. data/docs/usage_of_sendgrid_in_ruby_on_rails.md +0 -82
  36. data/docs/usage_of_sparkpost_in_ruby_on_rails.md +0 -142
  37. data/gemfiles/.bundle/config +0 -2
  38. data/gemfiles/mail_2.6.gemfile +0 -14
  39. data/gemfiles/mail_2.6.gemfile.lock +0 -84
  40. data/gemfiles/mail_2.7.0.gemfile +0 -14
  41. data/gemfiles/mail_2.7.0.gemfile.lock +0 -82
  42. data/gemfiles/mail_2.7.gemfile +0 -14
  43. data/gemfiles/mail_2.7.gemfile.lock +0 -82
  44. data/images/mail_plugger.png +0 -0
  45. data/mail_plugger.gemspec +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17973c75bad45ddc1062638b40375b54d904545dc71d6c019be433b8f72a94d5
4
- data.tar.gz: 86ff45ddfde8982854ed3959fa252da096f856aee4e7233e4063d89e04ee9d7d
3
+ metadata.gz: f909bb4d7136983266dbbe01519966ec0a3f5166cd7576401de5129e8fb6d255
4
+ data.tar.gz: 79a650bdbe95199bb28ff1dddefbf405d09e2dcf661d8bb0557b7c4594d85cc4
5
5
  SHA512:
6
- metadata.gz: 76cf32c05fe8c0f091bccefeee7f18cd6424c0e81588c806d4538aac4c8a155e7784e4753e6b7c270d4f531f14b518ca80d231e7da22a4a97cf2ad92fb12d9a6
7
- data.tar.gz: c68c13d1426dec32f33607f1ca1ff6ca36e92e950c23df4ded15ba1ee39dd4c2ee7c30a1ade1f62adcd8892584d123d50b1dddebbb241383eb0c46cca5d4c413
6
+ metadata.gz: 82416b31f9a56713434d37055caf55c83d361ea0bb22f1d643116106bc13cb5803974d9f89945ef938471fb63626742299353f40673df24f49f2ef098172daee
7
+ data.tar.gz: 2ee3ad7f530aad9e8dcf864bef0dc17c3dd23fea193fa796cffd676bf917f11d36a0af95632edb46fd2bb0267c12035f95b4783dd80fea1cff2125d5fcfc90f6
data/CHANGELOG.md CHANGED
@@ -1,23 +1,83 @@
1
1
  # Change log
2
2
 
3
+ ## 1.3.0 (2021-04-14)
4
+
5
+ ### New features
6
+
7
+ * Add MailGrabber to FakePlugger. Now we can use FakePlugger and MailGrabber in same time.
8
+
9
+ ### Changes
10
+
11
+ * Remove unnecessary double quotes from `show_debug_info` method in `FakePlugger::DeliveryMethod` and fix documentations.
12
+ * Update bundler and gems.
13
+ * Update bug_report.md.
14
+
15
+
16
+ ## 1.2.0 (2021-03-18)
17
+
18
+ ### New organization
19
+
20
+ * Move mail_plugger repository into MailToolbox organization.
21
+
22
+ ### Changes
23
+
24
+ * Update gems.
25
+ * Fix some documentation issues.
26
+
27
+
28
+ ## 1.1.1 (2021-01-21)
29
+
30
+ ### Changes
31
+
32
+ * Change `FakePlugger::DeliveryMethod` to returns with the extracted delivery data instead of the message object.
33
+ * Update code documentations.
34
+ * Add missing FakePlugger description in the README.md.
35
+
36
+
37
+ ## 1.1.0 (2021-01-18)
38
+
39
+ ### New features
40
+
41
+ * Add FakePlugger to mock MailPlugger.
42
+
43
+ ### Changes
44
+
45
+ * Fix typos in the documentations.
46
+ * Add more metadata to gempspec file.
47
+
48
+
49
+ ## 1.0.1 (2021-01-15)
50
+
51
+ ### Changes
52
+
53
+ * Tidy up the gemspec file and change which files contains in the gem. Now the gem is much smaller.
54
+ * Add a new mail plugger image which has a different canvas and use it in the README.md.
55
+
56
+
3
57
  ## 1.0.0 (2021-01-14)
4
58
 
59
+ ### Changes
60
+
5
61
  * Update gems.
6
62
  * Remove `webmock` gem to clean up unused things.
7
63
  * Update documentations.
8
64
 
65
+
9
66
  ## 1.0.0.rc1 (2021-01-13)
10
67
 
68
+ ### Changes
69
+
11
70
  * Change description and fix changelog_uri in gemspec file.
12
71
  * Add/Change documentations.
13
72
  * Update gems.
14
73
  * Change `MailPlugger.plug_in` and `MailPlugger::MailHelper.delivery_options` methods to accept strings and symbols.
15
- * Change `MailPlugger::MailHelper.delivery_data` method that we can retrieve massage object as well.
74
+ * Change `MailPlugger::MailHelper.delivery_data` method that we can retrieve message object as well.
16
75
  * Check hash keys in `MailPlugger::MailHelper.delivery_system` method, so now if we are add wrong `delivey_system` then we are getting a meaningful error message.
17
76
  * Change `MailPlugger::MailHelper.extract_attachments` method. If an attachment is inline then the hash contains the `filename` and `cid` as well.
18
77
  * Add/Change tests.
19
- * Change `MailPlugger::MailHelper.delivery_option` that returns with indifferent hash
78
+ * Change `MailPlugger::MailHelper.delivery_option` that returns with indifferent hash.
79
+
20
80
 
21
81
  ## 1.0.0.beta1 (2021-01-02)
22
82
 
23
- * Implement MailPlugger methods and functionality. See [README.md](https://github.com/norbertszivos/mail_plugger/blob/main/README.md)
83
+ * Implement MailPlugger methods and functionality. See [README.md](https://github.com/MailToolbox/mail_plugger/blob/main/README.md)
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # M<img src="https://github.com/norbertszivos/mail_plugger/blob/main/images/mail_plugger.png" height="25" />ilPlugger
1
+ # M<img src="https://raw.githubusercontent.com/MailToolbox/mail_plugger/main/images/mail_plugger800x500.png" height="22" />ilPlugger
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/mail_plugger.svg)](https://badge.fury.io/rb/mail_plugger)
4
- [![MIT license](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE.txt)
4
+ [![MIT license](https://img.shields.io/badge/license-MIT-brightgreen)](https://github.com/MailToolbox/mail_plugger/blob/main/LICENSE.txt)
5
5
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
6
- [![Build Status](https://travis-ci.com/norbertszivos/mail_plugger.svg?branch=main)](https://travis-ci.com/norbertszivos/mail_plugger)
7
- [![Maintainability](https://api.codeclimate.com/v1/badges/bd2cda43214c111d8d16/maintainability)](https://codeclimate.com/github/norbertszivos/mail_plugger/maintainability)
8
- [![Test Coverage](https://api.codeclimate.com/v1/badges/bd2cda43214c111d8d16/test_coverage)](https://codeclimate.com/github/norbertszivos/mail_plugger/test_coverage)
6
+ [![Build Status](https://travis-ci.com/MailToolbox/mail_plugger.svg?branch=main)](https://travis-ci.com/MailToolbox/mail_plugger)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/137881380fc475b4a836/maintainability)](https://codeclimate.com/github/MailToolbox/mail_plugger/maintainability)
8
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/137881380fc475b4a836/test_coverage)](https://codeclimate.com/github/MailToolbox/mail_plugger/test_coverage)
9
9
 
10
10
  **MailPlugger** helps you to use different mail providers' **API**. You can use any APIs which one would like to use. It allows you to send different emails with different APIs. Also it can help to move between providers, load balacing or cost management.
11
11
 
@@ -27,20 +27,31 @@ Or install it yourself as:
27
27
 
28
28
  ## Usage
29
29
 
30
- - [How to use MailPlugger.plug_in method](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_plug_in_method.md)
31
- - [How to use MailPlugger::DeliveryMethod class](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_delivery_method.md)
32
- - [How to use MailPlugger in a Ruby script or IRB console](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_in_script_or_console.md)
33
- - [How to use MailPlugger in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_in_ruby_on_rails.md)
34
- - [How to add API specific options to the mailer method in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_secial_options_in_ruby_on_rails.md)
35
- - [How to add attachments to the mailer method in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_attachments_in_ruby_on_rails.md)
36
- - [How to use more delivey systems in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_more_delivery_system_in_ruby_on_rails.md)
37
- - [How to use one delivey system with more send methods in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_one_delivery_system_with_more_send_methods_in_ruby_on_rails.md)
38
- - [How to use AWS SES with MailPlugger in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_aws_ses_in_ruby_on_rails.md)
39
- - [How to use SparkPost with MailPlugger in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_sparkpost_in_ruby_on_rails.md)
40
- - [How to use SendGrid with MailPlugger in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_sendgrid_in_ruby_on_rails.md)
41
- - [How to use Mandrill with MailPlugger in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_mandrill_in_ruby_on_rails.md)
42
- - [How to use Postmark with MailPlugger in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_postmark_in_ruby_on_rails.md)
43
- - [How to use Mailgun with MailPlugger in Ruby on Rails](https://github.com/norbertszivos/mail_plugger/blob/main/docs/usage_of_mailgun_in_ruby_on_rails.md)
30
+ - [How to use MailPlugger.plug_in method](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_plug_in_method.md)
31
+ - [How to use MailPlugger::DeliveryMethod class](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_delivery_method.md)
32
+ - [How to use MailPlugger in a Ruby script or IRB console](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_in_script_or_console.md)
33
+ - [How to use MailPlugger in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_in_ruby_on_rails.md)
34
+ - [How to add API specific options to the mailer method in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_special_options_in_ruby_on_rails.md)
35
+ - [How to add attachments to the mailer method in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_attachments_in_ruby_on_rails.md)
36
+ - [How to use more delivey systems in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_more_delivery_system_in_ruby_on_rails.md)
37
+ - [How to use one delivey system with more send methods in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_one_delivery_system_with_more_send_methods_in_ruby_on_rails.md)
38
+ - [How to use AWS SES with MailPlugger in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_aws_ses_in_ruby_on_rails.md)
39
+ - [How to use SparkPost with MailPlugger in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_sparkpost_in_ruby_on_rails.md)
40
+ - [How to use SendGrid with MailPlugger in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_sendgrid_in_ruby_on_rails.md)
41
+ - [How to use Mandrill with MailPlugger in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_mandrill_in_ruby_on_rails.md)
42
+ - [How to use Postmark with MailPlugger in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_postmark_in_ruby_on_rails.md)
43
+ - [How to use Mailgun with MailPlugger in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_mailgun_in_ruby_on_rails.md)
44
+
45
+ # F<img src="https://raw.githubusercontent.com/MailToolbox/mail_plugger/main/images/fake_plugger800x500.png" height="22" />kePlugger
46
+
47
+ **FakePlugger** is a delivery method to mock **MailPlugger**. It is working similarly like **MailPlugger**, but it won't send any emails (but if we would like it is possible, just we should do manually). Also it can write out debug informations or we can manipulate the response with it. Another option that we can use **[MailGrabber](https://github.com/MailToolbox/mail_grabber)** web interface if the delivery method is `:fake_plugger`.
48
+
49
+ ## Usage
50
+
51
+ - [How to use FakePlugger::DeliveryMethod class](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_fake_plugger_delivery_method.md)
52
+ - [How to use FakePlugger in a Ruby script or IRB console](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_fake_plugger_in_script_or_console.md)
53
+ - [How to use FakePlugger in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_fake_plugger_in_ruby_on_rails.md)
54
+ - [How to use FakePlugger with MailGrabber in Ruby on Rails](https://github.com/MailToolbox/mail_plugger/blob/main/docs/usage_of_fake_plugger_with_mail_grabber_in_ruby_on_rails.md)
44
55
 
45
56
  ## Development
46
57
 
@@ -50,7 +61,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
50
61
 
51
62
  To release a new version:
52
63
 
53
- - Update CHANGELOG.md
64
+ - Update [CHANGELOG.md](https://github.com/MailToolbox/mail_plugger/blob/main/CHANGELOG.md)
54
65
  - Update the version number in `version.rb` manually or use `gem-release` gem and run `gem bump -v major|minor|patch|rc|beta`.
55
66
  - Build gem with `bundle exec rake build`.
56
67
  - Run `bundle install` and `bundle exec appraisal install` to update gemfiles and commit the changes.
@@ -58,7 +69,7 @@ To release a new version:
58
69
 
59
70
  ## Contributing
60
71
 
61
- Bug reports and pull requests are welcome. Please read [CONTRIBUTING.md](https://github.com/norbertszivos/mail_plugger/blob/main/CONTRIBUTING.md) if you would like to contribute to this project.
72
+ Bug reports and pull requests are welcome. Please read [CONTRIBUTING.md](https://github.com/MailToolbox/mail_plugger/blob/main/CONTRIBUTING.md) if you would like to contribute to this project.
62
73
 
63
74
  ## Inspiration
64
75
 
@@ -69,4 +80,4 @@ Bug reports and pull requests are welcome. Please read [CONTRIBUTING.md](https:/
69
80
 
70
81
  ## License
71
82
 
72
- The gem is available as open source under the terms of the [MIT License](https://github.com/norbertszivos/mail_plugger/blob/main/LICENSE.txt).
83
+ The gem is available as open source under the terms of the [MIT License](https://github.com/MailToolbox/mail_plugger/blob/main/LICENSE.txt).
@@ -0,0 +1,186 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mail_grabber' if Gem.loaded_specs.key?('mail_grabber')
4
+
5
+ module FakePlugger
6
+ class DeliveryMethod < MailPlugger::DeliveryMethod
7
+ # Initialize FakePlugger delivery method attributes. If we are using
8
+ # MailPlugger.plug_in method, then these attributes can be nil, if not then
9
+ # we should set these attributes.
10
+ #
11
+ # @param [Hash] options check options below
12
+ # @option options [Class/Hash] client
13
+ # e.g. DefinedApiClientClass or { 'key' => DefinedApiClientClass }
14
+ #
15
+ # @option options [Array/Hash] delivery_options
16
+ # e.g. [:to, :from, :subject, :body] or
17
+ # { 'key' => [:to, :from, :subject, :body] }
18
+ #
19
+ # @option options [Hash] delivery_settings
20
+ # e.g. { return_response: true }
21
+ #
22
+ # @option options [String/Symbol] default_delivery_system
23
+ # e.g. 'defined_api'
24
+ #
25
+ # @option options [Boolean] debug
26
+ # if true it will show debug informations
27
+ #
28
+ # @option options [Boolean] raw_message
29
+ # if true it will show raw message
30
+ #
31
+ # @option options [String/Symbol/Array/Hash] response
32
+ # the deliver! method will return with this value or if this value is nil
33
+ # then it will return with the client object
34
+ #
35
+ # @option options [Boolean] use_mail_grabber
36
+ # if true it will store the message in a database which MailGrabber can
37
+ # read
38
+ def initialize(options = {})
39
+ super
40
+
41
+ @debug = options[:debug] ||
42
+ settings[:fake_plugger_debug] || false
43
+ @raw_message = options[:raw_message] ||
44
+ settings[:fake_plugger_raw_message] || false
45
+ @response = options[:response] || settings[:fake_plugger_response]
46
+ @use_mail_grabber = options[:use_mail_grabber] ||
47
+ settings[:fake_plugger_use_mail_grabber] || false
48
+ end
49
+
50
+ # Mock send message with the given client if the message parameter is a
51
+ # Mail::Message object. If 'response' parameter is nil then it will extract
52
+ # those information from the Mail::Message object which was provided in the
53
+ # 'delivery_options'. After that it generates a hash with these data and
54
+ # returns with the provided client class which has a 'deliver' method, but
55
+ # it won't call the 'deliver' method.
56
+ # If the 'response' parameter is a hash with 'return_delivery_data: true'
57
+ # then it will retrun with the extracted delivery data.
58
+ # If the 'response' parameter is not nil then retruns with that given data
59
+ # without call any other methods.
60
+ # Except if 'debug' is true. In this case it will call those methods which
61
+ # is calling in normal operation as well.
62
+ # If 'debug' is true then it prints out some debug informations.
63
+ # If 'raw_message' is true then it prints out raw message.
64
+ # if 'use_mail_grabber' is true then it stores the message in a database.
65
+ #
66
+ # @param [Mail::Message] message what we would like to send
67
+ #
68
+ # @return [Mail::Message/Hash] depends on the given value
69
+ #
70
+ # @example
71
+ #
72
+ # MailPlugger.plug_in('test_api_client') do |api|
73
+ # api.delivery_options = %i[from to subject body]
74
+ # api.delivery_settings = {
75
+ # fake_plugger_debug: true,
76
+ # fake_plugger_raw_message: true,
77
+ # fake_plugger_use_mail_grabber: true,
78
+ # fake_plugger_response: { response: 'OK' }
79
+ # }
80
+ # api.client = DefinedApiClientClass
81
+ # end
82
+ #
83
+ # message = Mail.new(from: 'from@example.com', to: 'to@example.com',
84
+ # subject: 'Test email', body: 'Test email body')
85
+ #
86
+ # FakePlugger::DeliveryMethod.new.deliver!(message)
87
+ #
88
+ # # or
89
+ #
90
+ # message = Mail.new(from: 'from@example.com', to: 'to@example.com',
91
+ # subject: 'Test email', body: 'Test email body')
92
+ #
93
+ # FakePlugger::DeliveryMethod.new(
94
+ # delivery_options: %i[from to subject body],
95
+ # client: DefinedApiClientClass,
96
+ # debug: true,
97
+ # raw_message: true,
98
+ # use_mail_grabber: true,
99
+ # response: { response: 'OK' }
100
+ # ).deliver!(message)
101
+ #
102
+ def deliver!(message)
103
+ unless message.is_a?(Mail::Message)
104
+ raise MailPlugger::Error::WrongParameter,
105
+ 'The given parameter is not a Mail::Message'
106
+ end
107
+
108
+ @message = message
109
+
110
+ call_extra_options
111
+
112
+ return_with_response
113
+ end
114
+
115
+ private
116
+
117
+ # Call extra options like show debug informations, show raw message,
118
+ # use mail grabber
119
+ def call_extra_options
120
+ show_debug_info if @debug
121
+ show_raw_message if @raw_message
122
+
123
+ return unless Gem.loaded_specs.key?('mail_grabber') && @use_mail_grabber
124
+
125
+ MailGrabber::DeliveryMethod.new.deliver!(@message)
126
+ end
127
+
128
+ # Return with a response which depends on the conditions.
129
+ def return_with_response
130
+ return client.new(delivery_data) if @response.nil?
131
+ if @response.is_a?(Hash) && @response[:return_delivery_data]
132
+ return delivery_data
133
+ end
134
+
135
+ @response
136
+ end
137
+
138
+ # Show debug informations from variables and methods.
139
+ def show_debug_info
140
+ puts <<~DEBUG_INFO
141
+
142
+ ===================== FakePlugger::DeliveryMethod =====================
143
+
144
+ ------------------------------ Variables ------------------------------
145
+
146
+ ==> @client: #{@client.inspect}
147
+
148
+ ==> @delivery_options: #{@delivery_options.inspect}
149
+
150
+ ==> @delivery_settings: #{@delivery_settings.inspect}
151
+
152
+ ==> @default_delivery_system: #{@default_delivery_system.inspect}
153
+
154
+ ==> @message: #{@message.inspect}
155
+
156
+ ------------------------------- Methods -------------------------------
157
+
158
+ ==> client: #{client.inspect}
159
+
160
+ ==> delivery_system: #{delivery_system.inspect}
161
+
162
+ ==> delivery_options: #{delivery_options.inspect}
163
+
164
+ ==> delivery_data: #{delivery_data.inspect}
165
+
166
+ ==> settings: #{settings.inspect}
167
+
168
+ =======================================================================
169
+
170
+ DEBUG_INFO
171
+ end
172
+
173
+ # Show raw message for debug purpose.
174
+ def show_raw_message
175
+ puts <<~RAW_MESSAGE
176
+
177
+ ============================ Mail::Message ============================
178
+
179
+ #{@message}
180
+
181
+ =======================================================================
182
+
183
+ RAW_MESSAGE
184
+ end
185
+ end
186
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FakePlugger
4
+ class Railtie < Rails::Railtie
5
+ initializer 'fake_plugger.add_delivery_method' do
6
+ ActiveSupport.on_load :action_mailer do
7
+ ActionMailer::Base.add_delivery_method(
8
+ :fake_plugger,
9
+ FakePlugger::DeliveryMethod
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
data/lib/mail_plugger.rb CHANGED
@@ -7,6 +7,10 @@ require 'mail_plugger/delivery_method'
7
7
  require 'mail_plugger/railtie' if defined?(Rails)
8
8
  require 'mail_plugger/version'
9
9
 
10
+ require 'fake_plugger/delivery_method'
11
+ # If we are using this gem outside of Rails then do not load this code.
12
+ require 'fake_plugger/railtie' if defined?(Rails)
13
+
10
14
  module MailPlugger
11
15
  class << self
12
16
  attr_reader :client, :delivery_options, :delivery_settings
@@ -17,7 +21,7 @@ module MailPlugger
17
21
  #
18
22
  # @example using Rails `config/initializers/mail_plugger.rb`
19
23
  #
20
- # # The defined API class should have an 'initializer' and a 'deliver'
24
+ # # The defined API class should have an 'initialize' and a 'deliver'
21
25
  # # method.
22
26
  # class DefinedApiClientClass
23
27
  # def initialize(options = {})
@@ -90,6 +94,10 @@ module MailPlugger
90
94
 
91
95
  private
92
96
 
97
+ # Check 'delivery_system' is valid or not. If it's not valid then
98
+ # it will raise an error.
99
+ #
100
+ # @param [String/Symbol] delivery_system the name of the API
93
101
  def check_value(delivery_system)
94
102
  if delivery_system.nil?
95
103
  raise Error::WrongDeliverySystem, '"delivery_system" is nil'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MailPlugger
4
- VERSION = '1.0.0'
4
+ VERSION = '1.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail_plugger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Norbert Szivós
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-14 00:00:00.000000000 Z
11
+ date: 2021-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -30,61 +30,30 @@ email:
30
30
  - sysqa@yahoo.com
31
31
  executables: []
32
32
  extensions: []
33
- extra_rdoc_files: []
33
+ extra_rdoc_files:
34
+ - LICENSE.txt
35
+ - README.md
34
36
  files:
35
- - ".github/ISSUE_TEMPLATE/bug_report.md"
36
- - ".github/ISSUE_TEMPLATE/feature_request.md"
37
- - ".gitignore"
38
- - ".rspec"
39
- - ".rubocop.yml"
40
- - ".travis.yml"
41
- - Appraisals
42
37
  - CHANGELOG.md
43
- - CODE_OF_CONDUCT.md
44
- - CONTRIBUTING.md
45
- - Gemfile
46
- - Gemfile.lock
47
38
  - LICENSE.txt
48
39
  - README.md
49
- - Rakefile
50
- - bin/console
51
- - bin/setup
52
- - docs/usage_in_ruby_on_rails.md
53
- - docs/usage_in_script_or_console.md
54
- - docs/usage_of_attachments_in_ruby_on_rails.md
55
- - docs/usage_of_aws_ses_in_ruby_on_rails.md
56
- - docs/usage_of_delivery_method.md
57
- - docs/usage_of_mailgun_in_ruby_on_rails.md
58
- - docs/usage_of_mandrill_in_ruby_on_rails.md
59
- - docs/usage_of_more_delivery_system_in_ruby_on_rails.md
60
- - docs/usage_of_one_delivery_system_with_more_send_methods_in_ruby_on_rails.md
61
- - docs/usage_of_plug_in_method.md
62
- - docs/usage_of_postmark_in_ruby_on_rails.md
63
- - docs/usage_of_secial_options_in_ruby_on_rails.md
64
- - docs/usage_of_sendgrid_in_ruby_on_rails.md
65
- - docs/usage_of_sparkpost_in_ruby_on_rails.md
66
- - gemfiles/.bundle/config
67
- - gemfiles/mail_2.6.gemfile
68
- - gemfiles/mail_2.6.gemfile.lock
69
- - gemfiles/mail_2.7.0.gemfile
70
- - gemfiles/mail_2.7.0.gemfile.lock
71
- - gemfiles/mail_2.7.gemfile
72
- - gemfiles/mail_2.7.gemfile.lock
73
- - images/mail_plugger.png
40
+ - lib/fake_plugger/delivery_method.rb
41
+ - lib/fake_plugger/railtie.rb
74
42
  - lib/mail_plugger.rb
75
43
  - lib/mail_plugger/delivery_method.rb
76
44
  - lib/mail_plugger/error.rb
77
45
  - lib/mail_plugger/mail_helper.rb
78
46
  - lib/mail_plugger/railtie.rb
79
47
  - lib/mail_plugger/version.rb
80
- - mail_plugger.gemspec
81
- homepage: https://github.com/norbertszivos/mail_plugger
48
+ homepage: https://github.com/MailToolbox/mail_plugger
82
49
  licenses:
83
50
  - MIT
84
51
  metadata:
85
- homepage_uri: https://github.com/norbertszivos/mail_plugger
86
- source_code_uri: https://github.com/norbertszivos/mail_plugger
87
- changelog_uri: https://github.com/norbertszivos/mail_plugger/blob/main/CHANGELOG.md
52
+ homepage_uri: https://github.com/MailToolbox/mail_plugger
53
+ source_code_uri: https://github.com/MailToolbox/mail_plugger
54
+ changelog_uri: https://github.com/MailToolbox/mail_plugger/blob/main/CHANGELOG.md
55
+ bug_tracker_uri: https://github.com/MailToolbox/mail_plugger/issues
56
+ documentation_uri: https://rubydoc.info/gems/mail_plugger
88
57
  post_install_message:
89
58
  rdoc_options: []
90
59
  require_paths:
@@ -103,5 +72,5 @@ requirements: []
103
72
  rubygems_version: 3.1.4
104
73
  signing_key:
105
74
  specification_version: 4
106
- summary: Plug in the required mailer API(s) with MailPlugger.
75
+ summary: Plug in required mailer API(s) with MailPlugger.
107
76
  test_files: []