gman 4.4.3 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/bin/gman +2 -0
- data/gman.gemspec +1 -1
- data/lib/gman.rb +1 -0
- data/lib/gman/country_codes.rb +2 -1
- data/lib/gman/sanctions.rb +29 -0
- data/test/test_gman_bin.rb +5 -0
- data/test/test_gman_sanctions.rb +20 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a172d1b966cc4024dbedfe36a23bc8b3e6719ed2
|
4
|
+
data.tar.gz: 7149f379f8c5a2db46f2f7835c060bad855d864b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efe3d26459c71897a6862807ced317f1b52d865e57bd732344f494ab45eba76522636c3c3013adfc94a383a9c9ae1e2aed426bd08ecacd8d2ff5c9437109d955
|
7
|
+
data.tar.gz: e8a51ae511157081d9bc0a8344f7af466e082ce54123e6b49c06f5d8d6db2a1fb301ea07b38413ab140c27531c2ad20a75d7ef4e7bec2dcb8a20401052f48b31
|
data/README.md
CHANGED
@@ -75,6 +75,12 @@ domain.country.currency #=> "USD"
|
|
75
75
|
domain.conutry.calling_code #=> "+1"
|
76
76
|
```
|
77
77
|
|
78
|
+
### Check if a country is on the US Sanctions list
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
Gman.new("foo.gov.kp").sanctioned? #=> true
|
82
|
+
```
|
83
|
+
|
78
84
|
### Command line
|
79
85
|
|
80
86
|
#### Getting information about a given domain
|
data/bin/gman
CHANGED
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 = '4.
|
5
|
+
s.version = '4.5.0'
|
6
6
|
s.authors = ["Ben Balter"]
|
7
7
|
s.email = "ben.balter@github.com"
|
8
8
|
s.homepage = "https://github.com/benbalter/gman"
|
data/lib/gman.rb
CHANGED
data/lib/gman/country_codes.rb
CHANGED
@@ -21,6 +21,7 @@ class Gman < NaughtyOrNice
|
|
21
21
|
#
|
22
22
|
# e.g., United States = US, United Kingdom = GB
|
23
23
|
def alpha2
|
24
|
+
return unless domain_parts
|
24
25
|
alpha2 = domain_parts.tld.split('.').last
|
25
26
|
if ALPHA2_MAP[alpha2.to_sym]
|
26
27
|
ALPHA2_MAP[alpha2.to_sym]
|
@@ -35,6 +36,6 @@ class Gman < NaughtyOrNice
|
|
35
36
|
# Gman.new("foo.gov").country.name => "United States"
|
36
37
|
# Gman.new("foo.gov").country.currency => "USD"
|
37
38
|
def country
|
38
|
-
@country ||= IsoCountryCodes.find(alpha2)
|
39
|
+
@country ||= IsoCountryCodes.find(alpha2) if alpha2
|
39
40
|
end
|
40
41
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Gman
|
2
|
+
|
3
|
+
# http://www.treasury.gov/resource-center/sanctions/Programs/Pages/Programs.aspx
|
4
|
+
SANCTIONED_COUNTRIES = %w[
|
5
|
+
112
|
6
|
+
384
|
7
|
+
192
|
8
|
+
180
|
9
|
+
364
|
10
|
+
368
|
11
|
+
422
|
12
|
+
434
|
13
|
+
408
|
14
|
+
706
|
15
|
+
728
|
16
|
+
729
|
17
|
+
760
|
18
|
+
804
|
19
|
+
887
|
20
|
+
716
|
21
|
+
430
|
22
|
+
694
|
23
|
+
716
|
24
|
+
]
|
25
|
+
|
26
|
+
def sanctioned?
|
27
|
+
SANCTIONED_COUNTRIES.include?(country.numeric) if country
|
28
|
+
end
|
29
|
+
end
|
data/test/test_gman_bin.rb
CHANGED
@@ -73,4 +73,9 @@ class TestGmanBin < Minitest::Test
|
|
73
73
|
output, status = test_bin("--no-color")
|
74
74
|
assert_match /Usage/i, output
|
75
75
|
end
|
76
|
+
|
77
|
+
should "know if a country is sanctioned" do
|
78
|
+
output, status = test_bin "kim@pyongyang.gov.kp"
|
79
|
+
assert_match /SANCTIONED/, output
|
80
|
+
end
|
76
81
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative "helper"
|
2
|
+
|
3
|
+
class TestGmanSanctions < Minitest::Test
|
4
|
+
|
5
|
+
should "know when a country isn't sanctioned" do
|
6
|
+
refute Gman.new("whitehouse.gov").sanctioned?
|
7
|
+
end
|
8
|
+
|
9
|
+
should "know when a country is sanctioned" do
|
10
|
+
assert Gman.new("kim@pyongyang.gov.kp").sanctioned?
|
11
|
+
end
|
12
|
+
|
13
|
+
should "not err on invalid domains" do
|
14
|
+
assert_equal nil, Gman.new("domain.invalid").sanctioned?
|
15
|
+
end
|
16
|
+
|
17
|
+
should "work with non-governemnt domains" do
|
18
|
+
assert Gman.new("foo@bar.co.kp").sanctioned?
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: swot
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- lib/gman/identifier.rb
|
177
177
|
- lib/gman/locality.rb
|
178
178
|
- lib/gman/parser.rb
|
179
|
+
- lib/gman/sanctions.rb
|
179
180
|
- script/alphabetize
|
180
181
|
- script/build
|
181
182
|
- script/cibuild
|
@@ -196,6 +197,7 @@ files:
|
|
196
197
|
- test/test_gman_filter.rb
|
197
198
|
- test/test_gman_identifier.rb
|
198
199
|
- test/test_gman_locality.rb
|
200
|
+
- test/test_gman_sanctions.rb
|
199
201
|
homepage: https://github.com/benbalter/gman
|
200
202
|
licenses:
|
201
203
|
- MIT
|
@@ -230,3 +232,4 @@ test_files:
|
|
230
232
|
- test/test_gman_filter.rb
|
231
233
|
- test/test_gman_identifier.rb
|
232
234
|
- test/test_gman_locality.rb
|
235
|
+
- test/test_gman_sanctions.rb
|