demandbase 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,47 +1,20 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestDemandbase < Test::Unit::TestCase
4
- should "get a record for Stanford University" do
5
- #assert_equal 'Stanford University', Demandbase::lookup_domain('stanford.edu')
4
+ should "get a record for Stanford University's domain name" do
5
+ assert_equal 'Stanford', Demandbase::lookup_domain('stanford.edu').company_name
6
6
  end
7
7
 
8
- should "get a record for the University of Strathclyde" do
9
-
10
- end
11
-
12
- should "get a record for a GitHub's IP address" do
13
-
14
- end
15
-
16
- should "recognize IP addresses" do
17
-
18
- end
19
-
20
- should "recognize domain names" do
21
-
8
+ should "get a record for a Stanford Uniersity IP" do
9
+ assert_equal 'Stanford Uniersity', Demandbase::lookup_ip('68.65.169.67').company_name # typo intentional
22
10
  end
23
11
 
24
- should "handle multiple formats" do
25
- queries = [
26
- "microsoft.com",
27
- "www.microsoft.com",
28
- "developer.hacks.microsoft.com",
29
- "http://www.microsoft.com",
30
- "https://www.microsofot.com",
31
- "william.gates@microsoft.com",
32
- "microsoft.co.uk"
33
- ]
34
- end
35
-
36
- should "return nothing when no record is found" do
37
-
12
+ should "be able to lazily lookup" do
13
+ assert_equal "Demandbase::IPRecord", Demandbase::lookup('68.65.169.67').class.to_s
14
+ assert_equal "Demandbase::DomainRecord", Demandbase::lookup('github.com').class.to_s
38
15
  end
39
16
 
