ses_blacklist_rails 0.0.1 → 0.0.2
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/README.md +12 -8
- data/lib/generators/ses_blacklist_rails/install_generator.rb +40 -0
- data/lib/generators/templates/ses_blacklist_rails.rb +5 -0
- data/lib/ses_blacklist_rails/action_mail_interceptor.rb +35 -0
- data/lib/ses_blacklist_rails/config.rb +17 -0
- data/lib/ses_blacklist_rails/version.rb +1 -1
- data/lib/ses_blacklist_rails.rb +10 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b306a0d1afa86638a8c1a4e86436bd771ba8d44
|
4
|
+
data.tar.gz: f3e670d796026a02ae1c19c73e3baf9f8461470f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a64869980ddff162b14458009ca2521643eb1883ce473733cdd8c0f08c7ccd6a750f15ff64b480931179ce0ca0c725c916716eaa99483011c764c6dac13a797
|
7
|
+
data.tar.gz: 6e3be1e79938e43eb866be0713f5886c84a62af2eee579f3b7bd1e9be936ba0930dc7d15875e59cbf11f0f83958c4547189f49353be0131e8999e3967d079320
|
data/README.md
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
# SesBlacklistRails
|
2
2
|
Short description and motivation.
|
3
3
|
|
4
|
-
## Usage
|
5
|
-
How to use my plugin.
|
6
|
-
|
7
4
|
## Installation
|
8
|
-
Add this line to your application's Gemfile
|
5
|
+
Add this line to your application's `Gemfile`:
|
9
6
|
|
10
7
|
```ruby
|
11
8
|
gem 'ses_blacklist_rails'
|
@@ -14,15 +11,22 @@ gem 'ses_blacklist_rails'
|
|
14
11
|
And then execute:
|
15
12
|
```bash
|
16
13
|
$ bundle
|
14
|
+
$ bundle exec rails g ses_blacklist_rails:install
|
17
15
|
```
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
## Configuration
|
18
|
+
|
19
|
+
`in config/initializers/ses_blacklist_rails.rb`
|
20
|
+
```ruby
|
21
|
+
SesBlacklistRails.configure do |config|
|
22
|
+
config.send_bounce = false
|
23
|
+
config.send_compliant = false
|
24
|
+
config.default_address = 'some_address@sample.com'
|
25
|
+
end
|
22
26
|
```
|
23
27
|
|
24
28
|
## Contributing
|
25
|
-
|
29
|
+
Please let me know if you found any problems, by creating ISSUE reports or PRs.
|
26
30
|
|
27
31
|
## License
|
28
32
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module SesBlacklistRails
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base # :nodoc:
|
6
|
+
source_root File.expand_path('../../templates', __FILE__)
|
7
|
+
desc 'Creates a SesBlacklistRails initializer and copy locale files to your application.'
|
8
|
+
|
9
|
+
class_option 'with-migrate', type: :boolean
|
10
|
+
|
11
|
+
def start
|
12
|
+
puts 'Start installing SesBlacklistRails...'
|
13
|
+
puts '*' * 80 + "\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
def install_migrations
|
17
|
+
puts 'Copying SesBlacklistRails migrations...'
|
18
|
+
Dir.chdir(Rails.root) do
|
19
|
+
`rake ses_blacklist_rails:install:migrations`
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def run_migrations
|
24
|
+
return unless options['with-migrate']
|
25
|
+
puts 'Running rake db:migrate'
|
26
|
+
`rake db:migrate`
|
27
|
+
end
|
28
|
+
|
29
|
+
def copy_initializer
|
30
|
+
puts 'Copying initializer template...'
|
31
|
+
template 'ses_blacklist_rails.rb', 'config/initializers/ses_blacklist_rails.rb'
|
32
|
+
end
|
33
|
+
|
34
|
+
def finished
|
35
|
+
puts "\n" + ('*' * 80)
|
36
|
+
puts 'Done! SesBlacklistRails has been successfully installed.'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module SesBlacklistRails
|
2
|
+
class ActionMailInterceptor # :nodoc:
|
3
|
+
class << self
|
4
|
+
def delivering_email(message)
|
5
|
+
validate!(message)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def validate!(message)
|
11
|
+
unless SesBlacklistRails.send_bounce
|
12
|
+
validate_bounce = ->(email) { SesBlacklistRails::Notification.bounce.find_by(email: email) }
|
13
|
+
message.to.reject!(validate_bounce)
|
14
|
+
message.cc.reject!(validate_bounce)
|
15
|
+
message.bcc.reject!(validate_bounce)
|
16
|
+
end
|
17
|
+
|
18
|
+
unless SesBlacklistRails.send_compliant
|
19
|
+
validate_bounce = ->(email) { SesBlacklistRails::Notification.compliant.find_by(email: email) }
|
20
|
+
message.to.reject!(validate_bounce)
|
21
|
+
message.cc.reject!(validate_bounce)
|
22
|
+
message.bcc.reject!(validate_bounce)
|
23
|
+
end
|
24
|
+
|
25
|
+
defualt_address!(message) if message.to.blank?
|
26
|
+
message
|
27
|
+
end
|
28
|
+
|
29
|
+
def defualt_address!(message)
|
30
|
+
message.to << SesBlacklistRails::Notification.default_address
|
31
|
+
message
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SesBlacklistRails
|
2
|
+
class Config # :nodoc:
|
3
|
+
include ActiveSupport::Configurable
|
4
|
+
|
5
|
+
config_accessor :send_bounce do
|
6
|
+
false
|
7
|
+
end
|
8
|
+
|
9
|
+
config_accessor :send_compliant do
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
config_accessor :default_address do
|
14
|
+
''
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/ses_blacklist_rails.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require 'ses_blacklist_rails/config'
|
2
|
+
require 'ses_blacklist_rails/engine'
|
2
3
|
|
3
|
-
module SesBlacklistRails
|
4
|
-
|
4
|
+
module SesBlacklistRails # :nodoc:
|
5
|
+
def self.configure(*)
|
6
|
+
yield config
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.config
|
10
|
+
@config ||= SesBlacklistRails::Config.new
|
11
|
+
end
|
5
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ses_blacklist_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mrdShinse
|
@@ -80,7 +80,11 @@ files:
|
|
80
80
|
- app/views/layouts/ses_blacklist_rails/application.html.erb
|
81
81
|
- config/routes.rb
|
82
82
|
- db/migrate/20171116073708_create_ses_blacklist_rails_notifications.rb
|
83
|
+
- lib/generators/ses_blacklist_rails/install_generator.rb
|
84
|
+
- lib/generators/templates/ses_blacklist_rails.rb
|
83
85
|
- lib/ses_blacklist_rails.rb
|
86
|
+
- lib/ses_blacklist_rails/action_mail_interceptor.rb
|
87
|
+
- lib/ses_blacklist_rails/config.rb
|
84
88
|
- lib/ses_blacklist_rails/engine.rb
|
85
89
|
- lib/ses_blacklist_rails/version.rb
|
86
90
|
- lib/tasks/ses_blacklist_rails_tasks.rake
|
@@ -104,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
108
|
version: '0'
|
105
109
|
requirements: []
|
106
110
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.6.11
|
108
112
|
signing_key:
|
109
113
|
specification_version: 4
|
110
114
|
summary: AWS SES blacklist for Rails applications.
|