trumail 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.fasterer.yml +19 -0
- data/.gitignore +9 -0
- data/.reek +11 -0
- data/.rspec +4 -0
- data/.rubocop.yml +22 -0
- data/.travis.yml +13 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +6 -0
- data/README.md +61 -0
- data/Rakefile +5 -0
- data/bin/console +15 -0
- data/bin/rake +15 -0
- data/bin/setup +7 -0
- data/lib/trumail.rb +9 -0
- data/lib/trumail/lookup.rb +89 -0
- data/lib/trumail/parser/base.rb +22 -0
- data/lib/trumail/parser/json.rb +15 -0
- data/lib/trumail/parser/xml.rb +18 -0
- data/lib/trumail/version.rb +5 -0
- data/trumail.gemspec +34 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0631d4de271739d362116211ab446ded8e028778
|
4
|
+
data.tar.gz: e6c3150436088ecd0fc0ab87d9e67e00c0f76786
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 48ec8563ad32b90290667d5d0d8d4eb4d45c47279992660031307290a69531e84457082c241f2246b6c066ac28fe6973a3aa0baeeb843380e2d79948ac1cb8aa
|
7
|
+
data.tar.gz: dd3425f52b77181df757de81302bf2ecf225c6c89c2d7ed4f053f5495b10e173e81e51a91023c68fd1c75265b54bf92d20cd7e9759f0726010bb5e19749ad04f
|
data/.fasterer.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
speedups:
|
2
|
+
rescue_vs_respond_to: true
|
3
|
+
module_eval: true
|
4
|
+
shuffle_first_vs_sample: true
|
5
|
+
for_loop_vs_each: true
|
6
|
+
each_with_index_vs_while: false
|
7
|
+
map_flatten_vs_flat_map: true
|
8
|
+
reverse_each_vs_reverse_each: true
|
9
|
+
select_first_vs_detect: true
|
10
|
+
sort_vs_sort_by: true
|
11
|
+
fetch_with_argument_vs_block: true
|
12
|
+
keys_each_vs_each_key: true
|
13
|
+
hash_merge_bang_vs_hash_brackets: true
|
14
|
+
block_vs_symbol_to_proc: true
|
15
|
+
proc_call_vs_yield: true
|
16
|
+
gsub_vs_tr: true
|
17
|
+
select_last_vs_reverse_detect: true
|
18
|
+
getter_vs_attr_reader: true
|
19
|
+
setter_vs_attr_writer: true
|
data/.gitignore
ADDED
data/.reek
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
DisplayStyleGuide: true
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
Exclude:
|
6
|
+
- 'spec/**/**/*'
|
7
|
+
Gemspec/OrderedDependencies:
|
8
|
+
Enabled: false
|
9
|
+
Layout/EmptyLinesAroundClassBody:
|
10
|
+
Enabled: false
|
11
|
+
Layout/EmptyLinesAroundModuleBody:
|
12
|
+
Enabled: false
|
13
|
+
LineLength:
|
14
|
+
Max: 100
|
15
|
+
Lint/ScriptPermission:
|
16
|
+
Enabled: false
|
17
|
+
Security/Eval:
|
18
|
+
Enabled: false
|
19
|
+
Style/Documentation:
|
20
|
+
Enabled: false
|
21
|
+
Style/RescueModifier:
|
22
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Trumail
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/trumail.svg)](http://badge.fury.io/rb/trumail)
|
4
|
+
[![Build Status](https://travis-ci.org/drexed/trumail.svg?branch=master)](https://travis-ci.org/drexed/trumail)
|
5
|
+
|
6
|
+
API wrapper for the free and open source [Trumail](https://trumail.io) email validation/verification system.
|
7
|
+
You can also self-host the system on your own server. Find out more here: [https://github.com/sdwolfe32/trumail](https://github.com/sdwolfe32/trumail)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'trumail'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install trumail
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
```ruby
|
27
|
+
# Basic Lookup
|
28
|
+
lookup = Trumail::Lookup.new('test@email.com').verify
|
29
|
+
lookup = Trumail::Lookup.verify('test@email.com')
|
30
|
+
|
31
|
+
# Custom Host
|
32
|
+
lookup = Trumail::Lookup.new('test@email.com', host: 'https://verifier.com').verify
|
33
|
+
lookup = Trumail::Lookup.verify('test@email.com', host: 'https://verifier.com')
|
34
|
+
|
35
|
+
# Custom Format
|
36
|
+
lookup = Trumail::Lookup.new('test@email.com', format: :xml).verify
|
37
|
+
lookup = Trumail::Lookup.verify('test@email.com', format: :xml)
|
38
|
+
|
39
|
+
# Public Methods
|
40
|
+
lookup.url => 'https://trumail.io/json/test@email.com'
|
41
|
+
lookup.to_h => { 'address' => 'test@email.com', 'catchAll' => true, ... }
|
42
|
+
lookup.address => 'test@email.com'
|
43
|
+
lookup.username => 'test'
|
44
|
+
lookup.domain => 'email.com'
|
45
|
+
lookup.catch_all? => true
|
46
|
+
lookup.deliverable? => false
|
47
|
+
lookup.disposable? => true
|
48
|
+
lookup.full_inbox? => false
|
49
|
+
lookup.gravatar? => true
|
50
|
+
lookup.host_exists? => false
|
51
|
+
```
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Your contribution is welcome.
|
56
|
+
|
57
|
+
1. Fork it
|
58
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
59
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
60
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'trumail'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require 'pry'
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start
|
data/bin/rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'rake' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'bundler/setup'
|
14
|
+
|
15
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/setup
ADDED
data/lib/trumail.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'typhoeus'
|
4
|
+
|
5
|
+
module Trumail
|
6
|
+
class Lookup
|
7
|
+
|
8
|
+
DEFAULT_HOST ||= 'https://trumail.io'
|
9
|
+
DEFAULT_FORMAT ||= :json
|
10
|
+
|
11
|
+
attr_reader :email, :host, :format, :response, :hash
|
12
|
+
|
13
|
+
def initialize(email, host: DEFAULT_HOST, format: DEFAULT_FORMAT)
|
14
|
+
@email = email
|
15
|
+
@host = host
|
16
|
+
@format = format.to_sym
|
17
|
+
@response = nil
|
18
|
+
@hash = {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.verify(email, host: DEFAULT_HOST, format: DEFAULT_FORMAT)
|
22
|
+
klass = new(email, host: host, format: format)
|
23
|
+
klass.verify
|
24
|
+
klass
|
25
|
+
end
|
26
|
+
|
27
|
+
def verify
|
28
|
+
return @hash unless @response.nil?
|
29
|
+
@response = Typhoeus.get(url).response_body
|
30
|
+
@hash = parse_by_format
|
31
|
+
end
|
32
|
+
|
33
|
+
def url
|
34
|
+
"#{@host}/#{@format}/#{@email}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_h
|
38
|
+
@hash
|
39
|
+
end
|
40
|
+
|
41
|
+
def address
|
42
|
+
@hash['address']
|
43
|
+
end
|
44
|
+
|
45
|
+
def catch_all?
|
46
|
+
@hash['catchAll']
|
47
|
+
end
|
48
|
+
|
49
|
+
def deliverable?
|
50
|
+
@hash['deliverable']
|
51
|
+
end
|
52
|
+
|
53
|
+
def disposable?
|
54
|
+
@hash['disposable']
|
55
|
+
end
|
56
|
+
|
57
|
+
def domain
|
58
|
+
@hash['domain']
|
59
|
+
end
|
60
|
+
|
61
|
+
def full_inbox?
|
62
|
+
@hash['fullInbox']
|
63
|
+
end
|
64
|
+
|
65
|
+
def gravatar?
|
66
|
+
@hash['gravatar']
|
67
|
+
end
|
68
|
+
|
69
|
+
def host_exists?
|
70
|
+
@hash['hostExists']
|
71
|
+
end
|
72
|
+
|
73
|
+
def username
|
74
|
+
@hash['username']
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def parse_by_format
|
80
|
+
return @hash if @response.nil?
|
81
|
+
|
82
|
+
case @format
|
83
|
+
when :json then Trumail::Parser::Json.parse(@response)
|
84
|
+
when :xml then Trumail::Parser::Xml.parse(@response)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Trumail
|
4
|
+
module Parser
|
5
|
+
class Base
|
6
|
+
|
7
|
+
attr_reader :hash
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@data = data
|
11
|
+
@hash = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.parse(data)
|
15
|
+
klass = new(data)
|
16
|
+
klass.parse
|
17
|
+
klass.hash
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ox'
|
4
|
+
|
5
|
+
module Trumail
|
6
|
+
module Parser
|
7
|
+
class Xml < Trumail::Parser::Base
|
8
|
+
|
9
|
+
def parse
|
10
|
+
@hash = Ox.parse(@data).nodes.each_with_object({}) do |xml, memo|
|
11
|
+
value = xml.nodes.first
|
12
|
+
memo[xml.value] = eval(value) rescue value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/trumail.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# coding: utf-8
|
4
|
+
|
5
|
+
lib = File.expand_path('../lib', __FILE__)
|
6
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
7
|
+
require 'trumail/version'
|
8
|
+
|
9
|
+
Gem::Specification.new do |spec|
|
10
|
+
spec.name = 'trumail'
|
11
|
+
spec.version = Trumail::VERSION
|
12
|
+
spec.authors = ['Juan Gomez']
|
13
|
+
spec.email = ['j.gomez@drexed.com']
|
14
|
+
|
15
|
+
spec.summary = 'Trumail Ruby SDK.'
|
16
|
+
spec.description = 'Trumail Ruby SDK for interacting with the Trumail API.'
|
17
|
+
spec.homepage = 'http://drexed.github.io/trumail'
|
18
|
+
spec.license = 'MIT'
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = %w[lib support]
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'ox'
|
26
|
+
spec.add_runtime_dependency 'typhoeus'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler'
|
29
|
+
spec.add_development_dependency 'rake'
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
|
+
spec.add_development_dependency 'fasterer'
|
32
|
+
spec.add_development_dependency 'reek'
|
33
|
+
spec.add_development_dependency 'rubocop'
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trumail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juan Gomez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ox
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: typhoeus
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fasterer
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: reek
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Trumail Ruby SDK for interacting with the Trumail API.
|
126
|
+
email:
|
127
|
+
- j.gomez@drexed.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".fasterer.yml"
|
133
|
+
- ".gitignore"
|
134
|
+
- ".reek"
|
135
|
+
- ".rspec"
|
136
|
+
- ".rubocop.yml"
|
137
|
+
- ".travis.yml"
|
138
|
+
- CODE_OF_CONDUCT.md
|
139
|
+
- Gemfile
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- bin/console
|
143
|
+
- bin/rake
|
144
|
+
- bin/setup
|
145
|
+
- lib/trumail.rb
|
146
|
+
- lib/trumail/lookup.rb
|
147
|
+
- lib/trumail/parser/base.rb
|
148
|
+
- lib/trumail/parser/json.rb
|
149
|
+
- lib/trumail/parser/xml.rb
|
150
|
+
- lib/trumail/version.rb
|
151
|
+
- trumail.gemspec
|
152
|
+
homepage: http://drexed.github.io/trumail
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata: {}
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
- support
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 2.6.14
|
174
|
+
signing_key:
|
175
|
+
specification_version: 4
|
176
|
+
summary: Trumail Ruby SDK.
|
177
|
+
test_files: []
|