crunchbase 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +38 -2
- data/VERSION +1 -1
- data/crunchbase.gemspec +6 -2
- data/lib/crunchbase.rb +3 -1
- data/lib/crunchbase/api.rb +44 -16
- data/lib/crunchbase/cb_object.rb +1 -0
- data/lib/crunchbase/company.rb +7 -0
- data/lib/crunchbase/financial_organization.rb +6 -1
- data/lib/crunchbase/person.rb +5 -1
- data/lib/crunchbase/product.rb +5 -1
- data/lib/crunchbase/search.rb +74 -0
- data/lib/crunchbase/search_result.rb +63 -0
- data/lib/crunchbase/service_provider.rb +5 -1
- data/spec/crunchbase/api_spec.rb +7 -1
- data/spec/crunchbase/company_spec.rb +6 -1
- data/spec/crunchbase/financial_organization_spec.rb +6 -1
- data/spec/crunchbase/person_spec.rb +6 -1
- data/spec/crunchbase/product_spec.rb +6 -1
- data/spec/crunchbase/search_result_spec.rb +16 -0
- data/spec/crunchbase/search_spec.rb +23 -0
- data/spec/crunchbase/service_provider_spec.rb +7 -2
- metadata +17 -13
data/README.rdoc
CHANGED
@@ -9,15 +9,51 @@ use the {YAJL gem}[http://github.com/brianmario/yajl-ruby]; if not, it will
|
|
9
9
|
fall back to the {JSON gem}[http://flori.github.com/json/]. Please ensure one
|
10
10
|
of the two is installed.
|
11
11
|
|
12
|
-
==
|
12
|
+
== Usage
|
13
|
+
|
14
|
+
If you already know the permalink for a given entity, you can grab the entry
|
15
|
+
with the +get+ method.
|
13
16
|
|
14
17
|
require 'crunchbase'
|
15
18
|
steve = Crunchbase::Person.get("steve-jobs")
|
16
19
|
facebook = Crunchbase::Company.get("facebook")
|
20
|
+
|
21
|
+
If you know the name of the entity but not the permalink, you can use the
|
22
|
+
+find+ method.
|
23
|
+
|
24
|
+
steve = Crunchbase::Person.find("Steve", "Jobs")
|
25
|
+
github = Crunchbase::Company.find("Github")
|
26
|
+
|
27
|
+
Note that finding using a name performs two HTTP requests internally, the first
|
28
|
+
returning the permalink associated with the name, and the second which returns
|
29
|
+
the actual data.
|
30
|
+
|
31
|
+
=== Search
|
32
|
+
|
33
|
+
Searching the Crunchbase is possible with the Search class.
|
34
|
+
|
35
|
+
s = Crunchbase::Search.find("widgets")
|
36
|
+
|
37
|
+
You can access the search results by treating the returned Search instance as
|
38
|
+
an array.
|
39
|
+
|
40
|
+
first_result = s[0]
|
41
|
+
s.each { |result| puts result.name }
|
42
|
+
|
43
|
+
While Search does include the Enumerable module, it does not implement all of
|
44
|
+
the methods of Array. If you need to treat the results as an array in a way not
|
45
|
+
supported, you can call +to_ary+; this prefetches all result pages (if they have
|
46
|
+
not already been loaded), so it may entail a slight delay, depending on the
|
47
|
+
number of results.
|
48
|
+
|
49
|
+
all_results = s.to_ary
|
50
|
+
result_slice = s[3..6]
|
51
|
+
|
52
|
+
Coming Soon: List of Entities
|
17
53
|
|
18
54
|
== Copyright
|
19
55
|
|
20
|
-
Copyright (c) 2011 Tyler Cunnion. This software is made available under the
|
56
|
+
Copyright (c) 2011-12 Tyler Cunnion. This software is made available under the
|
21
57
|
MIT/X11 license. See LICENSE.txt for further details.
|
22
58
|
|
23
59
|
I am not affiliated in any way with AOL, TechCrunch, Crunchbase, or anyone
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/crunchbase.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{crunchbase}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Tyler Cunnion}]
|
12
|
-
s.date = %q{2012-02-
|
12
|
+
s.date = %q{2012-02-21}
|
13
13
|
s.email = %q{tyler.cunnion@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
@@ -37,12 +37,16 @@ Gem::Specification.new do |s|
|
|
37
37
|
"lib/crunchbase/relationships/firm_relationship.rb",
|
38
38
|
"lib/crunchbase/relationships/person_relationship.rb",
|
39
39
|
"lib/crunchbase/relationships/provider_relationship.rb",
|
40
|
+
"lib/crunchbase/search.rb",
|
41
|
+
"lib/crunchbase/search_result.rb",
|
40
42
|
"lib/crunchbase/service_provider.rb",
|
41
43
|
"spec/crunchbase/api_spec.rb",
|
42
44
|
"spec/crunchbase/company_spec.rb",
|
43
45
|
"spec/crunchbase/financial_organization_spec.rb",
|
44
46
|
"spec/crunchbase/person_spec.rb",
|
45
47
|
"spec/crunchbase/product_spec.rb",
|
48
|
+
"spec/crunchbase/search_result_spec.rb",
|
49
|
+
"spec/crunchbase/search_spec.rb",
|
46
50
|
"spec/crunchbase/service_provider_spec.rb",
|
47
51
|
"spec/fixtures/brad-fitzpatrick.js",
|
48
52
|
"spec/fixtures/steve-jobs.js",
|
data/lib/crunchbase.rb
CHANGED
@@ -11,8 +11,10 @@ require 'crunchbase/relationship'
|
|
11
11
|
require 'crunchbase/relationships/firm_relationship'
|
12
12
|
require 'crunchbase/relationships/person_relationship'
|
13
13
|
require 'crunchbase/relationships/provider_relationship'
|
14
|
+
require 'crunchbase/search'
|
15
|
+
require 'crunchbase/search_result'
|
14
16
|
require 'crunchbase/crunch_exception'
|
15
17
|
|
16
18
|
module Crunchbase
|
17
|
-
VERSION = "0.0
|
19
|
+
VERSION = "0.1.0"
|
18
20
|
end
|
data/lib/crunchbase/api.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'net/http'
|
2
3
|
|
3
4
|
begin
|
@@ -16,6 +17,10 @@ module Crunchbase
|
|
16
17
|
# methods provided on each entity class instead of calling these directly.
|
17
18
|
class API
|
18
19
|
CB_URL = 'http://api.crunchbase.com/v/1/'
|
20
|
+
@timeout_limit = 60
|
21
|
+
@redirect_limit = 2
|
22
|
+
|
23
|
+
class << self; attr_accessor :timeout_limit, :redirect_limit end
|
19
24
|
|
20
25
|
def self.person(permalink)
|
21
26
|
fetch(permalink, 'person')
|
@@ -38,19 +43,8 @@ module Crunchbase
|
|
38
43
|
end
|
39
44
|
|
40
45
|
private
|
41
|
-
|
42
|
-
#
|
43
|
-
# Raises CrunchException if the returned JSON indicates an error.
|
44
|
-
def self.fetch(permalink, object_name)
|
45
|
-
uri = CB_URL + "#{object_name}/#{permalink}.js"
|
46
|
-
resp = Timeout::timeout(60) {
|
47
|
-
get_url_following_redirects(uri, 5)
|
48
|
-
}
|
49
|
-
j = parser.parse(resp)
|
50
|
-
raise CrunchException, j["error"] if j["error"]
|
51
|
-
return j
|
52
|
-
end
|
53
|
-
|
46
|
+
|
47
|
+
# Returns the JSON parser, whether that's an instance of Yajl or JSON
|
54
48
|
def self.parser
|
55
49
|
if defined?(Yajl)
|
56
50
|
Yajl::Parser
|
@@ -59,14 +53,48 @@ module Crunchbase
|
|
59
53
|
end
|
60
54
|
end
|
61
55
|
|
56
|
+
# Fetches URI for the permalink interface.
|
57
|
+
def self.fetch(permalink, object_name)
|
58
|
+
uri = CB_URL + "#{object_name}/#{permalink}.js"
|
59
|
+
get_json_response(uri)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Fetches URI for the search interface.
|
63
|
+
def self.search(query, page=1)
|
64
|
+
require "cgi"
|
65
|
+
uri = CB_URL + "search.js?query=#{CGI.escape(query)}&page=#{page}"
|
66
|
+
get_json_response(uri)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Searches for a permalink in a particular category.
|
70
|
+
def self.permalink(parameters, category)
|
71
|
+
require "cgi"
|
72
|
+
qs = parameters.map{|k,v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v)}"}.join('&')
|
73
|
+
uri = CB_URL + "#{category}/permalink?#{qs}"
|
74
|
+
get_json_response(uri)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Gets specified URI, then parses the returned JSON. Raises Timeout error
|
78
|
+
# if request time exceeds set limit. Raises CrunchException if returned
|
79
|
+
# JSON contains an error.
|
80
|
+
def self.get_json_response(uri)
|
81
|
+
resp = Timeout::timeout(@timeout_limit) {
|
82
|
+
get_url_following_redirects(uri, @redirect_limit)
|
83
|
+
}
|
84
|
+
j = parser.parse(resp)
|
85
|
+
raise CrunchException, j["error"] if j["error"]
|
86
|
+
j
|
87
|
+
end
|
88
|
+
|
89
|
+
# Performs actual HTTP requests, recursively if a redirect response is
|
90
|
+
# encountered. Will raise HTTP error if response is not 200, 404, or 3xx.
|
62
91
|
def self.get_url_following_redirects(uri_str, limit = 10)
|
63
92
|
raise CrunchException, 'HTTP redirect too deep' if limit == 0
|
64
93
|
|
65
94
|
url = URI.parse(uri_str)
|
66
|
-
|
67
|
-
response = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
|
95
|
+
response = Net::HTTP.start(url.host, url.port) { |http| http.get(url.request_uri) }
|
68
96
|
case response
|
69
|
-
when Net::HTTPSuccess
|
97
|
+
when Net::HTTPSuccess, Net::HTTPNotFound
|
70
98
|
response.body
|
71
99
|
when Net::HTTPRedirection
|
72
100
|
get_url_following_redirects(response['location'], limit - 1)
|
data/lib/crunchbase/cb_object.rb
CHANGED
data/lib/crunchbase/company.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'date'
|
2
2
|
module Crunchbase
|
3
|
+
# Represents a Company listed in the Crunchbase.
|
3
4
|
class Company < CB_Object
|
4
5
|
|
5
6
|
include Crunchbase::DateMethods
|
@@ -18,6 +19,11 @@ module Crunchbase
|
|
18
19
|
c = Company.new(j)
|
19
20
|
return c
|
20
21
|
end
|
22
|
+
|
23
|
+
# Factory method to return a Company instance from a company name.
|
24
|
+
def self.find(name)
|
25
|
+
get(API.permalink({name: name}, "companies")["permalink"])
|
26
|
+
end
|
21
27
|
|
22
28
|
def initialize(json)
|
23
29
|
@name = json["name"]
|
@@ -72,6 +78,7 @@ module Crunchbase
|
|
72
78
|
@deadpooled ||= date_from_components(@deadpooled_year, @deadpooled_month, @deadpooled_day)
|
73
79
|
end
|
74
80
|
|
81
|
+
# Returns an array of Product objects, representing this Company's products.
|
75
82
|
def products
|
76
83
|
@products ||= @products_list.map {|p| Product.get(p['permalink']) }
|
77
84
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'date'
|
2
2
|
module Crunchbase
|
3
|
+
# Represents a Financial Organization listed in the Crunchbase.
|
3
4
|
class FinancialOrganization < CB_Object
|
4
5
|
|
5
6
|
include Crunchbase::DateMethods
|
@@ -16,6 +17,10 @@ module Crunchbase
|
|
16
17
|
f = FinancialOrganization.new(j)
|
17
18
|
return f
|
18
19
|
end
|
20
|
+
|
21
|
+
def self.find(name)
|
22
|
+
get(API.permalink({name: name}, "financial-organizations")["permalink"])
|
23
|
+
end
|
19
24
|
|
20
25
|
def initialize(json)
|
21
26
|
@name = json['name']
|
@@ -53,4 +58,4 @@ module Crunchbase
|
|
53
58
|
@founded ||= date_from_components(@founded_year, @founded_month, @founded_day)
|
54
59
|
end
|
55
60
|
end
|
56
|
-
end
|
61
|
+
end
|
data/lib/crunchbase/person.rb
CHANGED
@@ -16,6 +16,10 @@ module Crunchbase
|
|
16
16
|
p = Person.new(j)
|
17
17
|
return p
|
18
18
|
end
|
19
|
+
|
20
|
+
def self.find(first_name, last_name)
|
21
|
+
get(API.permalink({first_name: first_name, last_name: last_name}, "people")["permalink"])
|
22
|
+
end
|
19
23
|
|
20
24
|
def initialize(json)
|
21
25
|
@first_name = json["first_name"]
|
@@ -52,4 +56,4 @@ module Crunchbase
|
|
52
56
|
end
|
53
57
|
|
54
58
|
end
|
55
|
-
end
|
59
|
+
end
|
data/lib/crunchbase/product.rb
CHANGED
@@ -14,6 +14,10 @@ module Crunchbase
|
|
14
14
|
j = API.product(permalink)
|
15
15
|
return Product.new(j)
|
16
16
|
end
|
17
|
+
|
18
|
+
def self.find(name)
|
19
|
+
get(API.permalink({name: name}, "products")["permalink"])
|
20
|
+
end
|
17
21
|
|
18
22
|
def initialize(json)
|
19
23
|
@name = json['name']
|
@@ -63,4 +67,4 @@ module Crunchbase
|
|
63
67
|
return @company
|
64
68
|
end
|
65
69
|
end
|
66
|
-
end
|
70
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Crunchbase
|
2
|
+
|
3
|
+
# The Search class provides access to the Crunchbase search API. To perform a
|
4
|
+
# search, call the find class method, which returns an object of the Search
|
5
|
+
# class. This object represents an array of SearchResult objects, which may
|
6
|
+
# be addressed in a way analogous to an Array. These results are loaded on
|
7
|
+
# demand, in line with the CB API which returns results in pages of 10. When
|
8
|
+
# requesting a result index that has not been loaded yet, a new request is
|
9
|
+
# made to fetch it, resulting in a small delay. The class implements the
|
10
|
+
# Enumerable module, allowing usage of +map+, +select+, etc. If this is not
|
11
|
+
# sufficient, and full access to the underlying array is required, you may
|
12
|
+
# call to_ary, which will return the entire array including all results. If
|
13
|
+
# not all results have been fetched yet, there will be a delay to retrieve
|
14
|
+
# them, so consider this if your search contains a large number of results.
|
15
|
+
class Search
|
16
|
+
include Enumerable
|
17
|
+
|
18
|
+
attr_reader :size, :crunchbase_url
|
19
|
+
alias :length :size
|
20
|
+
|
21
|
+
# Performs a Crunchbase search for query.
|
22
|
+
def self.find(query)
|
23
|
+
j = API.search(query)
|
24
|
+
s = Search.new(query, j)
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(query, json)
|
28
|
+
@query = query
|
29
|
+
@results = []
|
30
|
+
@size = json["total"]
|
31
|
+
@crunchbase_url = json["crunchbase_url"]
|
32
|
+
populate_results(json)
|
33
|
+
end
|
34
|
+
|
35
|
+
def [](key)
|
36
|
+
if key.kind_of?(Integer)
|
37
|
+
r = @results[key]
|
38
|
+
unless r.nil? && key < @size
|
39
|
+
r
|
40
|
+
else
|
41
|
+
retrieve_for_index(key)
|
42
|
+
@results[key]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns array of all search results (not just ones currently loaded.)
|
48
|
+
# This enables the user to take advantage of all Array methods, not just
|
49
|
+
# the ones implmented on Search.
|
50
|
+
def to_ary
|
51
|
+
self.map{|result| result}
|
52
|
+
end
|
53
|
+
|
54
|
+
# Calls _block_ once for each search result, passing that item as a
|
55
|
+
# parameter.
|
56
|
+
def each(&block) # :yields: result
|
57
|
+
0.upto(@size - 1) {|x| yield self[x]}
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def populate_results(json)
|
63
|
+
page = json["page"]
|
64
|
+
results = json["results"].map{|r| SearchResult.new(r)}
|
65
|
+
start = (page - 1) * 10
|
66
|
+
@results[start, results.length] = results
|
67
|
+
end
|
68
|
+
|
69
|
+
def retrieve_for_index(index)
|
70
|
+
page = (index / 10) + 1
|
71
|
+
populate_results(API.search(@query, page))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Crunchbase
|
2
|
+
# Represents a single search result arising from a Search. The information
|
3
|
+
# returned from a search includes the name, namespace (i.e. entity type),
|
4
|
+
# permalink, and an overview. You may also choose to retrieve the full
|
5
|
+
# entity with the entity method.
|
6
|
+
class SearchResult
|
7
|
+
attr_reader :permalink, :crunchbase_url, :namespace, :overview
|
8
|
+
|
9
|
+
def first_name
|
10
|
+
raise CrunchException, "Not available for this entity" unless namespace == "person"
|
11
|
+
@first_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def last_name
|
15
|
+
raise CrunchException, "Not available for this entity" unless namespace == "person"
|
16
|
+
@last_name
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns concatenation of first and last names if person, otherwise
|
20
|
+
# returns name. Thus, if you wanted to, for example, iterate over search
|
21
|
+
# results and output the name, you could do so without checking entity type
|
22
|
+
# first.
|
23
|
+
def name
|
24
|
+
if @namespace == "person"
|
25
|
+
@first_name + " " + @last_name
|
26
|
+
else
|
27
|
+
@name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(json)
|
32
|
+
@namespace = json["namespace"]
|
33
|
+
if @namespace == "person"
|
34
|
+
@first_name = json["first_name"]
|
35
|
+
@last_name = json["last_name"]
|
36
|
+
else
|
37
|
+
@name = json["name"]
|
38
|
+
end
|
39
|
+
@permalink = json["permalink"]
|
40
|
+
@crunchbase_url = json["crunchbase_url"]
|
41
|
+
@overview = json["overview"]
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns the entity associated with the search result, loading from
|
45
|
+
# memory if previously fetched, unless +force_reload+ is set to true.
|
46
|
+
def entity(force_reload=false)
|
47
|
+
return @entity unless @entity.nil? || force_reload
|
48
|
+
@entity = case @namespace
|
49
|
+
when "company"
|
50
|
+
Company.get(@permalink)
|
51
|
+
when "financial-organization"
|
52
|
+
FinancialOrganization.get(@permalink)
|
53
|
+
when "person"
|
54
|
+
Person.get(@permalink)
|
55
|
+
when "product"
|
56
|
+
Product.get(@permalink)
|
57
|
+
when "service-provider"
|
58
|
+
ServiceProvider.get(@permalink)
|
59
|
+
end
|
60
|
+
return @entity
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -12,6 +12,10 @@ module Crunchbase
|
|
12
12
|
s = ServiceProvider.new(j)
|
13
13
|
return s
|
14
14
|
end
|
15
|
+
|
16
|
+
def self.find(name)
|
17
|
+
get(API.permalink({name: name}, "service-providers")["permalink"])
|
18
|
+
end
|
15
19
|
|
16
20
|
def initialize(json)
|
17
21
|
@name = json["name"]
|
@@ -32,4 +36,4 @@ module Crunchbase
|
|
32
36
|
|
33
37
|
|
34
38
|
end
|
35
|
-
end
|
39
|
+
end
|
data/spec/crunchbase/api_spec.rb
CHANGED
@@ -23,5 +23,11 @@ module Crunchbase
|
|
23
23
|
c.name.should == "Adobe Systems"
|
24
24
|
end
|
25
25
|
|
26
|
+
it "should find a permalink from a well-formed search" do
|
27
|
+
j = API.permalink({name: "Accel Partners"}, "financial-organizations")
|
28
|
+
j.class.should == Hash
|
29
|
+
j["permalink"].should == 'accel-partners'
|
30
|
+
end
|
31
|
+
|
26
32
|
end
|
27
|
-
end
|
33
|
+
end
|
@@ -7,6 +7,11 @@ module Crunchbase
|
|
7
7
|
company = Company.get("facebook")
|
8
8
|
company.name.should == "Facebook"
|
9
9
|
end
|
10
|
+
|
11
|
+
it "should find companies by name" do
|
12
|
+
company = Company.find("Adobe Systems")
|
13
|
+
company.permalink.should == "adobe-systems"
|
14
|
+
end
|
10
15
|
|
11
16
|
it "should return date for founded" do
|
12
17
|
company = Company.new({"founded_year" => 2004, "founded_month" => 2,
|
@@ -24,4 +29,4 @@ module Crunchbase
|
|
24
29
|
|
25
30
|
|
26
31
|
end
|
27
|
-
end
|
32
|
+
end
|
@@ -7,6 +7,11 @@ module Crunchbase
|
|
7
7
|
finorg = FinancialOrganization.get("robin-hood-ventures")
|
8
8
|
finorg.name.should == "Robin Hood Ventures"
|
9
9
|
end
|
10
|
+
|
11
|
+
it "should find by name" do
|
12
|
+
f = FinancialOrganization.find("Accel Partners")
|
13
|
+
f.permalink.should == "accel-partners"
|
14
|
+
end
|
10
15
|
|
11
16
|
it "should return date for founded" do
|
12
17
|
finorg = FinancialOrganization.new({"founded_year" => 2004, "founded_month" => 2,
|
@@ -16,4 +21,4 @@ module Crunchbase
|
|
16
21
|
end
|
17
22
|
|
18
23
|
end
|
19
|
-
end
|
24
|
+
end
|
@@ -60,6 +60,11 @@ module Crunchbase
|
|
60
60
|
person = Person.get("steve-jobs")
|
61
61
|
person.first_name.should == "Steve"
|
62
62
|
end
|
63
|
+
|
64
|
+
it "should find a person by name" do
|
65
|
+
person = Person.find("Steve", "Jobs")
|
66
|
+
person.permalink.should == "steve-jobs"
|
67
|
+
end
|
63
68
|
|
64
69
|
it "should be equal to another with the same permalink and last updated" do
|
65
70
|
person = Person.get("steve-jobs")
|
@@ -68,4 +73,4 @@ module Crunchbase
|
|
68
73
|
end
|
69
74
|
|
70
75
|
end
|
71
|
-
end
|
76
|
+
end
|
@@ -7,6 +7,11 @@ module Crunchbase
|
|
7
7
|
product = Product.get("iphone")
|
8
8
|
product.name.should == "iPhone"
|
9
9
|
end
|
10
|
+
|
11
|
+
it "should find by name" do
|
12
|
+
product = Product.find("iPhone")
|
13
|
+
product.permalink.should == "iphone"
|
14
|
+
end
|
10
15
|
|
11
16
|
it "should return date for launched" do
|
12
17
|
product = Product.new({"launched_year" => 2004, "launched_month" => 2,
|
@@ -22,4 +27,4 @@ module Crunchbase
|
|
22
27
|
product.deadpooled.should === Date.new(2004, 2, 1)
|
23
28
|
end
|
24
29
|
end
|
25
|
-
end
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
module Crunchbase
|
5
|
+
describe SearchResult do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
@result = Search.find('google')[0]
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return the entity which is named" do
|
12
|
+
@result.name.should == @result.entity.name
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
module Crunchbase
|
5
|
+
describe Search do
|
6
|
+
|
7
|
+
it "should retrieve search results" do
|
8
|
+
s = Search.find('google')
|
9
|
+
s[0].class.should == SearchResult
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return higher search results" do
|
13
|
+
s = Search.find('google')
|
14
|
+
s[s.size/2].class.should == SearchResult
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return nil for array out of bounds" do
|
18
|
+
s = Search.find('google')
|
19
|
+
s[s.size].should be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -6,7 +6,12 @@ module Crunchbase
|
|
6
6
|
it "should pull from web api" do
|
7
7
|
sp = ServiceProvider.get("fox-rothschild")
|
8
8
|
sp.name.should == "Fox Rothschild"
|
9
|
-
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should find by name" do
|
12
|
+
sp = ServiceProvider.find("Fox Rothschild")
|
13
|
+
sp.permalink.should == "fox-rothschild"
|
14
|
+
end
|
10
15
|
|
11
16
|
end
|
12
|
-
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crunchbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-21 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70265569207100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70265569207100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70265569206160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70265569206160
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70265569205140 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70265569205140
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &70265569204040 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70265569204040
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdoc
|
60
|
-
requirement: &
|
60
|
+
requirement: &70265569202940 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70265569202940
|
69
69
|
description:
|
70
70
|
email: tyler.cunnion@gmail.com
|
71
71
|
executables: []
|
@@ -95,12 +95,16 @@ files:
|
|
95
95
|
- lib/crunchbase/relationships/firm_relationship.rb
|
96
96
|
- lib/crunchbase/relationships/person_relationship.rb
|
97
97
|
- lib/crunchbase/relationships/provider_relationship.rb
|
98
|
+
- lib/crunchbase/search.rb
|
99
|
+
- lib/crunchbase/search_result.rb
|
98
100
|
- lib/crunchbase/service_provider.rb
|
99
101
|
- spec/crunchbase/api_spec.rb
|
100
102
|
- spec/crunchbase/company_spec.rb
|
101
103
|
- spec/crunchbase/financial_organization_spec.rb
|
102
104
|
- spec/crunchbase/person_spec.rb
|
103
105
|
- spec/crunchbase/product_spec.rb
|
106
|
+
- spec/crunchbase/search_result_spec.rb
|
107
|
+
- spec/crunchbase/search_spec.rb
|
104
108
|
- spec/crunchbase/service_provider_spec.rb
|
105
109
|
- spec/fixtures/brad-fitzpatrick.js
|
106
110
|
- spec/fixtures/steve-jobs.js
|
@@ -120,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
124
|
version: '0'
|
121
125
|
segments:
|
122
126
|
- 0
|
123
|
-
hash:
|
127
|
+
hash: 4487821890368483707
|
124
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
129
|
none: false
|
126
130
|
requirements:
|