40
- should "throw an exception when the service is down" do
41
-
42
- end
43
-
44
- should "know a school" do
17
+ should "know a school by domain name" do
45
18
  schools = [
46
19
  'strath.ac.uk',
47
20
  'stanford.edu',
@@ -62,4 +35,50 @@ class TestDemandbase < Test::Unit::TestCase
62
35
  end
63
36
  end
64
37
 
38
+ should "know a goverment agency / body by domain name" do
39
+ government_agencies = [
40
+ 'jgi.doe.gov',
41
+ 'cia.gov',
42
+ 'glasgow.gov.uk',
43
+ #'lanl.gov'
44
+ #'gchq.gov.uk'
45
+ ]
46
+
47
+ non_government_agencies = [
48
+ 'rangers.co.uk',
49
+ 'leereilly.net'
50
+ ]
51
+
52
+ government_agencies.each do |government_agency|
53
+ assert_equal true, Demandbase::is_government?(government_agency), government_agency
54
+ end
55
+
56
+ non_government_agencies.each do |non_government_agency|
57
+ assert_equal false, Demandbase::is_government?(non_government_agency), non_government_agency
58
+ end
59
+ end
60
+
61
+ should "know a nonprofit by domain name" do
62
+ nonprofits = [
63
+ 'gatesfoundation.org',
64
+ 'bhf.org.uk'
65
+ #'rspca.org.uk',
66
+ #'runningchicken.org'
67
+
68
+ ]
69
+
70
+ non_nonprofits = [ # nonprofit
71
+ 'rangers.co.uk',
72
+ 'leereilly.net'
73
+ ]
74
+
75
+ nonprofits.each do |nonprofit|
76
+ assert_equal true, Demandbase::is_nonprofit?(nonprofit), nonprofit
77
+ end
78
+
79
+ non_nonprofits.each do |non_nonprofit|
80
+ assert_equal false, Demandbase::is_nonprofit?(non_nonprofit), non_nonprofit
81
+ end
82
+ end
83
+
65
84
  end
@@ -0,0 +1,78 @@
1
+ require 'helper'
2
+
3
+ class TestDemandbaseDomainRecord < Test::Unit::TestCase
4
+ should "initialize a new record with a valid domain" do
5
+ domain = 'github.com'
6
+ record = Demandbase::DomainRecord.new(domain)
7
+
8
+ assert_equal "Github Inc", record.company_name # dat h ಠ_ಠ
9
+ assert_equal 22528943, record.demandbase_sid
10
+ assert_equal "Github", record.marketing_alias
11
+ assert_equal "Software & Technology", record.industry
12
+ assert_equal "Software Applications", record.sub_industry
13
+ assert_equal 30, record.employee_count
14
+ assert_equal "7372", record.primary_sic
15
+ assert_equal "548 4th St", record.street_address
16
+ assert_equal "San Francisco", record.city
17
+ assert_equal "CA", record.state
18
+ assert_equal "94107", record.zip
19
+ assert_equal "US", record.country
20
+ assert_equal "United States", record.country_name
21
+ assert_equal "415-409-8053", record.phone
22
+ assert_equal nil, record.stock_ticker
23
+ assert_equal "github.com", record.web_site
24
+ assert_equal 6240000, record.annual_sales
25
+ assert_equal "$5M - $10M", record.revenue_range
26
+ assert_equal "Small", record.employee_range
27
+ assert_equal true, record.b2b
28
+ assert_equal true, record.b2c
29
+ assert_equal "Very High", record.traffic
30
+ assert_equal 37.7789, record.latitude
31
+ assert_equal -122.398, record.longitude
32
+ assert_equal false, record.fortune_1000 # TODO: fix this test in 2017
33
+ assert_equal false, record.forbes_2000 # TODO: fix this test in 2016
34
+ end
35
+
36
+ should "initialize a new record with various query formats" do
37
+ queries = [
38
+ "github.com",
39
+ "www.github.com",
40
+ "developer.github.com/",
41
+ "http://www.github.com/",
42
+ "https://www.github.com",
43
+ "https://www.github.com/leereilly/demandbase",
44
+ "lee@github.com"
45
+ ].each do |query|
46
+ record = Demandbase::DomainRecord.new(query)
47
+ assert_equal "github.com", record.web_site, "with #{query}"
48
+ end
49
+ end
50
+
51
+ should "return nil if no record is found" do
52
+ record = Demandbase::lookup('leereilly.net')
53
+ end
54
+
55
+ should "raise a ParseError if the domain doesn't look valid" do
56
+ assert_raise(Demandbase::ParseError) { Demandbase::lookup('NOPE') }
57
+ end
58
+
59
+ should "recognize valid domains" do
60
+ queries = [
61
+ "github.com",
62
+ "www.github.com",
63
+ "developer.github.com/",
64
+ "http://www.github.com/",
65
+ "https://www.github.com",
66
+ "https://www.github.com/leereilly/demandbase",
67
+ "lee@github.com"
68
+ ].each do |query|
69
+ assert_equal true, Demandbase::DomainRecord.is_domain(query), "with #{query}"
70
+ end
71
+ end
72
+
73
+ should "raise a ServerError if there's a problem communicating with the Demandbase server" do
74
+ Demandbase::DomainRecord.any_instance.stubs(:api_url).returns('http://www.example.com')
75
+ assert_raise(Demandbase::ServerError) { Demandbase::DomainRecord.new('github.com') }
76
+ Demandbase::DomainRecord.any_instance.unstub(:api_url)
77
+ end
78
+ end
@@ -0,0 +1,53 @@
1
+ require 'helper'
2
+
3
+ class TestDemandbaseIPRecord < Test::Unit::TestCase
4
+ should "initialize a new record with a valid ip" do
5
+ ip = '68.65.169.67'
6
+ record = Demandbase::IPRecord.new(ip)
7
+
8
+ assert_equal "Stanford University", record.registry_company_name
9
+ assert_equal "Stanford", record.registry_city
10
+ assert_equal "CA", record.registry_state
11
+ assert_equal "94305", record.registry_zip_code
12
+ assert_equal 650, record.registry_area_code
13
+ assert_equal "United States", record.registry_country
14
+ assert_equal "US", record.registry_country_code
15
+ assert_equal 37.41780090332031, record.registry_latitude
16
+ assert_equal -122.1719970703125, record.registry_longitude
17
+ assert_equal "Stanford Uniersity", record.company_name # typo intentional
18
+ assert_equal 28548234, record.demandbase_sid
19
+ assert_equal "Stanford Uniersity", record.marketing_alias # typo intentional
20
+ assert_equal "Education", record.industry
21
+ assert_equal "University", record.sub_industry
22
+ assert_equal 15, record.employee_count
23
+ assert_equal false, record.isp
24
+ assert_equal "8221", record.primary_sic
25
+ assert_equal "318 Campus Dr Ste 100", record.street_address
26
+ assert_equal "Stanford", record.city
27
+ assert_equal "CA", record.state
28
+ assert_equal "94305", record.zip
29
+ assert_equal "US", record.country
30
+ assert_equal "United States", record.country_name
31
+ assert_equal "650-736-1160", record.phone
32
+ assert_equal nil, record.stock_ticker
33
+ assert_equal nil, record.web_site
34
+ assert_equal 3120000, record.annual_sales
35
+ assert_equal "$1M - $5M", record.revenue_range
36
+ assert_equal "Small", record.employee_range
37
+ assert_equal true, record.b2b
38
+ assert_equal true, record.b2c
39
+ assert_equal "Low", record.traffic
40
+ assert_equal 37.4304, record.latitude
41
+ assert_equal -122.176, record.longitude
42
+ assert_equal false, record.fortune_1000
43
+ assert_equal false, record.forbes_2000
44
+ assert_equal "Detailed", record.information_level
45
+ assert_equal "Education", record.audience
46
+ assert_equal "University", record.audience_segment
47
+ assert_equal "68.65.169.67", record.ip
48
+ end
49
+
50
+ should "return nil if no record is found" do
51
+ record = Demandbase::IPRecord::new('127.0.0.1')
52
+ end
53
+ end
data/test/test_record.rb CHANGED
@@ -5,72 +5,72 @@ class TestDemandbaseRecord < Test::Unit::TestCase
5
5
  assert ENV['DEMANDBASE_RTID_KEY'], "Please set your $DEMANDBASE_RTID_KEY"
6
6
  end
7
7
 
8
- should "initialize a new record with a valid domain" do
9
- domain = 'github.com'
10
- record = Demandbase::Record.new(domain)
8
+ # should "initialize a new record with a valid domain" do
9
+ # domain = 'github.com'
10
+ # record = Demandbase::Record.new(domain)
11
11
 
12
- assert_equal "Github Inc", record.company_name # dat h ಠ_ಠ
13
- assert_equal 22528943, record.demandbase_sid
14
- assert_equal "Github", record.marketing_alias
15
- assert_equal "Software & Technology", record.industry
16
- assert_equal "Software Applications", record.sub_industry
17
- assert_equal 30, record.employee_count
18
- assert_equal "7372", record.primary_sic
19
- assert_equal "548 4th St", record.street_address
20
- assert_equal "San Francisco", record.city
21
- assert_equal "CA", record.state
22
- assert_equal "94107", record.zip
23
- assert_equal "US", record.country
24
- assert_equal "United States", record.country_name
25
- assert_equal "415-409-8053", record.phone
26
- assert_equal nil, record.stock_ticker
27
- assert_equal "github.com", record.web_site
28
- assert_equal 6240000, record.annual_sales
29
- assert_equal "$5M - $10M", record.revenue_range
30
- assert_equal "Small", record.employee_range
31
- assert_equal true, record.b2b
32
- assert_equal true, record.b2c
33
- assert_equal "Very High", record.traffic
34
- assert_equal 37.7789, record.latitude
35
- assert_equal -122.398, record.longitude
36
- assert_equal false, record.fortune_1000 # TODO: fix this test in 2017
37
- assert_equal false, record.forbes_2000 # TODO: fix this test in 2016
38
- end
12
+ # assert_equal "Github Inc", record.company_name # dat h ಠ_ಠ
13
+ # assert_equal 22528943, record.demandbase_sid
14
+ # assert_equal "Github", record.marketing_alias
15
+ # assert_equal "Software & Technology", record.industry
16
+ # assert_equal "Software Applications", record.sub_industry
17
+ # assert_equal 30, record.employee_count
18
+ # assert_equal "7372", record.primary_sic
19
+ # assert_equal "548 4th St", record.street_address
20
+ # assert_equal "San Francisco", record.city
21
+ # assert_equal "CA", record.state
22
+ # assert_equal "94107", record.zip
23
+ # assert_equal "US", record.country
24
+ # assert_equal "United States", record.country_name
25
+ # assert_equal "415-409-8053", record.phone
26
+ # assert_equal nil, record.stock_ticker
27
+ # assert_equal "github.com", record.web_site
28
+ # assert_equal 6240000, record.annual_sales
29
+ # assert_equal "$5M - $10M", record.revenue_range
30
+ # assert_equal "Small", record.employee_range
31
+ # assert_equal true, record.b2b
32
+ # assert_equal true, record.b2c
33
+ # assert_equal "Very High", record.traffic
34
+ # assert_equal 37.7789, record.latitude
35
+ # assert_equal -122.398, record.longitude
36
+ # assert_equal false, record.fortune_1000 # TODO: fix this test in 2017
37
+ # assert_equal false, record.forbes_2000 # TODO: fix this test in 2016
38
+ # end
39
39
 
40
- should "initialize a new record with a subdomain" do
41
- queries = [
42
- "github.com",
43
- "www.github.com",
44
- "developer.github.com/",
45
- "http://www.github.com/",
46
- "https://www.github.com",
47
- "https://www.github.com/leereilly/demandbase",
48
- "lee@github.com"
49
- ]
40
+ # should "initialize a new record with a subdomain" do
41
+ # queries = [
42
+ # "github.com",
43
+ # "www.github.com",
44
+ # "developer.github.com/",
45
+ # "http://www.github.com/",
46
+ # "https://www.github.com",
47
+ # "https://www.github.com/leereilly/demandbase",
48
+ # "lee@github.com"
49
+ # ]
50
50
 
51
- queries.each do |query|
52
- record = Demandbase::Record.new(query)
53
- assert_equal "github.com", record.web_site, "with #{query}"
54
- end
55
- end
51
+ # queries.each do |query|
52
+ # record = Demandbase::Record.new(query)
53
+ # assert_equal "github.com", record.web_site, "with #{query}"
54
+ # end
55
+ # end
56
56
 
57
- should "should return nil if no record is found" do
58
- record = Demandbase::lookup('leereilly.net')
59
- end
57
+ # should "should return nil if no record is found" do
58
+ # record = Demandbase::lookup('leereilly.net')
59
+ # end
60
60
 
61
- should "raise an RTIDNotSetError if no DEMANDBASE_RTID_KEY is set" do
62
- Demandbase::Record.any_instance.stubs(:rtid_key).returns(nil)
63
- assert_raise(Demandbase::RTIDNotSetError) { Demandbase::lookup('github.com') }
64
- Demandbase::Record.any_instance.unstub(:rtid_key)
65
- end
61
+ # should "raise an RTIDNotSetError if no DEMANDBASE_RTID_KEY is set" do
62
+ # Demandbase::Record.any_instance.stubs(:rtid_key).returns(nil)
63
+ # assert_raise(Demandbase::RTIDNotSetError) { Demandbase::lookup('github.com') }
64
+ # Demandbase::Record.any_instance.unstub(:rtid_key)
65
+ # end
66
66
 
67
- should "raise a ParseError if the domain doesn't look valid" do
68
- assert_raise(Demandbase::ParseError) { Demandbase::lookup('NOPE') }
69
- end
67
+ # should "raise a ParseError if the domain doesn't look valid" do
68
+ # assert_raise(Demandbase::ParseError) { Demandbase::lookup('NOPE') }
69
+ # end
70
70
 
71
- should "raise a ServerError if there's a problem communicating with the Demandbase server" do
72
- Demandbase::Record.any_instance.stubs(:domain_api_url).returns('http://www.example.com')
73
- assert_raise(Demandbase::ServerError) { Demandbase::lookup('github.com') }
74
- Demandbase::Record.any_instance.unstub(:domain_api_url)
75
- end
71
+ # should "raise a ServerError if there's a problem communicating with the Demandbase server" do
72
+ # Demandbase::Record.any_instance.stubs(:domain_api_url).returns('http://www.example.com')
73
+ # assert_raise(Demandbase::ServerError) { Demandbase::lookup('github.com') }
74
+ # Demandbase::Record.any_instance.unstub(:domain_api_url)
75
+ # end
76
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: demandbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-15 00:00:00.000000000 Z
12
+ date: 2013-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -156,10 +156,14 @@ files:
156
156
  - VERSION
157
157
  - demandbase.gemspec
158
158
  - lib/demandbase.rb
159
+ - lib/demandbase/domain_record.rb
159
160
  - lib/demandbase/error.rb
161
+ - lib/demandbase/ip_record.rb
160
162
  - lib/demandbase/record.rb
161
163
  - test/helper.rb
162
164
  - test/test_demandbase.rb
165
+ - test/test_domain_record.rb
166
+ - test/test_ip_record.rb
163
167
  - test/test_record.rb
164
168
  homepage: http://github.com/leereilly/demandbase
165
169
  licenses:
@@ -176,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
180
  version: '0'
177
181
  segments:
178
182
  - 0
179
- hash: 1716298398897801857
183
+ hash: -87636231127131332
180
184
  required_rubygems_version: !ruby/object:Gem::Requirement
181
185
  none: false
182
186
  requirements: