mailgun_email_validator 0.0.3 → 0.1.1

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: 3ef7cdeed61f1d573edd23ed593a1038cc30cf64
4
- data.tar.gz: 5f369e649468974fac841400f0bd9d3cc864a55a
3
+ metadata.gz: 06c8b8755370a7fece874003d16c53b4e3566f7d
4
+ data.tar.gz: 5189b916fe30c726a23f8e34db52a4b2cfd4b129
5
5
  SHA512:
6
- metadata.gz: 8859637da0c5a96cdccac53544b80d8317c9c223989664cf98c29d930a94f14fb344b463dd14ddc3741da0af9a13adc8e2b3b9b6d4264c527b918b70bbb0de82
7
- data.tar.gz: a1efadc4bb95cdac69eee9feccd760cd01c3ccc00beda38cb3532295e4d770e20ec0a01657e0bb166188217d3fe93bc5f8a7f43085ab328b8e36970d633ab92d
6
+ metadata.gz: 787d5cd9c28252da82282eb914e5667c1e619b6cc1394553d2d04277b1e88c4469c63333d48849ee170e6aa365490885456aa10c10430e9d550331d0f4eaf332
7
+ data.tar.gz: 48395969f9b6e32103d20a81adce56d6d022a5507b48c2ee225f044c9970dda6040940bb694159031b64063f11f5eb4628ef5274098f82a0e12c6377db2321db
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # mailgun_email_validator
2
2
 
3
- This gem adds a ``validates_as_email_with_mailgun`` method to ActiveRecord. It first tries to verify an e-mail using the amazing Mailgun e-mail validation API and then falls back to using the [spectator_validates_email](https://github.com/spectator/validates_email) gem if it can't connect.
3
+ This gem adds a `validates_as_email_with_mailgun` method to ActiveRecord. It first tries to verify an e-mail using the amazing Mailgun e-mail validation API and then falls back to using the [spectator_validates_email](https://github.com/spectator/validates_email) gem if it can't connect.
4
4
 
5
5
  ## Usage
6
6
 
@@ -8,15 +8,15 @@ Add the gem to your Rails project's Gemfile, then bundle install to get started.
8
8
 
9
9
  `gem 'mailgun_email_validator'`
10
10
 
11
- You'll need to add a ``MAILGUN_PUBLIC_KEY`` environmental variable to your system, for instance in your ``~/.bash_profile``:
11
+ You'll need to add a `MAILGUN_PUBLIC_KEY` environmental variable to your system, for instance in your `~/.bash_profile`:
12
12
 
13
- ``export MAILGUN_PUBLIC_KEY='f23oifj3ojo2j3ofj32ijoj2iojf3iojoi2f32'``
13
+ `export MAILGUN_PUBLIC_KEY='f23oifj3ojo2j3ofj32ijoj2iojf3iojoi2f32'`
14
14
 
15
15
  Alternatively, you can configure mailgun with an initializer:
16
16
 
17
- In ``config/initializers/mailgun_email_validator.rb``:
17
+ In `config/initializers/mailgun_email_validator.rb`:
18
18
 
19
- ``MailgunEmailValidator::MAILGUN_PUBLIC_KEY = 'f23oifj3ojo2j3ofj32ijoj2iojf3iojoi2f32'``
19
+ `MailgunEmailValidator.mailgun_public_key = 'f23oifj3ojo2j3ofj32ijoj2iojf3iojoi2f32'`
20
20
 
21
21
  *Note: This is not a real Mailgun public key*
22
22
 
@@ -25,12 +25,13 @@ To use mailgun_email_validator inside your models:
25
25
 
26
26
  `validates_as_email_with_mailgun :email`
27
27
 
28
- You can also specify many of the usual ActiveRecord validation options including ``:on``, ``:allow_nil``, ``:allow_blank``, and ``:message``.
28
+ You can also specify many of the usual ActiveRecord validation options including `:on`, `:allow_nil`, `:allow_blank`, and `:message`.
29
29
 
30
30
 
31
31
  There is also a helper method available on all models:
32
32
 
33
- ``MyModel#valid_email_with_mailgun?(email) => true/false``
33
+ `MyModel#valid_email_with_mailgun?(email) => true/false`
34
+
34
35
  ## Contributing to mailgun_email_validator
35
36
 
36
37
  Pull requests welcome.
@@ -1,9 +1,10 @@
1
+ require 'active_support/core_ext/module/attribute_accessors'
1
2
  require 'rest_client'
2
3
 
3
4
  module MailgunEmailValidator
4
- DEFAULT_VALIDATION_OPTIONS = {:on => :save, :allow_nil => false, :allow_blank => false, :message => nil}
5
+ mattr_writer :mailgun_public_key, instance_writer: false
5
6
 
6
- MAILGUN_PUBLIC_KEY = nil
7
+ DEFAULT_VALIDATION_OPTIONS = {:on => :save, :allow_nil => false, :allow_blank => false, :message => nil}
7
8
 
8
9
  def valid_email_with_mailgun?(email)
9
10
  !! parsed_validation_response!(email)["is_valid"]
@@ -45,7 +46,8 @@ module MailgunEmailValidator
45
46
  res = RestClient.get "https://api:#{mailgun_public_key}@api.mailgun.net/v2/address/validate", {params: {address: email}}
46
47
  JSON.parse(res)
47
48
  end
49
+
48
50
  def mailgun_public_key
49
- MAILGUN_PUBLIC_KEY || ENV['MAILGUN_PUBLIC_KEY'] || raise("You need to supply your mailgun public api key")
51
+ @@mailgun_public_key || ENV['MAILGUN_PUBLIC_KEY'] || raise("You need to supply your mailgun public api key")
50
52
  end
51
53
  end
@@ -1,3 +1,3 @@
1
1
  module MailgunEmailValidator
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailgun_email_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Feldman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails