crunchbase-ruby-library 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/crunchbase/api.rb +7 -2
- data/lib/crunchbase/model.rb +1 -0
- data/lib/crunchbase/model/entity.rb +6 -0
- data/lib/crunchbase/model/funded_organization.rb +25 -0
- data/lib/crunchbase/model/funding_round.rb +2 -12
- data/lib/crunchbase/version.rb +1 -1
- data/spec/crunchbase/model/funding_round_spec.rb +39 -0
- metadata +6 -3
data/lib/crunchbase/api.rb
CHANGED
@@ -13,7 +13,7 @@ require 'timeout'
|
|
13
13
|
module Crunchbase
|
14
14
|
class API
|
15
15
|
|
16
|
-
SUPPORTED_ENTITIES = ['organizations', 'people', 'products', 'funding_rounds', 'acquisitions', 'ipos', 'locations', 'categories', 'offices', 'customers', 'degrees', 'experience', 'primary_affiliation', 'videos', 'founded_companies', 'primary_location', 'advisor_at']
|
16
|
+
SUPPORTED_ENTITIES = ['organizations', 'people', 'products', 'funding_rounds', 'funding-rounds', 'acquisitions', 'ipos', 'locations', 'categories', 'offices', 'customers', 'degrees', 'experience', 'primary_affiliation', 'videos', 'founded_companies', 'primary_location', 'advisor_at']
|
17
17
|
|
18
18
|
@timeout_limit = 60
|
19
19
|
@redirect_limit = 2
|
@@ -93,11 +93,16 @@ module Crunchbase
|
|
93
93
|
lists_for_category('organizations', permalink, category, options)
|
94
94
|
end
|
95
95
|
|
96
|
-
#
|
96
|
+
# Visit: https://api.crunchbase.com/v/#{version}/people/#{permalink}/#{category}?user_key=key
|
97
97
|
def self.person_lists(permalink, category, options)
|
98
98
|
lists_for_category('people', permalink, category, options)
|
99
99
|
end
|
100
100
|
|
101
|
+
# Visit: https://api.crunchbase.com/v/#{version}/funding-rounds/#{permalink}/#{category}?user_key=key
|
102
|
+
def self.funding_rounds_lists(permalink, category, options)
|
103
|
+
lists_for_category('funding-rounds', permalink, category, options)
|
104
|
+
end
|
105
|
+
|
101
106
|
def self.lists_for_category(classify_name, permalink, category, options)
|
102
107
|
options[:page] = 1 if options[:page].nil?
|
103
108
|
options[:order] = ORDER_CREATED_AT_ASC if options[:order].nil?
|
data/lib/crunchbase/model.rb
CHANGED
@@ -17,6 +17,7 @@ module Crunchbase
|
|
17
17
|
autoload :FoundedCompany, "crunchbase/model/founded_company"
|
18
18
|
autoload :Founder, "crunchbase/model/founder"
|
19
19
|
autoload :Fund, "crunchbase/model/fund"
|
20
|
+
autoload :FundedOrganization, "crunchbase/model/funded_organization"
|
20
21
|
autoload :FundingRound, "crunchbase/model/funding_round"
|
21
22
|
autoload :Headquarter, "crunchbase/model/headquarter"
|
22
23
|
autoload :Image, "crunchbase/model/image"
|
@@ -51,6 +51,12 @@ module Crunchbase::Model
|
|
51
51
|
return Crunchbase::API.person_lists(permalink, self::RESOURCE_LIST, options)
|
52
52
|
end
|
53
53
|
|
54
|
+
def self.funding_rounds_lists(permalink, options={})
|
55
|
+
options = options.merge({ model_name: self })
|
56
|
+
|
57
|
+
return Crunchbase::API.funding_rounds_lists(permalink, self::RESOURCE_LIST.gsub('_', '-'), options)
|
58
|
+
end
|
59
|
+
|
54
60
|
def fetch
|
55
61
|
fetch_object = get_fetch_object
|
56
62
|
return [] if fetch_object.empty?
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crunchbase::Model
|
4
|
+
class FundedOrganization < Crunchbase::Model::Entity
|
5
|
+
|
6
|
+
attr_reader :type, :name, :path, :created_at, :updated_at
|
7
|
+
|
8
|
+
def initialize(json)
|
9
|
+
property_keys.each { |v|
|
10
|
+
instance_variable_set("@#{v}", json[v] || nil)
|
11
|
+
}
|
12
|
+
|
13
|
+
%w[created_at updated_at].each { |v|
|
14
|
+
instance_variable_set("@#{v}", Time.at(json[v]))
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def property_keys
|
19
|
+
%w[
|
20
|
+
type name path created_at updated_at
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -4,6 +4,7 @@ module Crunchbase::Model
|
|
4
4
|
class FundingRound < Crunchbase::Model::Entity
|
5
5
|
|
6
6
|
RESOURCE_LIST = 'funding_rounds'
|
7
|
+
RESOURCE_NAME = 'funding-rounds'
|
7
8
|
|
8
9
|
attr_reader :api_path, :web_path, :funding_type, :series, :series_qualifier,
|
9
10
|
:announced_on, :announced_on_trust_code, :closed_on, :closed_on_trust_code,
|
@@ -21,7 +22,7 @@ module Crunchbase::Model
|
|
21
22
|
|
22
23
|
unless (relationships = json['relationships']).nil?
|
23
24
|
set_relationships_object(Crunchbase::Model::Investment, 'investments', relationships['investments'])
|
24
|
-
set_relationships_object(Crunchbase::Model::
|
25
|
+
set_relationships_object(Crunchbase::Model::FundedOrganization, 'funded_organization', relationships['funded_organization'])
|
25
26
|
set_relationships_object(Crunchbase::Model::Image, 'images', relationships['images'])
|
26
27
|
set_relationships_object(Crunchbase::Model::Video, 'videos', relationships['videos'])
|
27
28
|
set_relationships_object(Crunchbase::Model::New, 'news', relationships['news'])
|
@@ -43,16 +44,5 @@ module Crunchbase::Model
|
|
43
44
|
%w[ announced_on closed_on ]
|
44
45
|
end
|
45
46
|
|
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
47
|
end
|
58
48
|
end
|
data/lib/crunchbase/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "../..", "spec_helper.rb")
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
module Model
|
5
|
+
|
6
|
+
describe FundingRound, "#get" do
|
7
|
+
round = FundingRound.get('c31e2cc41e8f30c6da0aaf6b395469e5')
|
8
|
+
|
9
|
+
puts round.inspect
|
10
|
+
end
|
11
|
+
|
12
|
+
describe FundingRound, "#organization_lists" do
|
13
|
+
begin
|
14
|
+
results = FundingRound.organization_lists("xiaomi").results
|
15
|
+
results.collect {|e| puts e.funding_type }
|
16
|
+
|
17
|
+
rescue Exception => e
|
18
|
+
puts e.message
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe FundingRound, "get news" do
|
23
|
+
news = New.funding_rounds_lists('c31e2cc41e8f30c6da0aaf6b395469e5').results
|
24
|
+
puts news.map {|e| e.title }
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
describe FundingRound, "get images" do
|
29
|
+
images = Image.funding_rounds_lists('c31e2cc41e8f30c6da0aaf6b395469e5').results
|
30
|
+
puts images.map {|e| e.inspect }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe FundingRound, "get investments" do
|
34
|
+
investments = Investment.funding_rounds_lists('c31e2cc41e8f30c6da0aaf6b395469e5').results
|
35
|
+
puts investments.map {|e| e.inspect }
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crunchbase-ruby-library
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/crunchbase/model/founded_company.rb
|
109
109
|
- lib/crunchbase/model/founder.rb
|
110
110
|
- lib/crunchbase/model/fund.rb
|
111
|
+
- lib/crunchbase/model/funded_organization.rb
|
111
112
|
- lib/crunchbase/model/funding_round.rb
|
112
113
|
- lib/crunchbase/model/headquarter.rb
|
113
114
|
- lib/crunchbase/model/image.rb
|
@@ -140,6 +141,7 @@ files:
|
|
140
141
|
- lib/crunchbase/version.rb
|
141
142
|
- spec/crunchbase.yml.example
|
142
143
|
- spec/crunchbase/model/board_members_and_advisor_spec.rb
|
144
|
+
- spec/crunchbase/model/funding_round_spec.rb
|
143
145
|
- spec/crunchbase/model/office_spec.rb
|
144
146
|
- spec/crunchbase/model/organization_spec.rb
|
145
147
|
- spec/crunchbase/model/past_team_spec.rb
|
@@ -163,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
165
|
version: '0'
|
164
166
|
segments:
|
165
167
|
- 0
|
166
|
-
hash:
|
168
|
+
hash: 3314474323939257372
|
167
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
170
|
none: false
|
169
171
|
requirements:
|
@@ -172,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
174
|
version: '0'
|
173
175
|
segments:
|
174
176
|
- 0
|
175
|
-
hash:
|
177
|
+
hash: 3314474323939257372
|
176
178
|
requirements: []
|
177
179
|
rubyforge_project:
|
178
180
|
rubygems_version: 1.8.23.2
|
@@ -182,6 +184,7 @@ summary: Ruby wrapper for Crunchbase API version 3
|
|
182
184
|
test_files:
|
183
185
|
- spec/crunchbase.yml.example
|
184
186
|
- spec/crunchbase/model/board_members_and_advisor_spec.rb
|
187
|
+
- spec/crunchbase/model/funding_round_spec.rb
|
185
188
|
- spec/crunchbase/model/office_spec.rb
|
186
189
|
- spec/crunchbase/model/organization_spec.rb
|
187
190
|
- spec/crunchbase/model/past_team_spec.rb
|