crunchbase-ruby-library 0.3.6 → 0.3.7

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.
Files changed (67) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +0 -65
  3. data/.rubocop_todo.yml +54 -16
  4. data/Gemfile +1 -0
  5. data/Rakefile +1 -0
  6. data/bin/console +1 -1
  7. data/crunchbase-ruby-library.gemspec +2 -2
  8. data/lib/crunchbase.rb +1 -0
  9. data/lib/crunchbase/api.rb +1 -0
  10. data/lib/crunchbase/client.rb +1 -0
  11. data/lib/crunchbase/model/acquired_by.rb +0 -1
  12. data/lib/crunchbase/model/acquiree.rb +0 -1
  13. data/lib/crunchbase/model/acquirer.rb +0 -1
  14. data/lib/crunchbase/model/acquisition.rb +0 -1
  15. data/lib/crunchbase/model/address.rb +0 -1
  16. data/lib/crunchbase/model/advisory_role.rb +0 -1
  17. data/lib/crunchbase/model/batch_search.rb +0 -1
  18. data/lib/crunchbase/model/board_members_and_advisor.rb +0 -1
  19. data/lib/crunchbase/model/category.rb +0 -1
  20. data/lib/crunchbase/model/competitor.rb +0 -1
  21. data/lib/crunchbase/model/current_team.rb +0 -1
  22. data/lib/crunchbase/model/customer.rb +0 -1
  23. data/lib/crunchbase/model/degree.rb +3 -4
  24. data/lib/crunchbase/model/entity.rb +8 -5
  25. data/lib/crunchbase/model/error.rb +0 -1
  26. data/lib/crunchbase/model/founded_company.rb +0 -1
  27. data/lib/crunchbase/model/founder.rb +0 -1
  28. data/lib/crunchbase/model/fund.rb +1 -0
  29. data/lib/crunchbase/model/fund_raise.rb +1 -0
  30. data/lib/crunchbase/model/funding_round.rb +1 -1
  31. data/lib/crunchbase/model/headquarter.rb +0 -1
  32. data/lib/crunchbase/model/image.rb +0 -1
  33. data/lib/crunchbase/model/investment.rb +0 -1
  34. data/lib/crunchbase/model/investor.rb +0 -1
  35. data/lib/crunchbase/model/ipo.rb +0 -1
  36. data/lib/crunchbase/model/job.rb +8 -7
  37. data/lib/crunchbase/model/location.rb +0 -1
  38. data/lib/crunchbase/model/member.rb +0 -1
  39. data/lib/crunchbase/model/membership.rb +0 -1
  40. data/lib/crunchbase/model/new.rb +0 -1
  41. data/lib/crunchbase/model/office.rb +0 -1
  42. data/lib/crunchbase/model/organization.rb +14 -16
  43. data/lib/crunchbase/model/organization_summary.rb +0 -1
  44. data/lib/crunchbase/model/owned_by.rb +0 -1
  45. data/lib/crunchbase/model/parent_location.rb +0 -1
  46. data/lib/crunchbase/model/past_team.rb +0 -1
  47. data/lib/crunchbase/model/person.rb +9 -8
  48. data/lib/crunchbase/model/person_summary.rb +0 -1
  49. data/lib/crunchbase/model/primary_affiliation.rb +3 -4
  50. data/lib/crunchbase/model/primary_image.rb +0 -1
  51. data/lib/crunchbase/model/primary_location.rb +0 -1
  52. data/lib/crunchbase/model/product.rb +0 -1
  53. data/lib/crunchbase/model/product_summary.rb +1 -0
  54. data/lib/crunchbase/model/school.rb +0 -1
  55. data/lib/crunchbase/model/search.rb +0 -1
  56. data/lib/crunchbase/model/search_result.rb +1 -3
  57. data/lib/crunchbase/model/simple_organization.rb +0 -1
  58. data/lib/crunchbase/model/sub_organization.rb +0 -1
  59. data/lib/crunchbase/model/video.rb +0 -1
  60. data/lib/crunchbase/model/website.rb +0 -1
  61. data/lib/crunchbase/version.rb +1 -1
  62. data/spec/crunchbase/data/organizations/crunchbase.json +2853 -1344
  63. data/spec/crunchbase/model/funding_round_spec.rb +2 -2
  64. data/spec/crunchbase/model/organization_spec.rb +170 -146
  65. data/spec/crunchbase/support/api_helper.rb +8 -5
  66. data/spec/spec_helper.rb +1 -0
  67. metadata +5 -6
@@ -56,8 +56,8 @@ module Crunchbase
56
56
  first_investment = funding_round.investments[0]
57
57
 
58
58
  expect(first_investment.investors.nil?).to be_falsy
59
- expect(first_investment.investors.name).to eq("DST Global")
60
- expect(first_investment.investors.permalink).to eq("digital-sky-technologies-fo")
59
+ expect(first_investment.investors.name).to eq('DST Global')
60
+ expect(first_investment.investors.permalink).to eq('digital-sky-technologies-fo')
61
61
  end
62
62
 
63
63
  it 'should return 2 investors of founding round' do
@@ -1,196 +1,220 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # disabled ModuleLength
4
3
  module Crunchbase
5
4
  module Model
6
5
  RSpec.describe Organization do
7
- let(:without_relationship_json_data) { parse_json('organizations', 'facebook-without-relationships') }
8
- let(:with_relationship_json_data) { parse_json('organizations', 'facebook') }
9
- let(:ekohe_data) { parse_json('organizations', 'ekohe') }
6
+ context 'facebook' do
7
+ let(:without_relationship_json_data) { parse_json('organizations', 'facebook-without-relationships') }
8
+ let(:with_relationship_json_data) { parse_json('organizations', 'facebook') }
9
+ let(:ekohe_data) { parse_json('organizations', 'ekohe') }
10
10
 
11
- context 'facebook without relationships data' do
12
- let(:without_organization) { Organization.get('facebook') }
11
+ context 'without relationships data' do
12
+ let(:without_organization) { Organization.get('facebook') }
13
13
 
14
- before :each do
15
- result = Organization.new(without_relationship_json_data)
14
+ before :each do
15
+ result = Organization.new(without_relationship_json_data)
16
16
 
17
- allow(Organization).to receive(:get).and_return(result)
18
- end
17
+ allow(Organization).to receive(:get).and_return(result)
18
+ end
19
19
 
20
- it 'should return facebook and Facebook from API' do
21
- expect(without_organization.permalink).to eq('facebook')
22
- expect(without_organization.name).to eq('Facebook')
23
- end
20
+ it 'should return facebook and Facebook from API' do
21
+ expect(without_organization.permalink).to eq('facebook')
22
+ expect(without_organization.name).to eq('Facebook')
23
+ expect(without_organization.rank).to eq(nil)
24
+ end
24
25
 
