crunchbase-ruby-library 0.0.1
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/.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,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class Address < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'addresses'
|
7
|
+
|
8
|
+
attr_reader :name, :street_1, :street_2, :city, :city_web_path, :region, :region_web_path,
|
9
|
+
:country, :country_web_path, :latitude, :longitude, :created_at, :updated_at
|
10
|
+
|
11
|
+
|
12
|
+
def property_keys
|
13
|
+
%w[
|
14
|
+
name street_1 street_2 city city_web_path region region_web_path
|
15
|
+
country country_web_path latitude longitude created_at updated_at
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class BoardMembersAndAdvisor < Crunchbase::Model::Job
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'board_members_and_advisors'
|
7
|
+
|
8
|
+
attr_reader :person
|
9
|
+
|
10
|
+
def initialize(json)
|
11
|
+
super
|
12
|
+
|
13
|
+
unless (relationships = json['relationships']).nil?
|
14
|
+
set_relationships_object(Crunchbase::Model::Person, 'person', relationships['person'])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_relationships_object(object_name, key, item)
|
19
|
+
return unless item
|
20
|
+
|
21
|
+
instance_variable_set "@#{key}", ( object_name.new(item) || nil )
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class Category < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'categories'
|
7
|
+
|
8
|
+
attr_reader :web_path, :name, :organizations_in_category, :products_in_category, :created_at, :updated_at
|
9
|
+
|
10
|
+
def property_keys
|
11
|
+
%w[
|
12
|
+
web_path name organizations_in_category products_in_category created_at updated_at
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class CurrentTeam < Crunchbase::Model::Job
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'current_team'
|
7
|
+
|
8
|
+
attr_reader :person
|
9
|
+
|
10
|
+
def initialize(json)
|
11
|
+
super
|
12
|
+
|
13
|
+
unless (relationships = json['relationships']).nil?
|
14
|
+
set_relationships_object(Crunchbase::Model::Person, 'person', relationships['person'])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_relationships_object(object_name, key, item)
|
19
|
+
return unless item
|
20
|
+
|
21
|
+
instance_variable_set "@#{key}", ( object_name.new(item) || nil )
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class Degree < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'degrees'
|
7
|
+
|
8
|
+
attr_reader :degree_type_name, :degree_subject, :started_on, :started_on_trust_code, :is_completed,
|
9
|
+
:completed_on, :completed_on_trust_code,
|
10
|
+
:created_at, :updated_at
|
11
|
+
|
12
|
+
attr_reader :school
|
13
|
+
|
14
|
+
def initialize(json)
|
15
|
+
super
|
16
|
+
|
17
|
+
unless (relationships = json['relationships']).nil?
|
18
|
+
instance_relationships_object(Crunchbase::Model::School, 'school', relationships['school'])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def property_keys
|
23
|
+
%w[
|
24
|
+
degree_type_name degree_subject started_on started_on_trust_code is_completed
|
25
|
+
completed_on completed_on_trust_code
|
26
|
+
created_at updated_at
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class Entity
|
5
|
+
|
6
|
+
attr_reader :type_name, :uuid
|
7
|
+
|
8
|
+
def initialize(json)
|
9
|
+
instance_variable_set("@type_name", json['type'] || nil)
|
10
|
+
instance_variable_set("@uuid", json['uuid'] || nil)
|
11
|
+
|
12
|
+
property_keys.each { |v|
|
13
|
+
instance_variable_set("@#{v}", json['properties'][v] || nil)
|
14
|
+
}
|
15
|
+
|
16
|
+
date_keys.each { |v|
|
17
|
+
instance_variable_set("@#{v}", json['properties'][v].nil? ? nil : Date.parse(json['properties'][v]))
|
18
|
+
}
|
19
|
+
|
20
|
+
%w[created_at updated_at].each { |v|
|
21
|
+
if json['properties'][v].kind_of?(String)
|
22
|
+
instance_variable_set( "@#{v}", begin Time.parse(json['properties'][v]) rescue nil end )
|
23
|
+
else
|
24
|
+
instance_variable_set( "@#{v}", begin Time.at(json['properties'][v]) rescue nil end )
|
25
|
+
end
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Factory method to return an instance from a permalink
|
30
|
+
def self.get(permalink)
|
31
|
+
result = Crunchbase::API.single_entity(permalink, self::RESOURCE_NAME)
|
32
|
+
|
33
|
+
return self.new( result )
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.list(page=nil)
|
37
|
+
model_name = get_model_name(self::RESOURCE_LIST)
|
38
|
+
|
39
|
+
return Crunchbase::API.list( { page: page, model_name: model_name }, self::RESOURCE_LIST )
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.organization_lists(permalink, options={})
|
43
|
+
options = options.merge({ model_name: self })
|
44
|
+
|
45
|
+
return Crunchbase::API.organization_lists(permalink, self::RESOURCE_LIST, options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.person_lists(permalink, options={})
|
49
|
+
options = options.merge({ model_name: self })
|
50
|
+
|
51
|
+
return Crunchbase::API.person_lists(permalink, self::RESOURCE_LIST, options)
|
52
|
+
end
|
53
|
+
|
54
|
+
def fetch
|
55
|
+
fetch_object = get_fetch_object
|
56
|
+
return [] if fetch_object.empty?
|
57
|
+
|
58
|
+
return fetch_object[0].new API.fetch(self.permalink, fetch_object[1])
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.array_from_list(list)
|
62
|
+
return [] if list.nil?
|
63
|
+
|
64
|
+
list['items'].map do |l|
|
65
|
+
self.new l if l.kind_of?(Hash)
|
66
|
+
end.compact
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.parsing_from_list(list)
|
70
|
+
return [] if list.nil?
|
71
|
+
|
72
|
+
list.map do |l|
|
73
|
+
self.new l if l.kind_of?(Hash)
|
74
|
+
end.compact
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.total_items_from_list(list)
|
78
|
+
return 0 if list.nil?
|
79
|
+
|
80
|
+
list['paging']['total_items']
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def property_keys
|
86
|
+
[]
|
87
|
+
end
|
88
|
+
|
89
|
+
def date_keys
|
90
|
+
[]
|
91
|
+
end
|
92
|
+
|
93
|
+
def set_relationships_object(object_name, key, list)
|
94
|
+
return unless list
|
95
|
+
|
96
|
+
one_to_one(object_name, key, list['item']) if list['item']
|
97
|
+
one_to_many(object_name, key, list) if list['items']
|
98
|
+
end
|
99
|
+
|
100
|
+
def one_to_one(object_name, key, item)
|
101
|
+
return unless item
|
102
|
+
|
103
|
+
instance_variable_set "@#{key}", ( object_name.new( item ) || nil )
|
104
|
+
instance_variable_set "@#{key}_total_items", (item ? 1 : 0)
|
105
|
+
end
|
106
|
+
|
107
|
+
def one_to_many(object_name, key, list)
|
108
|
+
return unless list['items'].respond_to?(:each)
|
109
|
+
|
110
|
+
instance_variable_set "@#{key}", list['items'].inject([]) { |v, i| v << object_name.new(i) }
|
111
|
+
instance_variable_set "@#{key}_total_items", list['paging']['total_items']
|
112
|
+
end
|
113
|
+
|
114
|
+
def instance_relationships_object(object_name, key, item)
|
115
|
+
return unless item
|
116
|
+
|
117
|
+
instance_variable_set "@#{key}", ( object_name.new(item) || nil )
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.get_model_name(resource_list)
|
121
|
+
return nil unless ['organizations', 'people'].include?(resource_list)
|
122
|
+
|
123
|
+
case resource_list
|
124
|
+
when 'organizations'
|
125
|
+
OrganizationSummary
|
126
|
+
when 'people'
|
127
|
+
PersonSummary
|
128
|
+
else
|
129
|
+
nil
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class FoundedCompany < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'founded_companies'
|
7
|
+
|
8
|
+
attr_reader :type, :name, :path, :created_at, :updated_at
|
9
|
+
|
10
|
+
def initialize(json)
|
11
|
+
property_keys.each { |v|
|
12
|
+
instance_variable_set("@#{v}", json[v] || nil)
|
13
|
+
}
|
14
|
+
|
15
|
+
%w[created_at updated_at].each { |v|
|
16
|
+
instance_variable_set("@#{v}", Time.at(json[v]))
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def property_keys
|
21
|
+
%w[
|
22
|
+
type name path created_at updated_at
|
23
|
+
]
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class Fund < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'funds'
|
7
|
+
|
8
|
+
attr_reader :api_path, :web_path, :name, :announced_on, :announced_on_trust_code, :money_raised, :money_raised_currency_code, :money_raised_usd, :created_at, :updated_at
|
9
|
+
|
10
|
+
# attr_reader :venture_firm, :investor, :images, :videos, :news
|
11
|
+
|
12
|
+
# attr_reader :venture_firm_total_items, :investor_total_items, :images_total_items, :videos_total_items, :news_total_items
|
13
|
+
|
14
|
+
def property_keys
|
15
|
+
%w[
|
16
|
+
api_path web_path name announced_on announced_on_trust_code
|
17
|
+
money_raised money_raised_currency_code money_raised_usd created_at updated_at
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
def date_keys
|
22
|
+
%w[ announced_on ]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class FundingRound < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'funding_rounds'
|
7
|
+
|
8
|
+
attr_reader :api_path, :web_path, :funding_type, :series, :series_qualifier,
|
9
|
+
:announced_on, :announced_on_trust_code, :closed_on, :closed_on_trust_code,
|
10
|
+
:money_raised, :money_raised_currency_code, :money_raised_usd,
|
11
|
+
:target_money_raised, :target_money_raised_currency_code, :target_money_raised_usd,
|
12
|
+
:created_at, :updated_at
|
13
|
+
|
14
|
+
attr_reader :investments, :funded_organization, :images, :videos, :news
|
15
|
+
|
16
|
+
attr_reader :investments_total_items, :funded_organization_total_items, :images_total_items,
|
17
|
+
:videos_total_items, :news_total_items
|
18
|
+
|
19
|
+
def initialize(json)
|
20
|
+
super
|
21
|
+
|
22
|
+
unless (relationships = json['relationships']).nil?
|
23
|
+
set_relationships_object(Crunchbase::Model::Investment, 'investments', relationships['investments'])
|
24
|
+
set_relationships_object(Crunchbase::Model::Organization, 'funded_organization', relationships['funded_organization'])
|
25
|
+
set_relationships_object(Crunchbase::Model::Image, 'images', relationships['images'])
|
26
|
+
set_relationships_object(Crunchbase::Model::Video, 'videos', relationships['videos'])
|
27
|
+
set_relationships_object(Crunchbase::Model::New, 'news', relationships['news'])
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def property_keys
|
33
|
+
%w[
|
34
|
+
api_path web_path funding_type series series_qualifier
|
35
|
+
announced_on announced_on_trust_code closed_on closed_on_trust_code
|
36
|
+
money_raised money_raised_currency_code money_raised_usd
|
37
|
+
target_money_raised target_money_raised_currency_code target_money_raised_usd
|
38
|
+
created_at updated_at
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
def date_keys
|
43
|
+
%w[ announced_on closed_on ]
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def set_relationships_object(object_name, key, item)
|
48
|
+
return unless item
|
49
|
+
|
50
|
+
instance_variable_set "@#{key}", ( object_name.new(item) || nil )
|
51
|
+
instance_variable_set "@#{key}_total_items", 1
|
52
|
+
|
53
|
+
super
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class Image < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
RESOURCE_LIST = 'images'
|
7
|
+
|
8
|
+
attr_reader :asset_path, :asset_url, :content_type, :height, :width, :filesize, :created_at, :updated_at
|
9
|
+
|
10
|
+
def property_keys
|
11
|
+
%w[
|
12
|
+
asset_url asset_path content_type height width filesize created_at updated_at
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|