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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be92ed12a82e9954ed61eafef665d848fe13474d
4
- data.tar.gz: 39cae3633e2a92236abe70416dc4aa4194c507b0
3
+ metadata.gz: 7b306a0d1afa86638a8c1a4e86436bd771ba8d44
4
+ data.tar.gz: f3e670d796026a02ae1c19c73e3baf9f8461470f
5
5
  SHA512:
6
- metadata.gz: d8d3b578c9bf7d926d4bec8e817765d55e402b1f03f84f0cf1fd2e3ca55b0f784d40490d562250398116e8ca0418f52d310f0e65b4fd7bb7816424f2d51f1a36
7
- data.tar.gz: 041bdfe65479250c5a7cec09a1cb9319aaa3efe3195895b625084a1a4c2322b066d529012dddffc45fcbffd825ca6ab7d12dda0467cf9653a7de1ecf77c79f2b
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
- Or install it yourself as:
20
- ```bash
21
- $ gem install ses_blacklist_rails
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
- Contribution directions go here.
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,5 @@
1
+ SesBlacklistRails.configure do |config|
2
+ config.send_bounce = false
3
+ config.send_compliant = false
4
+ config.default_address = 'some_address@sample.com'
5
+ 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
@@ -1,3 +1,3 @@
1
1
  module SesBlacklistRails
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
@@ -1,5 +1,12 @@
1
- require "ses_blacklist_rails/engine"
1
+ require 'ses_blacklist_rails/config'
2
+ require 'ses_blacklist_rails/engine'
2
3
 
3
- module SesBlacklistRails
4
- # Your code goes here...
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.1
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.5.1
111
+ rubygems_version: 2.6.11
108
112
  signing_key:
109
113
  specification_version: 4
110
114
  summary: AWS SES blacklist for Rails applications.