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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99d4f1edc2e2e2e463e445d24620e9fe2be2ba73
4
- data.tar.gz: 1d72f716a432b6351dc635e171c0526c29f7b6eb
3
+ metadata.gz: a172d1b966cc4024dbedfe36a23bc8b3e6719ed2
4
+ data.tar.gz: 7149f379f8c5a2db46f2f7835c060bad855d864b
5
5
  SHA512:
6
- metadata.gz: 649a0450105a4de7d913684677bf20211169cc68989fb35951fd6945508d8d243b1cccebb035802af66cdde4f25e39307d5006f32c3f01cd7b2f9323d6deba17
7
- data.tar.gz: fb87052259126e43790f40e235cc5ff4cdc63f16c2ae3166fd8c2036d553fb3fee27a9bf1d8a269664e9434533e2986c7d9b034b156e3c7b0be1bb7c5a8c285b
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
@@ -41,3 +41,5 @@ puts "Status : " + "Valid government domain".green
41
41
  value = gman.send(key)
42
42
  puts "#{key.capitalize.ljust(8)}: #{value}" if value
43
43
  end
44
+
45
+ puts "SANCTIONED NATION".red if gman.sanctioned?
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.4.3'
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
@@ -5,6 +5,7 @@ require 'csv'
5
5
  require_relative 'gman/country_codes'
6
6
  require_relative 'gman/locality'
7
7
  require_relative 'gman/identifier'
8
+ require_relative 'gman/sanctions'
8
9
 
9
10
  class Gman < NaughtyOrNice
10
11
  class << self
@@ -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
@@ -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.3
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-28 00:00:00.000000000 Z
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