25
- it 'should return nil when without relationships' do
26
- expect(without_organization.products.nil?).to be_truthy
27
- expect(without_organization.offices.nil?).to be_truthy
28
- expect(without_organization.headquarters.nil?).to be_truthy
29
- expect(without_organization.funding_rounds.nil?).to be_truthy
30
- expect(without_organization.competitors.nil?).to be_truthy
31
- expect(without_organization.investments.nil?).to be_truthy
32
- expect(without_organization.acquisitions.nil?).to be_truthy
33
- expect(without_organization.ipo.nil?).to be_truthy
34
- expect(without_organization.categories.nil?).to be_truthy
35
- expect(without_organization.news.nil?).to be_truthy
36
- expect(without_organization.current_team.nil?).to be_truthy
37
- expect(without_organization.websites.nil?).to be_truthy
38
- expect(without_organization.founders.nil?).to be_truthy
39
- expect(without_organization.past_team.nil?).to be_truthy
40
- expect(without_organization.board_members_and_advisors.nil?).to be_truthy
41
- expect(without_organization.featured_team.nil?).to be_truthy
26
+ it 'should return nil when without relationships' do
27
+ expect(without_organization.products.nil?).to be_truthy
28
+ expect(without_organization.offices.nil?).to be_truthy
29
+ expect(without_organization.headquarters.nil?).to be_truthy
30
+ expect(without_organization.funding_rounds.nil?).to be_truthy
31
+ expect(without_organization.competitors.nil?).to be_truthy
32
+ expect(without_organization.investments.nil?).to be_truthy
33
+ expect(without_organization.acquisitions.nil?).to be_truthy
34
+ expect(without_organization.ipo.nil?).to be_truthy
35
+ expect(without_organization.categories.nil?).to be_truthy
36
+ expect(without_organization.news.nil?).to be_truthy
37
+ expect(without_organization.current_team.nil?).to be_truthy
38
+ expect(without_organization.websites.nil?).to be_truthy
39
+ expect(without_organization.founders.nil?).to be_truthy
40
+ expect(without_organization.past_team.nil?).to be_truthy
41
+ expect(without_organization.board_members_and_advisors.nil?).to be_truthy
42
+ expect(without_organization.featured_team.nil?).to be_truthy
43
+ end
42
44
  end
43
- end
44
-
45
- context 'facebook with relationships data' do
46
- let(:organization) { Organization.get('facebook') }
47
-
48
- before :each do
49
- result = Organization.new(with_relationship_json_data)
50
45
 
51
- allow(Organization).to receive(:get).and_return(result)
52
- end
46
+ context 'facebook with relationships data' do
47
+ let(:organization) { Organization.get('facebook') }
53
48
 
54
- it 'should return facebook and Facebook from API' do
55
- expect(organization.permalink).to eq('facebook')
56
- expect(organization.name).to eq('Facebook')
57
- end
49
+ before :each do
50
+ result = Organization.new(with_relationship_json_data)
58
51
 
59
- it 'should return one primary_image' do
60
- expect(organization.primary_image.nil?).to be_falsy
61
- expect(organization.primary_image_total_items).to eq(1)
62
- end
52
+ allow(Organization).to receive(:get).and_return(result)
53
+ end
63
54
 
64
- it 'should return 0 of products and competitors' do
65
- expect(organization.products.size).to eq(0)
66
- expect(organization.competitors.size).to eq(0)
67
- end
55
+ it 'should return facebook and Facebook from API' do
56
+ expect(organization.permalink).to eq('facebook')
57
+ expect(organization.name).to eq('Facebook')
58
+ end
68
59
 
69
- it 'should return 1 of offices - OneToOne' do
70
- expect(organization.offices.class).to eq(Office)
71
- expect(organization.offices.nil?).to be_falsy
72
- end
60
+ it 'should return one primary_image' do
61
+ expect(organization.primary_image.nil?).to be_falsy
62
+ expect(organization.primary_image_total_items).to eq(1)
63
+ end
73
64
 
74
- it 'should return 1 of headquarters - OneToOne' do
75
- expect(organization.headquarters.class).to eq(Headquarter)
76
- expect(organization.headquarters.nil?).to be_falsy
77
- end
65
+ it 'should return 0 of products and competitors' do
66
+ expect(organization.products.size).to eq(0)
67
+ expect(organization.competitors.size).to eq(0)
68
+ end
78
69
 
79
- it 'should return 10 of funding_rounds' do
80
- expect(organization.funding_rounds.size).to eq(10)
81
- end
70
+ it 'should return 1 of offices - OneToOne' do
71
+ expect(organization.offices.class).to eq(Office)
72
+ expect(organization.offices.nil?).to be_falsy
73
+ end
82
74
 
83
- it 'should return 10 of investments' do
84
- expect(organization.investments.size).to eq(10)
85
- end
75
+ it 'should return 1 of headquarters - OneToOne' do
76
+ expect(organization.headquarters.class).to eq(Headquarter)
77
+ expect(organization.headquarters.nil?).to be_falsy
78
+ end
86
79
 
87
- it 'should return 10 of acquisitions' do
88
- expect(organization.acquisitions.size).to eq(10)
89
- end
80
+ it 'should return 10 of funding_rounds' do
81
+ expect(organization.funding_rounds.size).to eq(10)
82
+ end
90
83
 
91
- it 'should return ipo relationship' do
92
- expect(organization.ipo.nil?).to be_falsy
93
- end
84
+ it 'should return 10 of investments' do
85
+ expect(organization.investments.size).to eq(10)
86
+ end
94
87
 
95
- it 'should return 3 of categories' do
96
- expect(organization.categories.size).to eq(3)
97
- end
88
+ it 'should return 10 of acquisitions' do
89
+ expect(organization.acquisitions.size).to eq(10)
90
+ end
98
91
 
99
- it 'should return 0 of videos' do
100
- expect(organization.videos.size).to eq(0)
101
- expect(organization.videos_total_items).to eq(0)
102
- end
92
+ it 'should return ipo relationship' do
93
+ expect(organization.ipo.nil?).to be_falsy
94
+ end
103
95
 
104
- it 'should return 10 of news' do
105
- expect(organization.news.size).to eq(10)
106
- expect(organization.news_total_items).to eq(263177)
107
- end
96
+ it 'should return 3 of categories' do
97
+ expect(organization.categories.size).to eq(3)
98
+ end
108
99
 
109
- it 'should return 10 of current_team' do
110
- expect(organization.current_team.size).to eq(10)
111
- end
100
+ it 'should return 0 of videos' do
101
+ expect(organization.videos.size).to eq(0)
102
+ expect(organization.videos_total_items).to eq(0)
103
+ end
112
104
 
113
- it 'should return 4 of websites' do
114
- expect(organization.websites.size).to eq(4)
115
- end
105
+ it 'should return 10 of news' do
106
+ expect(organization.news.size).to eq(10)
107
+ expect(organization.news_total_items).to eq(263177)
108
+ end
116
109
 
117
- it 'should return 10 of investors item and total pages count 20' do
118
- expect(organization.investors.size).to eq(10)
119
- expect(organization.investors_total_items).to eq(20)
120
- end
110
+ it 'should return 10 of current_team' do
111
+ expect(organization.current_team.size).to eq(10)
112
+ end
121
113
 
122
- it 'should return 5 of founders' do
123
- expect(organization.founders.size).to eq(5)
124
- end
114
+ it 'should return 4 of websites' do
115
+ expect(organization.websites.size).to eq(4)
116
+ end
125
117
 
126
- it 'should return 10 of past_team and total 420 of past team' do
127
- expect(organization.past_team_total_items).to eq(420)
128
- expect(organization.past_team.size).to eq(10)
129
- end
118
+ it 'should return 10 of investors item and total pages count 20' do
119
+ expect(organization.investors.size).to eq(10)
120
+ expect(organization.investors_total_items).to eq(20)
121
+ end
130
122
 
131
- it 'should return the first past_team information' do
132
- first_member = organization.past_team[0]
123
+ it 'should return 5 of founders' do
124
+ expect(organization.founders.size).to eq(5)
125
+ end
133
126
 
134
- expect(first_member.title).to eq('Software Engineer')
135
- expect(first_member.uuid).to eq('009b372b0ee6bf03f60346b3a1730f41')
136
- expect(first_member.person.first_name).to eq('Perry')
137
- expect(first_member.person.last_name).to eq('Tam')
138
- expect(first_member.person.permalink).to eq('perry-tam')
139
- end
127
+ it 'should return 10 of past_team and total 420 of past team' do
128
+ expect(organization.past_team_total_items).to eq(420)
129
+ expect(organization.past_team.size).to eq(10)
130
+ end
140
131
 
141
- it 'should return 10 of board_members_and_advisors' do
142
- expect(organization.board_members_and_advisors_total_items).to eq(10)
143
- expect(organization.board_members_and_advisors.size).to eq(10)
144
- end
132
+ it 'should return the first past_team information' do
133
+ first_member = organization.past_team[0]
145
134
 
146
- it 'should return 6 of featured_team' do
147
- expect(organization.featured_team_total_items).to eq(6)
148
- expect(organization.featured_team.size).to eq(6)
149
- end
135
+ expect(first_member.title).to eq('Software Engineer')
136
+ expect(first_member.uuid).to eq('009b372b0ee6bf03f60346b3a1730f41')
137
+ expect(first_member.person.first_name).to eq('Perry')
138
+ expect(first_member.person.last_name).to eq('Tam')
139
+ expect(first_member.person.permalink).to eq('perry-tam')
140
+ end
150
141
 
151
- context 'funding_rounds' do
152
- it 'should return correctly data of the first funding round' do
153
- first_funding_round = organization.funding_rounds[0]
142
+ it 'should return 10 of board_members_and_advisors' do
143
+ expect(organization.board_members_and_advisors_total_items).to eq(10)
144
+ expect(organization.board_members_and_advisors.size).to eq(10)
145
+ end
154
146
 
155
- expect(first_funding_round.uuid).to eq('37bd05f961af726ba3c1b279da842805')
156
- expect(first_funding_round.funding_type).to eq('private_equity')
157
- expect(first_funding_round.announced_on).to eq(Date.parse('2011-01-21'))
158
- expect(first_funding_round.money_raised_currency_code).to eq('USD')
159
- expect(first_funding_round.money_raised).to eq(1500000000)
160
- expect(first_funding_round.money_raised_usd).to eq(1500000000)
161
- expect(first_funding_round.investments.size).to eq(2)
147
+ it 'should return 6 of featured_team' do
148
+ expect(organization.featured_team_total_items).to eq(6)
149
+ expect(organization.featured_team.size).to eq(6)
150
+ end
162
151
 
163
- expect(first_funding_round.investments[0].investors.name).to eq('DST Global')
164
- expect(first_funding_round.investments[0].partners.size).to eq(1)
152
+ context 'funding_rounds' do
153
+ it 'should return correctly data of the first funding round' do
154
+ first_funding_round = organization.funding_rounds[0]
155
+
156
+ expect(first_funding_round.uuid).to eq('37bd05f961af726ba3c1b279da842805')
157
+ expect(first_funding_round.funding_type).to eq('private_equity')
158
+ expect(first_funding_round.announced_on).to eq(Date.parse('2011-01-21'))
159
+ expect(first_funding_round.money_raised_currency_code).to eq('USD')
160
+ expect(first_funding_round.money_raised).to eq(1500000000)
161
+ expect(first_funding_round.money_raised_usd).to eq(1500000000)
162
+ expect(first_funding_round.investments.size).to eq(2)
163
+
164
+ expect(first_funding_round.investments[0].investors.name).to eq('DST Global')
165
+ expect(first_funding_round.investments[0].partners.size).to eq(1)
166
+ end
165
167
  end
166
168
  end
167
- end
168
169
 
169
- context 'ekohe data' do
170
- let(:ekohe) { Organization.get('ekohe') }
170
+ context 'ekohe data' do
171
+ let(:ekohe) { Organization.get('ekohe') }
171
172
 
172
- before :each do
173
- result = Organization.new(ekohe_data)
173
+ before :each do
174
+ result = Organization.new(ekohe_data)
174
175
 
175
- allow(Organization).to receive(:get).and_return(result)
176
- end
176
+ allow(Organization).to receive(:get).and_return(result)
177
+ end
177
178
 
178
- it 'should return ekohe information' do
179
- expect(ekohe.name).to eq('Ekohe')
180
- expect(ekohe.permalink).to eq('ekohe')
179
+ it 'should return ekohe information' do
180
+ expect(ekohe.name).to eq('Ekohe')
181
+ expect(ekohe.permalink).to eq('ekohe')
182
+ end
183
+
184
+ it 'should return ekohe relationships data' do
185
+ expect(ekohe.acquired_by.nil?).to be_truthy
186
+ expect(ekohe.products.empty?).to be_truthy
187
+ end
181
188
  end
182
189
 
183
- it 'should return ekohe relationships data' do
184
- expect(ekohe.acquired_by.nil?).to be_truthy
185
- expect(ekohe.products.empty?).to be_truthy
190
+ context 'mx-media-llc data' do
191
+ it 'should return Crunchbase::Exception with 404 as results' do
192
+ expect do
193
+ parse_json('organizations', 'mx-media-llc')
194
+ end.to raise_error(Crunchbase::Exception)
195
+ end
186
196
  end
187
197
  end
188
198
 
189
- context 'mx-media-llc data' do
190
- it 'should return Crunchbase::Exception with 404 as results' do
191
- expect do
192
- parse_json('organizations', 'mx-media-llc')
193
- end.to raise_error(Crunchbase::Exception)
199
+ context 'crunchbase' do
200
+ context 'response' do
201
+ it 'returns new fields' do
202
+ crunchbase_data = parse_json('organizations', 'crunchbase')
203
+ result = Organization.new(crunchbase_data)
204
+
205
+ allow(Organization).to receive(:get).and_return(result)
206
+
207
+ organization = Organization.get('crunchbase')
208
+
209
+ expect(organization.permalink).to eq('crunchbase')
210
+ expect(organization.name).to eq('Crunchbase')
211
+ expect(organization.rank).to eq(22)
212
+ expect(organization.investor_type).to eq(nil)
213
+ expect(organization.contact_email).to eq('info@crunchbase.com')
214
+ expect(organization.phone_number).to eq(' ')
215
+ expect(organization.api_path).to eq('organizations/crunchbase')
216
+ expect(organization.permalink_aliases).to eq(nil)
217
+ end
194
218
  end
195
219
  end
196
220
  end
@@ -2,15 +2,18 @@
2
2
 
3
3
  module ApiHelper
4
4
  def parse_json(endpoint, filename)
5
- response_data = JSON.parse(load_file(endpoint, filename))
6
- response_data = response_data[0] if response_data.is_a?(Array)
7
- raise Crunchbase::Exception, message: response_data['message'], status: response_data['status'] unless response_data['message'].nil?
5
+ response = JSON.parse(load_file(endpoint, filename))
6
+ response = response[0] if response.is_a?(Array)
8
7
 
9
- response_data['data']
8
+ raise Crunchbase::Exception, message: response['message'], status: response['status'] unless response['message'].nil?
9
+
10
+ response['data']
10
11
  end
11
12
 
12
13
  def load_file(endpoint, filename)
13
- File.read(File.join(File.dirname(__FILE__), "../data/#{endpoint}", "#{filename}.json"))
14
+ json_file = File.join(File.dirname(__FILE__), "../data/#{endpoint}", "#{filename}.json")
15
+
16
+ File.read(json_file)
14
17
  end
15
18
 
16
19
  def search_results(data, kclass)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'coveralls'
3
4
  Coveralls.wear!
4
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchbase-ruby-library
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Encore Shao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-09 00:00:00.000000000 Z
11
+ date: 2019-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: pry
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -236,8 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  - !ruby/object:Gem::Version
237
237
  version: '0'
238
238
  requirements: []
239
- rubyforge_project:
240
- rubygems_version: 2.6.13
239
+ rubygems_version: 3.0.3
241
240
  signing_key:
242
241
  specification_version: 4
243
242
  summary: A Ruby wrapper for Crunchbase API v3.1