crunchbase-ruby-library 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +24 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +102 -0
- data/Rakefile +2 -0
- data/crunchbase-ruby-library.gemspec +25 -0
- data/lib/crunchbase.rb +12 -0
- data/lib/crunchbase/api.rb +160 -0
- data/lib/crunchbase/exception.rb +18 -0
- data/lib/crunchbase/model.rb +49 -0
- data/lib/crunchbase/model/acquired_by.rb +7 -0
- data/lib/crunchbase/model/acquisition.rb +36 -0
- data/lib/crunchbase/model/address.rb +20 -0
- data/lib/crunchbase/model/advisory_role.rb +10 -0
- data/lib/crunchbase/model/board_members_and_advisor.rb +25 -0
- data/lib/crunchbase/model/category.rb +17 -0
- data/lib/crunchbase/model/competitor.rb +7 -0
- data/lib/crunchbase/model/current_team.rb +25 -0
- data/lib/crunchbase/model/customer.rb +7 -0
- data/lib/crunchbase/model/degree.rb +31 -0
- data/lib/crunchbase/model/entity.rb +134 -0
- data/lib/crunchbase/model/error.rb +14 -0
- data/lib/crunchbase/model/founded_company.rb +27 -0
- data/lib/crunchbase/model/founder.rb +9 -0
- data/lib/crunchbase/model/fund.rb +26 -0
- data/lib/crunchbase/model/funding_round.rb +58 -0
- data/lib/crunchbase/model/headquarter.rb +6 -0
- data/lib/crunchbase/model/image.rb +17 -0
- data/lib/crunchbase/model/investment.rb +27 -0
- data/lib/crunchbase/model/investor.rb +28 -0
- data/lib/crunchbase/model/ipo.rb +35 -0
- data/lib/crunchbase/model/job.rb +39 -0
- data/lib/crunchbase/model/location.rb +29 -0
- data/lib/crunchbase/model/member.rb +7 -0
- data/lib/crunchbase/model/membership.rb +28 -0
- data/lib/crunchbase/model/new.rb +21 -0
- data/lib/crunchbase/model/office.rb +9 -0
- data/lib/crunchbase/model/organization.rb +88 -0
- data/lib/crunchbase/model/organization_summary.rb +19 -0
- data/lib/crunchbase/model/owned_by.rb +27 -0
- data/lib/crunchbase/model/parent_location.rb +7 -0
- data/lib/crunchbase/model/past_team.rb +25 -0
- data/lib/crunchbase/model/person.rb +55 -0
- data/lib/crunchbase/model/person_summary.rb +23 -0
- data/lib/crunchbase/model/primary_affiliation.rb +22 -0
- data/lib/crunchbase/model/primary_image.rb +7 -0
- data/lib/crunchbase/model/primary_location.rb +17 -0
- data/lib/crunchbase/model/product.rb +47 -0
- data/lib/crunchbase/model/school.rb +6 -0
- data/lib/crunchbase/model/search.rb +50 -0
- data/lib/crunchbase/model/search_result.rb +10 -0
- data/lib/crunchbase/model/sub_organization.rb +9 -0
- data/lib/crunchbase/model/video.rb +17 -0
- data/lib/crunchbase/model/website.rb +17 -0
- data/lib/crunchbase/version.rb +3 -0
- data/spec/crunchbase.yml.example +2 -0
- data/spec/crunchbase/model/board_members_and_advisor_spec.rb +20 -0
- data/spec/crunchbase/model/office_spec.rb +17 -0
- data/spec/crunchbase/model/organization_spec.rb +60 -0
- data/spec/crunchbase/model/past_team_spec.rb +26 -0
- data/spec/crunchbase/model/person_spec.rb +28 -0
- data/spec/crunchbase/model/product_spec.rb +33 -0
- data/spec/crunchbase/model/search_spec.rb +50 -0
- data/spec/crunchbase/model/website_spec.rb +18 -0
- data/spec/spec_helper.rb +20 -0
- metadata +192 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class PersonSummary < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
attr_reader :permalink, :api_path, :web_path, :first_name, :last_name, :title,
|
7
|
+
:organization_permalink, :organization_api_path, :organization_web_path, :organization_name,
|
8
|
+
:profile_image_url, :homepage_url, :facebook_url, :twitter_url, :linkedin_url,
|
9
|
+
:city_name, :region_name, :country_code,
|
10
|
+
:created_at, :updated_at
|
11
|
+
|
12
|
+
def property_keys
|
13
|
+
%w[
|
14
|
+
permalink api_path web_path first_name last_name title
|
15
|
+
organization_permalink organization_api_path organization_web_path organization_name
|
16
|
+
profile_image_url homepage_url facebook_url twitter_url linkedin_url
|
17
|
+
city_name region_name country_code
|
18
|
+
created_at updated_at
|
19
|
+
]
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class PrimaryAffiliation < Crunchbase::Model::Job
|
5
|
+
|
6
|
+
attr_reader :organization
|
7
|
+
|
8
|
+
def initialize(json)
|
9
|
+
super
|
10
|
+
|
11
|
+
unless (relationships = json['relationships']).nil?
|
12
|
+
set_relationships_object(Crunchbase::Model::Organization, 'organization', relationships['organization'])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_relationships_object(object_name, key, item)
|
17
|
+
return unless item
|
18
|
+
|
19
|
+
instance_variable_set "@#{key}", ( object_name.new(item) || nil )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class PrimaryLocation < Crunchbase::Model::Location
|
5
|
+
|
6
|
+
attr_reader :parent_locations
|
7
|
+
|
8
|
+
def initialize(json)
|
9
|
+
super
|
10
|
+
|
11
|
+
unless (relationships = json['relationships']).nil?
|
12
|
+
set_relationships_object(Crunchbase::Model::ParentLocation, 'parent_locations', relationships['parent_locations'])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class Product < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
RESOURCE_LIST = RESOURCE_NAME = 'products'
|
7
|
+
|
8
|
+
attr_reader :permalink, :api_path, :web_path, :name, :also_known_as,
|
9
|
+
:lifecycle_stage, :short_description, :description,
|
10
|
+
:launched_on, :launched_on_trust_code, :closed_on, :closed_on_trust_code,
|
11
|
+
:homepage_url, :created_at, :updated_at
|
12
|
+
|
13
|
+
attr_reader :websites, :primary_image, :images, :images_total_items, :categories, :video, :news
|
14
|
+
|
15
|
+
attr_reader :websites_total_items, :primary_image_total_items, :categories_items, :video_total_items, :new_total_items
|
16
|
+
|
17
|
+
# attr_reader :owner, :competitors, :customers
|
18
|
+
|
19
|
+
# attr_reader :owner_total_items, :competitors_total_items, :customers_total_items
|
20
|
+
|
21
|
+
def initialize(json)
|
22
|
+
super
|
23
|
+
|
24
|
+
unless (relationships = json['relationships']).nil?
|
25
|
+
set_relationships_object(Crunchbase::Model::Category, 'categories', relationships['categories'])
|
26
|
+
set_relationships_object(Crunchbase::Model::PrimaryImage, 'primary_image', relationships['primary_image'])
|
27
|
+
set_relationships_object(Crunchbase::Model::Image, 'images', relationships['images'])
|
28
|
+
set_relationships_object(Crunchbase::Model::Video, 'video', relationships['video'])
|
29
|
+
set_relationships_object(Crunchbase::Model::New, 'news', relationships['news'])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def property_keys
|
34
|
+
%w[
|
35
|
+
permalink api_path web_path name also_known_as
|
36
|
+
lifecycle_stage short_description description
|
37
|
+
launched_on launched_on_trust_code closed_on closed_on_trust_code
|
38
|
+
homepage_url created_at updated_at
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
def date_keys
|
43
|
+
%w[launched_on closed_on]
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class Search < Crunchbase::Model::Entity
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
attr_reader :total_items, :per_page, :pages, :current_page, :prev_page_url, :next_page_url, :sort_order, :results
|
8
|
+
|
9
|
+
alias :length :total_items
|
10
|
+
alias :size :total_items
|
11
|
+
alias :items :results
|
12
|
+
|
13
|
+
def initialize(query, json, _model)
|
14
|
+
@query = query
|
15
|
+
@results = []
|
16
|
+
@total_items = 0
|
17
|
+
|
18
|
+
populate_results(json, _model) if json['error'].nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def populate_results(json, _model)
|
23
|
+
@results = json["items"].map{|r| _model.new(r)}
|
24
|
+
|
25
|
+
@total_items = json['paging']['total_items']
|
26
|
+
@per_page = json['paging']['items_per_page']
|
27
|
+
@pages = json['paging']['number_of_pages']
|
28
|
+
@current_page = json['paging']['current_page']
|
29
|
+
@prev_page_url = json['paging']['prev_page_url']
|
30
|
+
@next_page_url = json['paging']['next_page_url']
|
31
|
+
@sort_order = json['paging']['sort_order']
|
32
|
+
end
|
33
|
+
|
34
|
+
# Finds an entity by its name. Uses two HTTP requests; one to find the
|
35
|
+
# permalink, and another to request the actual entity.
|
36
|
+
def self.search(options, resource_list)
|
37
|
+
model_name = get_model_name(resource_list)
|
38
|
+
|
39
|
+
raise 'Unknown type error!' if model_name.nil?
|
40
|
+
|
41
|
+
return Search.new options, Crunchbase::API.search( options, resource_list ), model_name
|
42
|
+
end
|
43
|
+
|
44
|
+
# Factory method to return an instance from a permalink
|
45
|
+
def self.get(permalink)
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class Video < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'videos'
|
7
|
+
|
8
|
+
attr_reader :title, :service_name, :url, :created_at, :updated_at
|
9
|
+
|
10
|
+
def property_keys
|
11
|
+
%w[
|
12
|
+
title service_name url created_at updated_at
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class Website < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'websites'
|
7
|
+
|
8
|
+
attr_reader :website, :url, :created_at, :updated_at
|
9
|
+
|
10
|
+
def property_keys
|
11
|
+
%w[
|
12
|
+
website url created_at updated_at
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../..", "spec_helper.rb")
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
module Model
|
5
|
+
|
6
|
+
describe BoardMembersAndAdvisor do
|
7
|
+
begin
|
8
|
+
o = BoardMembersAndAdvisor.organization_lists("apple")
|
9
|
+
|
10
|
+
puts o.total_items
|
11
|
+
|
12
|
+
o.results.collect { |p| puts p.person.first_name }
|
13
|
+
|
14
|
+
rescue Exception => e
|
15
|
+
puts e.message
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../..", "spec_helper.rb")
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
module Model
|
5
|
+
|
6
|
+
describe Office, "#organization_lists" do
|
7
|
+
begin
|
8
|
+
results = Office.organization_lists("facebook").results
|
9
|
+
results.collect {|e| puts e.name }
|
10
|
+
|
11
|
+
rescue Exception => e
|
12
|
+
puts e.message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../..", "spec_helper.rb")
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
module Model
|
5
|
+
|
6
|
+
describe Organization do
|
7
|
+
|
8
|
+
before(:all) do
|
9
|
+
@organization = Organization.get("facebook")
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'show all products name' do
|
13
|
+
puts @organization.products.map { |i| i.name }.inspect
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'show all offices name' do
|
17
|
+
puts @organization.offices.map { |i| i.name }.inspect
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'show all funding_rounds funding_type' do
|
21
|
+
puts @organization.funding_rounds.map { |i| i.funding_type }.inspect
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'show all competitors name' do
|
25
|
+
puts @organization.competitors.map { |i| i.name }.inspect
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'show all investments money_invested' do
|
29
|
+
puts @organization.investments.map { |i| i.money_invested }.inspect
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'show all acquisitions acquiree name' do
|
33
|
+
puts @organization.acquisitions.map { |i| i.acquiree.name }.inspect
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'show all ipo funded_company name' do
|
37
|
+
puts "IPOs - #{@organization.ipo_total_items.nil?}"
|
38
|
+
puts @organization.ipo.map { |i| i.funded_company.name }.inspect unless @organization.ipo.nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
it "show all categories name" do
|
42
|
+
puts @organization.categories.map {|i| i.name }.inspect
|
43
|
+
end
|
44
|
+
|
45
|
+
it "show all news name" do
|
46
|
+
puts @organization.news.map {|i| i.title }.inspect
|
47
|
+
end
|
48
|
+
|
49
|
+
it "show all current_team members name" do
|
50
|
+
puts @organization.current_team.map {|i| [i.title, i.person.last_name] }.inspect
|
51
|
+
end
|
52
|
+
|
53
|
+
it "show all websites website" do
|
54
|
+
puts @organization.websites.map {|i| i.website }.inspect
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../..", "spec_helper.rb")
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
module Model
|
5
|
+
|
6
|
+
describe PastTeam do
|
7
|
+
|
8
|
+
before(:all) do
|
9
|
+
begin
|
10
|
+
@past_team = PastTeam.organization_lists("apple2")
|
11
|
+
rescue Exception => e
|
12
|
+
@past_team = nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'show past team results' do
|
17
|
+
unless @past_team.nil?
|
18
|
+
puts @past_team.total_items
|
19
|
+
|
20
|
+
puts @past_team.results.collect { |p| [p.title, p.person.first_name] }.inspect
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../..", "spec_helper.rb")
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
module Model
|
5
|
+
|
6
|
+
# describe Person, "#get" do
|
7
|
+
# begin
|
8
|
+
# person = Person.get("li-ka-shing")
|
9
|
+
|
10
|
+
# puts person.inspect
|
11
|
+
|
12
|
+
# rescue Exception => e
|
13
|
+
# puts e.message
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
|
17
|
+
describe Person, "#list" do
|
18
|
+
begin
|
19
|
+
person = Person.list( 1 )
|
20
|
+
puts person.results.map {|e| [e.first_name, e.last_name].join(', ') }.inspect
|
21
|
+
rescue Exception => e
|
22
|
+
puts e.message
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../..", "spec_helper.rb")
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
module Model
|
5
|
+
|
6
|
+
describe Product, "#get" do
|
7
|
+
begin
|
8
|
+
ps = Product.get("hiphop-virtual-machine")
|
9
|
+
|
10
|
+
puts ps.inspect
|
11
|
+
|
12
|
+
rescue Exception => e
|
13
|
+
puts e.message
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Product, "#organization_lists" do
|
18
|
+
# begin
|
19
|
+
# ps = Product.organization_lists("facebook")
|
20
|
+
|
21
|
+
# puts ps.total_items
|
22
|
+
|
23
|
+
# ps.results.each do |p|
|
24
|
+
# puts [p.permalink, p.name].inspect
|
25
|
+
# end
|
26
|
+
|
27
|
+
# rescue Exception => e
|
28
|
+
# puts e.message
|
29
|
+
# end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../..", "spec_helper.rb")
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
module Model
|
5
|
+
|
6
|
+
# Full text search of an Organization's name,
|
7
|
+
# aliases (i.e. previous names or "also known as"), and short description
|
8
|
+
describe Search, "Search organizations with -> query through crunchbase API" do
|
9
|
+
o = Search.search({query: "Google"}, 'organizations')
|
10
|
+
|
11
|
+
|
12
|
+
o.results.each do |i|
|
13
|
+
puts [i.name, i.permalink].inspect
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Full text search limited to name and aliases
|
18
|
+
describe Search, "Search organizations with -> name through crunchbase API" do
|
19
|
+
o = Search.search({name: "Google"}, 'organizations')
|
20
|
+
|
21
|
+
|
22
|
+
o.results.each do |i|
|
23
|
+
puts [i.name, i.permalink].inspect
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Text search of an Organization's domain_name (e.g. www.google.com)
|
28
|
+
describe Search, "Search organizations with -> domain_name through crunchbase API" do
|
29
|
+
o = Search.search({domain_name: "google.com"}, 'organizations')
|
30
|
+
|
31
|
+
|
32
|
+
o.results.each do |i|
|
33
|
+
puts [i.name, i.domain].inspect
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# A full-text query of name, title, and company
|
38
|
+
describe Search, "Search person with -> query through crunchbase API" do
|
39
|
+
o = Search.search({query: "encore"}, 'people')
|
40
|
+
|
41
|
+
|
42
|
+
o.results.each do |i|
|
43
|
+
puts [i.first_name, i.last_name].inspect
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|