gman 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -9
- data/README.md +1 -1
- data/gman.gemspec +7 -1
- data/lib/domains.txt +6 -0
- data/lib/gman.rb +4 -2
- data/test/test_gman.rb +29 -2
- metadata +93 -9
- checksums.yaml +0 -7
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@ A ruby gem to check if the owner of a given email address or website is working
|
|
6
6
|
|
7
7
|
You could theoretically [use regex](https://gist.github.com/benbalter/6147066), 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).
|
8
8
|
|
9
|
-
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](https://github.com/benbalter/gman/blob/master/lib/domains.
|
9
|
+
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](https://github.com/benbalter/gman/blob/master/lib/domains.txt). It should cover all US and international, government and military domains for both email and website verification.
|
10
10
|
|
11
11
|
See a domains that's missing or one that shouldn't be there? [We'd love you to contribute](CONTRIBUTING.md).
|
12
12
|
|
data/gman.gemspec
CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
|
|
2
2
|
s.name = "gman"
|
3
3
|
s.summary = "Check if a given domain or email address belong to a governemnt entity"
|
4
4
|
s.description = "A ruby gem to check if the owner of a given email address is working for THE MAN."
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.7"
|
6
6
|
s.authors = ["Ben Balter"]
|
7
7
|
s.email = "ben.balter@github.com"
|
8
8
|
s.homepage = "https://github.com/benbalter/gman"
|
@@ -25,4 +25,10 @@ Gem::Specification.new do |s|
|
|
25
25
|
]
|
26
26
|
s.require_paths = ["lib"]
|
27
27
|
s.add_dependency( "public_suffix" )
|
28
|
+
s.add_dependency( "swot" )
|
29
|
+
|
30
|
+
s.add_development_dependency( "rake" )
|
31
|
+
s.add_development_dependency( "shoulda" )
|
32
|
+
s.add_development_dependency( "rdoc" )
|
33
|
+
s.add_development_dependency( "bundler" )
|
28
34
|
end
|
data/lib/domains.txt
CHANGED
@@ -136,6 +136,7 @@ gov.ve
|
|
136
136
|
gov.vn
|
137
137
|
gov.ws
|
138
138
|
gub.uy
|
139
|
+
ottawa.ca
|
139
140
|
|
140
141
|
//non-US mil
|
141
142
|
mil.ac
|
@@ -193,10 +194,15 @@ bouldercounty.org
|
|
193
194
|
ci.champaign.il.us
|
194
195
|
ci.longmont.co.us
|
195
196
|
sfgov.org
|
197
|
+
sfmta.org
|
198
|
+
sfcta.org
|
199
|
+
smgov.net
|
196
200
|
state.de.us
|
197
201
|
state.or.us
|
198
202
|
borough.kenai.ak.us
|
199
203
|
kcmo.org
|
204
|
+
clevelandmetroparks.com
|
200
205
|
|
201
206
|
// Non US sub-divisions
|
202
207
|
greatersudbury.ca
|
208
|
+
ega.or.th
|
data/lib/gman.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'public_suffix'
|
2
2
|
require 'yaml'
|
3
|
+
require 'swot'
|
3
4
|
|
4
5
|
module Gman
|
5
6
|
|
6
|
-
VERSION='0.0.3'
|
7
|
-
|
8
7
|
class << self
|
9
8
|
|
10
9
|
# Normalizes and checks if a given string represents a governemnt domain
|
@@ -20,6 +19,9 @@ module Gman
|
|
20
19
|
return false if text.nil?
|
21
20
|
domain = get_domain text
|
22
21
|
|
22
|
+
# Ensure non-edu
|
23
|
+
return false if Swot::is_academic?(domain)
|
24
|
+
|
23
25
|
# check using public suffix's standard logic
|
24
26
|
rule = list.find domain
|
25
27
|
return true if !rule.nil? && rule.allow?(domain)
|
data/test/test_gman.rb
CHANGED
@@ -1,15 +1,42 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'swot'
|
2
3
|
|
3
|
-
VALID = ["foo.gov",
|
4
|
-
|
4
|
+
VALID = [ "foo.gov",
|
5
|
+
"http://foo.mil",
|
6
|
+
"foo@bar.gc.ca",
|
7
|
+
"foo.gov.au",
|
8
|
+
"http://www.foo.gouv.fr",
|
9
|
+
"foo@ci.champaign.il.us",
|
10
|
+
"foo.bar.baz.gov.au",
|
11
|
+
"foo@bar.gov.uk"
|
12
|
+
]
|
13
|
+
|
14
|
+
INVALID = [ "foo.bar.com",
|
15
|
+
"bar@foo.biz",
|
16
|
+
"http://www.foo.biz",
|
17
|
+
"foo.uk",
|
18
|
+
"gov",
|
19
|
+
"foo@k12.champaign.il.us",
|
20
|
+
"foo@kii.gov.by"
|
21
|
+
]
|
5
22
|
|
6
23
|
class TestGman < Test::Unit::TestCase
|
24
|
+
|
7
25
|
should "recognize government email addresses and domains" do
|
8
26
|
VALID.each do |test|
|
9
27
|
assert_equal true, Gman::valid?(test), "#{test} should be detected as a valid government domain"
|
10
28
|
end
|
29
|
+
end
|
30
|
+
|
31
|
+
should "not recognize non-government email addresses and domains" do
|
11
32
|
INVALID.each do |test|
|
12
33
|
assert_equal false, Gman::valid?(test), "#{test} should be detected as an invalid government domain"
|
13
34
|
end
|
14
35
|
end
|
36
|
+
|
37
|
+
should "not contain any educational domains" do
|
38
|
+
Gman.list.each do |entry|
|
39
|
+
assert_equal false, Swot::is_academic?(entry.name), "#{entry.name} is an academic domain"
|
40
|
+
end
|
41
|
+
end
|
15
42
|
end
|
metadata
CHANGED
@@ -1,27 +1,110 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Ben Balter
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-11-25 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: public_suffix
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: swot
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: shoulda
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rdoc
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: bundler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
25
108
|
- !ruby/object:Gem::Version
|
26
109
|
version: '0'
|
27
110
|
description: A ruby gem to check if the owner of a given email address is working
|
@@ -47,25 +130,26 @@ files:
|
|
47
130
|
homepage: https://github.com/benbalter/gman
|
48
131
|
licenses:
|
49
132
|
- MIT
|
50
|
-
metadata: {}
|
51
133
|
post_install_message:
|
52
134
|
rdoc_options: []
|
53
135
|
require_paths:
|
54
136
|
- lib
|
55
137
|
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
56
139
|
requirements:
|
57
|
-
- - '>='
|
140
|
+
- - ! '>='
|
58
141
|
- !ruby/object:Gem::Version
|
59
142
|
version: '0'
|
60
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
61
145
|
requirements:
|
62
|
-
- - '>='
|
146
|
+
- - ! '>='
|
63
147
|
- !ruby/object:Gem::Version
|
64
148
|
version: '0'
|
65
149
|
requirements: []
|
66
150
|
rubyforge_project:
|
67
|
-
rubygems_version:
|
151
|
+
rubygems_version: 1.8.23
|
68
152
|
signing_key:
|
69
|
-
specification_version:
|
153
|
+
specification_version: 3
|
70
154
|
summary: Check if a given domain or email address belong to a governemnt entity
|
71
155
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: a52506ac373d14b8d623fc9811a217a260529e73
|
4
|
-
data.tar.gz: 69f9252bb61fae8d90eef34b598ac572b2553b03
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 2cf3eb4c913957387a50403d566101e89328330dbc01cf39c38c3a869ed91c25a153f0eff81dba7bf8e34f1a3048b03b451df4f14401e83df717b4b07cc658d7
|
7
|
-
data.tar.gz: 0067d03484926f13cb78b32b83dba2e1ec41a8434417fd14ba236c0d3d28e3891cc30305f7f8ab06ffd6554e2d7e1194177923b8718d40edd0f0d5dcd315740f
|