mailgat 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.example +1 -0
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +8 -0
- data/lib/mailgat.rb +56 -0
- data/lib/mailgat/email.rb +34 -0
- data/lib/mailgat/resource.rb +11 -0
- data/lib/mailgat/version.rb +3 -0
- data/mailgat.gemspec +32 -0
- data/spec/cassettes/r_spec/example_groups/mailgat_email/suggestion/given_invalid_addresses.yml +54 -0
- data/spec/cassettes/r_spec/example_groups/mailgat_email/suggestion/given_valid_addresses.yml +54 -0
- data/spec/cassettes/r_spec/example_groups/mailgat_email/valid/invalid_emails.yml +54 -0
- data/spec/cassettes/r_spec/example_groups/mailgat_email/valids.yml +54 -0
- data/spec/integration/email_spec.rb +45 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/support/client_helper.rb +9 -0
- data/spec/support/vcr_helper.rb +25 -0
- metadata +213 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b142c3d49de1d9991225697606919deaf42ee549
|
4
|
+
data.tar.gz: 73f38981d7f131cdd789305e037d979d4ea1a3d5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a3b7c0ccd51c6d483d2b293ae9676e439227b894b4848c9acdce26b4388c068d5c610ebef0ecbd2a0cc227baff09c1ee7d3b0952badaa8d94f75ce0d45c09cbd
|
7
|
+
data.tar.gz: a00efeedeefbea8073f54bcc9ea7e507d658533f4b4705591d8674821601b8d8be4fe90e24c82a0b922171ba3c1a4b5a9e4e86bbb7c7050f758ae7c4e75561a2
|
data/.env.example
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
MAILGUN_API_KEY=XYZ
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
.env
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
mkmf.log
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 James Phillips
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
[ ![Codeship Status for mailgunner](https://www.codeship.io/projects/608a58b0-4169-0132-8b16-3ae7a01b01d4/status?branch=master)](https://www.codeship.io/projects/44160) [![Coverage Status](https://coveralls.io/repos/jamesdphillips/mailgat/badge.png?branch=master)](https://coveralls.io/r/jamesdphillips/mailgat?branch=master)
|
2
|
+
|
3
|
+
# Mailgat
|
4
|
+
|
5
|
+
Client wrapper for Mailgun API
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'mailgat'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Simply configure with your API key:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
# config/initializers/mailgun.rb
|
23
|
+
|
24
|
+
Mailgat.configure do |config|
|
25
|
+
config.api_key = "XYZ"
|
26
|
+
config.public_key = "ABC" # optional
|
27
|
+
config.adapter = :typoeus # optional; will default to your Faraday default adapter
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
The client will also try to use `ENV["MAILGUN_API_KEY"]` by default.
|
32
|
+
|
33
|
+
### Email Validation
|
34
|
+
|
35
|
+
Wraps validation endpoint. Example usage:
|
36
|
+
|
37
|
+
```
|
38
|
+
email = Mailgunner::Email.new("jason@;gmail.com")
|
39
|
+
email.valid? # => false
|
40
|
+
email.suggestion # => "jason@gmail.com"
|
41
|
+
```
|
42
|
+
|
43
|
+
## Testing
|
44
|
+
|
45
|
+
To run the tests:
|
46
|
+
|
47
|
+
```shell
|
48
|
+
$ rake spec
|
49
|
+
```
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Pull Requests more than welcome!
|
54
|
+
|
55
|
+
1. Fork it ( https://github.com/jamesdphillips/mailgunner/fork )
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/mailgat.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "faraday_middleware"
|
3
|
+
require "hashie/mash"
|
4
|
+
|
5
|
+
require "mailgat/resource"
|
6
|
+
require "mailgat/email"
|
7
|
+
require "mailgat/version"
|
8
|
+
|
9
|
+
module Mailgat
|
10
|
+
class << self
|
11
|
+
attr_writer :client
|
12
|
+
attr_reader :configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
# Configure client
|
16
|
+
#
|
17
|
+
# @yield [configuration] configuration object to defining client paramters
|
18
|
+
# @example
|
19
|
+
# Mailgat.configure do |config|
|
20
|
+
# config.api_key = "XYZ"
|
21
|
+
# config.adapter = :typhoeus
|
22
|
+
# end
|
23
|
+
def self.configure(&block)
|
24
|
+
@configuration ||= Configuration.new
|
25
|
+
yield(@configuration) if block_given?
|
26
|
+
|
27
|
+
self.client = Faraday.new(@configuration.api_base) do |connection|
|
28
|
+
connection.basic_auth "api", @configuration.api_key
|
29
|
+
connection.request :url_encoded
|
30
|
+
connection.response :logger
|
31
|
+
connection.response :mashify
|
32
|
+
connection.response :json, content_type: /\bjson$/
|
33
|
+
connection.adapter @configuration.adapter
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.client
|
38
|
+
@client || configure
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.client_auth_header
|
42
|
+
{ "Authorization" =>
|
43
|
+
"Basic #{ Base64.encode64(["api", configuration.public_key].join(":")).gsub!("\n", "") }" }
|
44
|
+
end
|
45
|
+
|
46
|
+
class Configuration
|
47
|
+
attr_accessor :api_base, :api_key, :public_key, :adapter
|
48
|
+
|
49
|
+
def initialize
|
50
|
+
@api_base = "https://api.mailgun.net/v2"
|
51
|
+
@api_key = ENV["MAILGUN_API_KEY"]
|
52
|
+
@public_key = ENV["MAILGUN_PUBLIC_KEY"]
|
53
|
+
@adapter = Faraday.default_adapter
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Mailgat
|
2
|
+
class Email < Resource
|
3
|
+
|
4
|
+
# @param email [String] address
|
5
|
+
def initialize(email)
|
6
|
+
@email = email
|
7
|
+
super()
|
8
|
+
end
|
9
|
+
|
10
|
+
# Determine whether or not the address appears valid
|
11
|
+
#
|
12
|
+
# @see http://documentation.mailgun.com/api-email-validation.html#email-validation
|
13
|
+
# @return [Boolean]
|
14
|
+
def valid?
|
15
|
+
response = validate
|
16
|
+
!!response.is_valid
|
17
|
+
end
|
18
|
+
|
19
|
+
# If invalid w/ suspected typo, returns suggestion
|
20
|
+
#
|
21
|
+
# @see http://documentation.mailgun.com/api-email-validation.html#email-validation
|
22
|
+
# @return [String]
|
23
|
+
def suggestion
|
24
|
+
response = validate
|
25
|
+
response.did_you_mean
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def validate
|
31
|
+
@validation ||= get("address/validate", {address: @email}, Mailgat.client_auth_header).body
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/mailgat.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mailgat/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mailgat"
|
8
|
+
spec.version = Mailgat::VERSION
|
9
|
+
spec.authors = ["James Phillips"]
|
10
|
+
spec.email = ["jamesdphillips@gmail.com"]
|
11
|
+
spec.summary = %q{Client wrapper for Mailgun API}
|
12
|
+
spec.description = %q{Simple client wrapper for Mailgun API using Faraday client}
|
13
|
+
spec.homepage = "https://www.jphillips.ca"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "activesupport", "~> 4.0"
|
22
|
+
spec.add_dependency "faraday", "~> 0.9"
|
23
|
+
spec.add_dependency "faraday_middleware", "~> 0.9"
|
24
|
+
spec.add_dependency "hashie", "~> 3.0"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
27
|
+
spec.add_development_dependency "coveralls", "~> 0.7"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
30
|
+
spec.add_development_dependency "vcr", "~> 2.9"
|
31
|
+
spec.add_development_dependency "webmock", "~> 1.20"
|
32
|
+
end
|
data/spec/cassettes/r_spec/example_groups/mailgat_email/suggestion/given_invalid_addresses.yml
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api:PUBLICKEY@api.mailgun.net/v2/address/validate?address=jamesdphillips@%3Bgmail.com
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx/1.4.7
|
23
|
+
Date:
|
24
|
+
- Wed, 29 Oct 2014 08:21:36 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Content-Length:
|
28
|
+
- '198'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Access-Control-Max-Age:
|
34
|
+
- '600'
|
35
|
+
Access-Control-Allow-Methods:
|
36
|
+
- GET, POST, PUT, DELETE, OPTIONS
|
37
|
+
Access-Control-Allow-Headers:
|
38
|
+
- Content-Type, x-requested-with
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |-
|
42
|
+
{
|
43
|
+
"address": "jamesdphillips@;gmail.com",
|
44
|
+
"did_you_mean": "jamesdphillips@gmail.com",
|
45
|
+
"is_valid": false,
|
46
|
+
"parts": {
|
47
|
+
"display_name": null,
|
48
|
+
"domain": null,
|
49
|
+
"local_part": null
|
50
|
+
}
|
51
|
+
}
|
52
|
+
http_version:
|
53
|
+
recorded_at: Wed, 29 Oct 2014 08:21:36 GMT
|
54
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api:PUBLICKEY@api.mailgun.net/v2/address/validate?address=james@metalab.co
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx/1.4.7
|
23
|
+
Date:
|
24
|
+
- Wed, 29 Oct 2014 08:21:36 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Content-Length:
|
28
|
+
- '177'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Access-Control-Max-Age:
|
34
|
+
- '600'
|
35
|
+
Access-Control-Allow-Methods:
|
36
|
+
- GET, POST, PUT, DELETE, OPTIONS
|
37
|
+
Access-Control-Allow-Headers:
|
38
|
+
- Content-Type, x-requested-with
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |-
|
42
|
+
{
|
43
|
+
"address": "james@metalab.co",
|
44
|
+
"did_you_mean": null,
|
45
|
+
"is_valid": true,
|
46
|
+
"parts": {
|
47
|
+
"display_name": null,
|
48
|
+
"domain": "metalab.co",
|
49
|
+
"local_part": "james"
|
50
|
+
}
|
51
|
+
}
|
52
|
+
http_version:
|
53
|
+
recorded_at: Wed, 29 Oct 2014 08:21:36 GMT
|
54
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api:PUBLICKEY@api.mailgun.net/v2/address/validate?address=so-horribly%3Bwrong!
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx/1.4.7
|
23
|
+
Date:
|
24
|
+
- Wed, 29 Oct 2014 08:21:36 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Content-Length:
|
28
|
+
- '169'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Access-Control-Max-Age:
|
34
|
+
- '600'
|
35
|
+
Access-Control-Allow-Methods:
|
36
|
+
- GET, POST, PUT, DELETE, OPTIONS
|
37
|
+
Access-Control-Allow-Headers:
|
38
|
+
- Content-Type, x-requested-with
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |-
|
42
|
+
{
|
43
|
+
"address": "so-horribly;wrong!",
|
44
|
+
"did_you_mean": null,
|
45
|
+
"is_valid": false,
|
46
|
+
"parts": {
|
47
|
+
"display_name": null,
|
48
|
+
"domain": null,
|
49
|
+
"local_part": null
|
50
|
+
}
|
51
|
+
}
|
52
|
+
http_version:
|
53
|
+
recorded_at: Wed, 29 Oct 2014 08:21:36 GMT
|
54
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api:PUBLICKEY@api.mailgun.net/v2/address/validate?address=james@metalab.co
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx/1.4.7
|
23
|
+
Date:
|
24
|
+
- Wed, 29 Oct 2014 08:21:35 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Content-Length:
|
28
|
+
- '177'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Access-Control-Max-Age:
|
34
|
+
- '600'
|
35
|
+
Access-Control-Allow-Methods:
|
36
|
+
- GET, POST, PUT, DELETE, OPTIONS
|
37
|
+
Access-Control-Allow-Headers:
|
38
|
+
- Content-Type, x-requested-with
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: |-
|
42
|
+
{
|
43
|
+
"address": "james@metalab.co",
|
44
|
+
"did_you_mean": null,
|
45
|
+
"is_valid": true,
|
46
|
+
"parts": {
|
47
|
+
"display_name": null,
|
48
|
+
"domain": "metalab.co",
|
49
|
+
"local_part": "james"
|
50
|
+
}
|
51
|
+
}
|
52
|
+
http_version:
|
53
|
+
recorded_at: Wed, 29 Oct 2014 08:21:35 GMT
|
54
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "./lib/mailgat"
|
3
|
+
|
4
|
+
RSpec.describe Mailgat::Email, helpers: :vcr do
|
5
|
+
let(:email) { "james@metalab.co" }
|
6
|
+
let(:resource) { Mailgat::Email.new(email) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
configure_client
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#valid?" do
|
13
|
+
subject { resource.valid? }
|
14
|
+
|
15
|
+
it "returns true" do
|
16
|
+
is_expected.to be_truthy
|
17
|
+
end
|
18
|
+
|
19
|
+
context "invalid email" do
|
20
|
+
let(:email) { "so-horribly;wrong!" }
|
21
|
+
|
22
|
+
it "returns false" do
|
23
|
+
is_expected.to be_falsey
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#suggestion" do
|
29
|
+
subject { resource.suggestion }
|
30
|
+
|
31
|
+
context "given valid address" do
|
32
|
+
it "should return nil" do
|
33
|
+
is_expected.to be_nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "given invalid address" do
|
38
|
+
let(:email) { "jamesdphillips@;gmail.com" }
|
39
|
+
|
40
|
+
it "should include a suggestion" do
|
41
|
+
is_expected.to be_a(String)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Code coverage
|
2
|
+
require 'coveralls'
|
3
|
+
Coveralls.wear!
|
4
|
+
|
5
|
+
# Load helpers
|
6
|
+
Dir["./spec/support/**/*.rb"].sort.each { |f| require f}
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.expect_with :rspec do |expectations|
|
10
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
11
|
+
end
|
12
|
+
|
13
|
+
config.mock_with :rspec do |mocks|
|
14
|
+
mocks.verify_partial_doubles = true
|
15
|
+
end
|
16
|
+
|
17
|
+
config.filter_run :focus
|
18
|
+
config.run_all_when_everything_filtered = true
|
19
|
+
config.disable_monkey_patching!
|
20
|
+
config.warnings = true
|
21
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
22
|
+
config.profile_examples = 10
|
23
|
+
config.order = :random
|
24
|
+
Kernel.srand config.seed
|
25
|
+
|
26
|
+
config.include ClientHelper
|
27
|
+
config.include VCRHelper, helpers: :vcr
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "vcr"
|
2
|
+
require "webmock"
|
3
|
+
require "active_support/concern"
|
4
|
+
require "active_support/core_ext/string/inflections"
|
5
|
+
|
6
|
+
module VCRHelper
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
VCR.configure do |config|
|
10
|
+
config.cassette_library_dir = "spec/cassettes"
|
11
|
+
config.hook_into :webmock
|
12
|
+
config.configure_rspec_metadata!
|
13
|
+
config.filter_sensitive_data("APIKEY") { ENV["MAILGUN_KEY"] }
|
14
|
+
config.filter_sensitive_data("PUBLICKEY") { ENV["MAILGUN_PUBLIC_KEY"] }
|
15
|
+
end
|
16
|
+
|
17
|
+
included do
|
18
|
+
around(:each) do |example|
|
19
|
+
cassette_name = defined?(cassette) ? cassette : self.class.name.tableize
|
20
|
+
VCR.use_cassette(cassette_name, record: :new_episodes, match_requests_on: [:path]) do
|
21
|
+
example.run
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mailgat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Phillips
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.9'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday_middleware
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hashie
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.6'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.3'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.1'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.1'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: vcr
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.9'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.9'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: webmock
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1.20'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1.20'
|
153
|
+
description: Simple client wrapper for Mailgun API using Faraday client
|
154
|
+
email:
|
155
|
+
- jamesdphillips@gmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".env.example"
|
161
|
+
- ".gitignore"
|
162
|
+
- ".rspec"
|
163
|
+
- Gemfile
|
164
|
+
- LICENSE.txt
|
165
|
+
- README.md
|
166
|
+
- Rakefile
|
167
|
+
- lib/mailgat.rb
|
168
|
+
- lib/mailgat/email.rb
|
169
|
+
- lib/mailgat/resource.rb
|
170
|
+
- lib/mailgat/version.rb
|
171
|
+
- mailgat.gemspec
|
172
|
+
- spec/cassettes/r_spec/example_groups/mailgat_email/suggestion/given_invalid_addresses.yml
|
173
|
+
- spec/cassettes/r_spec/example_groups/mailgat_email/suggestion/given_valid_addresses.yml
|
174
|
+
- spec/cassettes/r_spec/example_groups/mailgat_email/valid/invalid_emails.yml
|
175
|
+
- spec/cassettes/r_spec/example_groups/mailgat_email/valids.yml
|
176
|
+
- spec/integration/email_spec.rb
|
177
|
+
- spec/spec_helper.rb
|
178
|
+
- spec/support/client_helper.rb
|
179
|
+
- spec/support/vcr_helper.rb
|
180
|
+
homepage: https://www.jphillips.ca
|
181
|
+
licenses:
|
182
|
+
- MIT
|
183
|
+
metadata: {}
|
184
|
+
post_install_message:
|
185
|
+
rdoc_options: []
|
186
|
+
require_paths:
|
187
|
+
- lib
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
requirements: []
|
199
|
+
rubyforge_project:
|
200
|
+
rubygems_version: 2.4.2
|
201
|
+
signing_key:
|
202
|
+
specification_version: 4
|
203
|
+
summary: Client wrapper for Mailgun API
|
204
|
+
test_files:
|
205
|
+
- spec/cassettes/r_spec/example_groups/mailgat_email/suggestion/given_invalid_addresses.yml
|
206
|
+
- spec/cassettes/r_spec/example_groups/mailgat_email/suggestion/given_valid_addresses.yml
|
207
|
+
- spec/cassettes/r_spec/example_groups/mailgat_email/valid/invalid_emails.yml
|
208
|
+
- spec/cassettes/r_spec/example_groups/mailgat_email/valids.yml
|
209
|
+
- spec/integration/email_spec.rb
|
210
|
+
- spec/spec_helper.rb
|
211
|
+
- spec/support/client_helper.rb
|
212
|
+
- spec/support/vcr_helper.rb
|
213
|
+
has_rdoc:
|