Skip to content
/ gman Public
forked from benbalter/gman

A ruby gem to check if the owner of a given email address or website is working for THE MAN (a.k.a verifies government domains).

License

Notifications You must be signed in to change notification settings

jlord/gman

 
 

Repository files navigation

Gman Gem

Build Status Gem Version

A ruby gem to check if the owner of a given email address or website is working for THE MAN (a.k.a verifies government domains). It does this by leveraging the power of the Public Suffix List, and the associated Ruby Gem.

You could theoretically use regex, but either you'll a bunch of false positives, or your regex will be insanely complicated. gov.uk, may be valid, for example, but gov.fr is not (it's gouv.fr, for what it's worth).

The solution? Use Public Suffix to verify that it's a valid public domain, then maintain a crowd-sourced sub-list of known global government and military domains. It should cover all US and international, government and military domains for both email and website verification.

See a domains that's missing or one that shouldn't be there? We'd love you to contribute.

Installation

Gman is a Ruby gem, so you'll need a little Ruby-fu to get it working. Simply

gem install gman

Or add this to your Gemfile before doing a bundle install:

gem 'gman'

Usage

Verify email addresses

Gman.valid? "foo@bar.gov" #true
Gman.valid? "foo@bar.com" #false

Really verify an email address

(also verifies that the server returns a valid MX record)

Gman.valid? "foo@whitehouse.gov", true #true
Gman.valid? "foo@bar.gov", true #false

Verify domain

Gman.valid? "http://foo.bar.gov" #true
Gman.valid? "foo.bar.gov" #true
Gman.valid? "foo.gov" #true
Gman.valid? "foo.biz" #false

Get a domain name from an arbitrary domainy string

Gman.get_domain "http://foo.bar.gov" # foo.bar.gov
Gman.get_domain "foo@bar.gov" # bar.gov
Gman.get_domain "foo.bar.gov" # foo.bar.gov
Gman.get_domain "asdf@asdf" # nil (no domain within the string)
Gman.get_domain "foo@bar.gov", true #false (no MX record)
Gman.get_domain "foo@whitehouse.gov", true # true (valid MX record)

Contributing

Contributions welcome! Please see the contribution guidelines for code contributions or for details on how to add, update, or delete government domains.

Credits

Heavily inspired by swot. Thanks @leereily!

About

A ruby gem to check if the owner of a given email address or website is working for THE MAN (a.k.a verifies government domains).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 92.3%
  • Shell 7.7%