spam_email 0.0.42 → 0.0.44

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,12 @@
1
+ require 'mail'
2
+
3
+ module SpamEmail
4
+ def self.blacklisted? email_address
5
+ address = Mail::Address.new(email_address)
6
+ return false unless address.domain
7
+
8
+ BLACKLIST.include?(address.domain.downcase)
9
+ rescue Mail::Field::ParseError
10
+ false
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module SpamEmail
2
- VERSION = '0.0.42'
2
+ VERSION = '0.0.44'
3
3
  end
data/lib/spam_email.rb CHANGED
@@ -1,24 +1,16 @@
1
1
  require "spam_email/version"
2
2
  require "spam_email/blacklist"
3
+ require 'spam_email/check'
3
4
  require 'active_model'
4
5
  require 'active_model/validations'
5
- require 'mail'
6
6
 
7
7
  I18n.load_path += Dir.glob(File.expand_path('../../config/locales/**/*',__FILE__))
8
8
 
9
9
  class SpamEmailValidator < ActiveModel::EachValidator
10
- def validate_each(record,attribute,value)
11
- begin
12
- m = Mail::Address.new(value)
13
- return if m.domain.nil?
14
- domain = m.domain.downcase
15
-
16
- if SpamEmail::BLACKLIST.include?(domain)
17
- message = (options[:message] || I18n.t(:blacklisted, scope: "spam_email.validations.email"))
18
- record.errors[attribute] << message
19
- end
20
- rescue Mail::Field::ParseError
21
- return
10
+ def validate_each(record, attribute, value)
11
+ if SpamEmail.blacklisted?(value)
12
+ message = (options[:message] || I18n.t(:blacklisted, scope: 'spam_email.validations.email'))
13
+ record.errors[attribute] << message
22
14
  end
23
15
  end
24
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spam_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.42
4
+ version: 0.0.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phillipp Röll
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-06 00:00:00.000000000 Z
11
+ date: 2017-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -84,6 +84,7 @@ files:
84
84
  - config/locales/fr.yml
85
85
  - lib/spam_email.rb
86
86
  - lib/spam_email/blacklist.rb
87
+ - lib/spam_email/check.rb
87
88
  - lib/spam_email/iplist.rb
88
89
  - lib/spam_email/version.rb
89
90
  - spam_email.gemspec