demandbase 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "demandbase"
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
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"]
@@ -6,7 +6,28 @@ require 'demandbase/error'
6
6
  require 'demandbase/record'
7
7
 
8
8
  module Demandbase
9
- class << self
9
+
10
+ # Standard Industrial Classification (SIC) codes for organizations providing
11
+ # elementary, secondary, tertiary, or quaternary education.
12
+ #
13
+ # See https://github.com/leereilly/csi/blob/master/lib/data/master.toml for
14
+ # a complete list.
15
+ ACADEMIC_SIC_CODES = [
16
+ "82", # educational services
17
+ "821", # elementary and secondary schools
18
+ "8211", # elementary and secondary schools
19
+ "822", # colleges, universities, professional schools and junior colleges
20
+ "8221", # colleges, universities, and professional schools
21
+ "8222", # junior colleges and technical institutes
22
+ "824", # vocational schools
23
+ "8243", # data processing schools
24
+ "8244", # business and secretarila schools
25
+ "8249", # vocational schools, not elsewhere classified
26
+ "829", # schools and educational services, not elsewhere classified
27
+ "8299" # schools and educational services, not elsewhere classified
28
+ ]
29
+
30
+ class << self
10
31
 
11
32
  # Look up a Demandbase record for a given domain name.
12
33
  #
@@ -19,5 +40,22 @@ module Demandbase
19
40
  def lookup(domain)
20
41
  Demandbase::Record.new(domain)
21
42
  end
43
+
44
+ # Find out if a particular domain is associated with an academic institution.
45
+ #
46
+ # Returns true if it looks like an academic organization; false otherwise.
47
+ #
48
+ # Raises a Demandbase::RTIDNotSetError if a RTID key is not set.
49
+ # Raises a Demandbase::ParseError if the domain doesn't look legit.
50
+ # Raises a Demandbase::ServerError if the Demandbase server is unresponsive.
51
+ #
52
+ def is_academic?(domain)
53
+ record = Demandbase::Record.new(domain)
54
+ if record && ACADEMIC_SIC_CODES.include?(record.primary_sic)
55
+ return true
56
+ else
57
+ return false
58
+ end
59
+ end
22
60
  end
23
61
  end
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
- require 'mocha/setup'
3
+
4
4
  begin
5
5
  Bundler.setup(:default, :development)
6
6
  rescue Bundler::BundlerError => e
@@ -10,7 +10,7 @@ rescue Bundler::BundlerError => e
10
10
  end
11
11
  require 'test/unit'
12
12
  require 'shoulda'
13
-
13
+ require 'mocha/setup'
14
14
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
15
15
  $LOAD_PATH.unshift(File.dirname(__FILE__))
16
16
  require 'demandbase'
@@ -41,4 +41,25 @@ class TestDemandbase < Test::Unit::TestCase
41
41
 
42
42
  end
43
43
 
44
+ should "know a school" do
45
+ schools = [
46
+ 'strath.ac.uk',
47
+ 'stanford.edu',
48
+ 'walnutcreeksd.org'
49
+ ]
50
+
51
+ not_schools = [
52
+ 'lanl.gov',
53
+ 'microsoft.com'
54
+ ]
55
+
56
+ schools.each do |school|
57
+ assert_equal true, Demandbase::is_academic?(school)
58
+ end
59
+
60
+ not_schools.each do |school|
61
+ assert_equal false, Demandbase::is_academic?(school)
62
+ end
63
+ end
64
+
44
65
  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.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -176,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  segments:
178
178
  - 0
179
- hash: -62646037689653422
179
+ hash: 1716298398897801857
180
180
  required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  none: false
182
182
  requirements: