demandbase 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
+ # 0.1.6
2
+
3
+ * Added `is_academic?` and `is_government()` instance methods. Thanks @benbalter!
4
+ * Added support for deprecated `lazy_lookup()` method. Thanks @benbalter!
5
+
1
6
  # 0.1.4
2
7
 
3
- * Add a utility method `is_academic?(domain)` for detecting academic organizations, educational institutions, etc.
8
+ * Added a utility method `is_academic?(domain)` for detecting academic organizations, educational institutions, etc.
4
9
 
5
10
  # 0.1.3
6
11
 
@@ -32,4 +37,4 @@
32
37
 
33
38
  # 0.1.0
34
39
 
35
- * Initial release.
40
+ * Initial release.
data/README.md CHANGED
@@ -43,6 +43,12 @@ record = Demandbase::lookup_domain 'microsoft.com'
43
43
  record.company_name
44
44
  # => "Microsoft Corporation"
45
45
 
46
+ record.is_academic?
47
+ # => false
48
+
49
+ record.is_government?
50
+ # => false
51
+
46
52
  record.demandbase_sid
47
53
  # => 457441
48
54
 
@@ -126,16 +132,11 @@ The IP lookup returns some additional information e.g.
126
132
  ```ruby
127
133
  record = Demandbase::lookup_ip 'microsoft.com'
128
134
  # => <Demandbase::Record:0x007fce82a46060>
129
- <<<<<<< HEAD
130
-
131
-
132
- =======
133
- >>>>>>> ae8ee8ca255b42a6a0754c9087e83102c966d2f8
134
135
  ```
135
136
 
136
137
  #### Lazy Lookup
137
138
 
138
- If you have an IP, domain name, email address, or craptacular URL and just want to use that use `lazy_lookup`
139
+ If you have an IP, domain name, email address, or craptacular URL and just want to use that use `lookup`
139
140
 
140
141
  ```ruby
141
142
  ip_looking_thing = '12.12.12.12'
@@ -143,16 +144,16 @@ domain_looking_thing 'http://google.com'
143
144
  url_looking_thing 'www.google.com/lol?seriously=true'
144
145
  email_looking_thing 'willy@microsoft.com'
145
146
 
146
- (Demandbase::lazy_lookup ip_looking_thing).class
147
+ (Demandbase::lookup ip_looking_thing).class
147
148
  # => Demanbase::IPRecord
148
149
 
149
- (Demandbase::lazy_lookup domain_looking_thing).class
150
+ (Demandbase::lookup domain_looking_thing).class
150
151
  # => Demanbase::DomainRecord
151
152
 
152
- (Demandbase::lazy_lookup url_looking_thing).class
153
+ (Demandbase::lookup url_looking_thing).class
153
154
  # => Demanbase::DomainRecord
154
155
 
155
- (Demandbase::lazy_lookup email_looking_thing).class
156
+ (Demandbase::lookup email_looking_thing).class
156
157
  # => Demanbase::DomainRecord
157
158
  ```
158
159
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.7
data/demandbase.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "demandbase"
8
- s.version = "0.1.5"
8
+ s.version = "0.1.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Lee Reilly"]
12
- s.date = "2013-03-24"
12
+ s.date = "2013-04-12"
13
13
  s.description = "Ruby wrapper for the Demandbase API"
14
14
  s.email = "lee@leereilly.net"
15
15
  s.extra_rdoc_files = [
data/lib/demandbase.rb CHANGED
@@ -114,11 +114,6 @@ module Demandbase
114
114
  end
115
115
  alias_method :lookup_domain_name, :lookup_domain
116
116
 
117
- def lazy_lookup
118
-
119
- end
120
- alias_method :lookup, :lazy_lookup
121
-
122
117
  # Look up a Demandbase record for a given domain name.
123
118
  #
124
119
  # Returns a Demandbase::Record if the record is found; nil otherwise.
@@ -136,6 +131,7 @@ module Demandbase
136
131
  raise Demandbase::ParseError
137
132
  end
138
133
  end
134
+ alias_method :lazy_lookup, :lookup
139
135
 
140
136
  # Find out if a particular domain is associated with an academic institution.
141
137
  #
@@ -31,5 +31,29 @@ module Demandbase
31
31
  def rtid_key
32
32
  ENV['DEMANDBASE_RTID_KEY']
33
33
  end
34
+
35
+ def is_academic?
36
+ if Demandbase::ACADEMIC_SIC_CODES.include?(primary_sic)
37
+ return true
38
+ else
39
+ return false
40
+ end
41
+ end
42
+
43
+ def is_government?
44
+ if Demandbase::GOVERNMENT_SIC_CODES.include?(primary_sic)
45
+ return true
46
+ else
47
+ return false
48
+ end
49
+ end
50
+
51
+ def is_nonprofit?
52
+ if Demandbase::NONPROFIT_SIC_CODES.include?(primary_sic)
53
+ return true
54
+ else
55
+ return false
56
+ end
57
+ end
34
58
  end
35
59
  end
@@ -1,6 +1,18 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestDemandbase < Test::Unit::TestCase
4
+ should "ensure lazy_lookup sticks around as an aliased lookup method for early adopters" do
5
+ Demandbase.method(:lazy_lookup) == Demandbase.method(:lookup)
6
+ end
7
+
8
+ should "lazily lookup domain names" do
9
+ assert_equal Demandbase::DomainRecord, Demandbase::lookup('stanford.edu').class
10
+ end
11
+
12
+ should "lazily lookup IPv4 addresses" do
13
+ assert_equal Demandbase::IPRecord, Demandbase::lookup('68.65.169.67').class
14
+ end
15
+
4
16
  should "get a record for Stanford University's domain name" do
5
17
  assert_equal 'Stanford', Demandbase::lookup_domain('stanford.edu').company_name
6
18
  end
data/test/test_record.rb CHANGED
@@ -5,6 +5,16 @@ 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 "recognize academic institutions" do
9
+ record = Demandbase::lookup 'stanford.edu'
10
+ assert_equal true, record.is_academic?
11
+ end
12
+
13
+ should "recognize government institutions" do
14
+ record = Demandbase::lookup 'fbi.gov'
15
+ assert_equal true, record.is_government?
16
+ end
17
+
8
18
  # should "initialize a new record with a valid domain" do
9
19
  # domain = 'github.com'
10
20
  # record = Demandbase::Record.new(domain)
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.5
4
+ version: 0.1.7
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-24 00:00:00.000000000 Z
12
+ date: 2013-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -180,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  version: '0'
181
181
  segments:
182
182
  - 0
183
- hash: -87636231127131332
183
+ hash: 2140425610906353527
184
184
  required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  none: false
186
186
  requirements: