crunchbase_v2 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/.gitignore +25 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.rdoc +88 -0
  5. data/Rakefile +7 -0
  6. data/crunchbase.gemspec +24 -0
  7. data/lib/crunchbase.rb +36 -0
  8. data/lib/crunchbase/acquisition.rb +66 -0
  9. data/lib/crunchbase/api.rb +153 -0
  10. data/lib/crunchbase/board_members_and_advisor.rb +23 -0
  11. data/lib/crunchbase/category.rb +22 -0
  12. data/lib/crunchbase/cb_entity.rb +70 -0
  13. data/lib/crunchbase/competitor.rb +25 -0
  14. data/lib/crunchbase/crunch_exception.rb +6 -0
  15. data/lib/crunchbase/current_team.rb +26 -0
  16. data/lib/crunchbase/customer.rb +21 -0
  17. data/lib/crunchbase/founder.rb +21 -0
  18. data/lib/crunchbase/funding_round.rb +69 -0
  19. data/lib/crunchbase/headquarter.rb +27 -0
  20. data/lib/crunchbase/image.rb +21 -0
  21. data/lib/crunchbase/investment.rb +33 -0
  22. data/lib/crunchbase/ipo.rb +57 -0
  23. data/lib/crunchbase/location.rb +24 -0
  24. data/lib/crunchbase/new_item.rb +22 -0
  25. data/lib/crunchbase/office.rb +28 -0
  26. data/lib/crunchbase/organization.rb +246 -0
  27. data/lib/crunchbase/past_team.rb +29 -0
  28. data/lib/crunchbase/person.rb +31 -0
  29. data/lib/crunchbase/primary_image.rb +21 -0
  30. data/lib/crunchbase/product.rb +78 -0
  31. data/lib/crunchbase/relationship.rb +17 -0
  32. data/lib/crunchbase/search.rb +45 -0
  33. data/lib/crunchbase/search_result.rb +11 -0
  34. data/lib/crunchbase/sub_organization.rb +21 -0
  35. data/lib/crunchbase/version.rb +3 -0
  36. data/lib/crunchbase/website.rb +20 -0
  37. data/spec/apikey.example.yml +2 -0
  38. data/spec/bootstrap.rb +9 -0
  39. data/spec/crunchbase/acquisition_spec.rb +26 -0
  40. data/spec/crunchbase/api_spec.rb +8 -0
  41. data/spec/crunchbase/board_members_and_advisor_spec.rb +16 -0
  42. data/spec/crunchbase/category_spec.rb +25 -0
  43. data/spec/crunchbase/competitor_spec.rb +19 -0
  44. data/spec/crunchbase/current_team_spec.rb +17 -0
  45. data/spec/crunchbase/customer_spec.rb +20 -0
  46. data/spec/crunchbase/founder_spec.rb +20 -0
  47. data/spec/crunchbase/funding_round_spec.rb +26 -0
  48. data/spec/crunchbase/headquarter_spec.rb +17 -0
  49. data/spec/crunchbase/investment_spec.rb +20 -0
  50. data/spec/crunchbase/ipo_spec.rb +29 -0
  51. data/spec/crunchbase/location_spec.rb +16 -0
  52. data/spec/crunchbase/new_item_spec.rb +33 -0
  53. data/spec/crunchbase/office_spec.rb +19 -0
  54. data/spec/crunchbase/organization_spec.rb +62 -0
  55. data/spec/crunchbase/past_team_spec.rb +16 -0
  56. data/spec/crunchbase/person_spec.rb +23 -0
  57. data/spec/crunchbase/primary_image_spec.rb +21 -0
  58. data/spec/crunchbase/product_spec.rb +28 -0
  59. data/spec/crunchbase/search_result_spec.rb +16 -0
  60. data/spec/crunchbase/search_spec.rb +17 -0
  61. data/spec/crunchbase/sub_organization_spec.rb +21 -0
  62. data/spec/crunchbase/website_spec.rb +25 -0
  63. data/spec/fixtures/facebook-acquisition.js +82 -0
  64. data/spec/fixtures/facebook-funding-round.js +96 -0
  65. data/spec/fixtures/organization-facebook.js +1023 -0
  66. data/spec/fixtures/person-randi-zuckerberg.js +233 -0
  67. data/spec/spec_helper.rb +10 -0
  68. metadata +192 -0
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase
4
+ class Search
5
+ include Enumerable
6
+
7
+ attr_reader :total_items, :per_page, :pages, :current_page,
8
+ :prev_page_url, :next_page_url, :sort_order, :results
9
+
10
+ alias :length :total_items
11
+ alias :size :total_items
12
+ alias :items :results
13
+
14
+ # Performs a Crunchbase search for query.
15
+ def self.find(query)
16
+ search(query)
17
+ end
18
+
19
+ def self.search(query, t='organizations')
20
+ query = { name: query } if query.kind_of?(String)
21
+
22
+ Search.new query, API.search(query, t), SearchResult
23
+ end
24
+
25
+ def initialize(query, json, _model)
26
+ @query = query
27
+ @results = []
28
+ @total_items = json['paging']['total_items']
29
+ @per_page = json['paging']['items_per_page']
30
+ @pages = json['paging']['number_of_pages']
31
+ @current_page = json['paging']['current_page']
32
+ @prev_page_url = json['paging']['prev_page_url']
33
+ @next_page_url = json['paging']['next_page_url']
34
+ @sort_order = json['paging']['sort_order']
35
+
36
+ populate_results(json, _model)
37
+ end
38
+
39
+
40
+ def populate_results(json, _model)
41
+ @results = json["items"].map{|r| _model.new(r)}
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase
4
+ class SearchResult < Relationship
5
+
6
+ def initialize(json)
7
+ super(json)
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ # http://api.crunchbase.com/v/2/organization/facebook/sub_organizations
4
+
5
+ module Crunchbase
6
+ class SubOrganization < CBEntity
7
+ RESOURCE_LIST = 'sub_organizations'
8
+
9
+ attr_reader :type_name, :name, :path, :permalink, :created_at, :updated_at
10
+
11
+ def initialize(json)
12
+ @type_name = json['type']
13
+ @name = json['name']
14
+ @path = json['path']
15
+ @permalink = json['path'] && json['path'].gsub('organization/', '')
16
+ @created_at = Time.at(json['created_at']).utc
17
+ @updated_at = Time.at(json['updated_at']).utc
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Crunchbase
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ # http://api.crunchbase.com/v/2/organization/facebook/websites
4
+
5
+ module Crunchbase
6
+ class Website < CBEntity
7
+ RESOURCE_NAME = 'website'
8
+ RESOURCE_LIST = 'websites'
9
+
10
+ attr_reader :url, :type_name, :title, :created_at, :updated_at
11
+
12
+ def initialize(json)
13
+ @url = json['url']
14
+ @type_name = json['type']
15
+ @title = json['title']
16
+ @created_at = Time.at(json['created_at']).utc
17
+ @updated_at = Time.at(json['updated_at']).utc
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,2 @@
1
+ key: <your_key_goes_here>
2
+ debug: false
data/spec/bootstrap.rb ADDED
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env ruby
2
+ $: << '../lib'
3
+ require 'crunchbase'
4
+ require 'yaml'
5
+
6
+ yaml = YAML.load_file('apikey.yml')
7
+
8
+ Crunchbase::API.key = yaml['key']
9
+ Crunchbase::API.debug = yaml['debug']
@@ -0,0 +1,26 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe Acquisition do
5
+
6
+ describe "advanced indexing" do
7
+ before(:all) do
8
+ @all_acquisitions = Acquisition.lists_for_permalink("facebook")
9
+ end
10
+
11
+ it "should pull from web api" do
12
+ @all_acquisitions.per_page.should == 1000
13
+ @all_acquisitions.current_page.should == 1
14
+ @all_acquisitions.size.should == 49
15
+ end
16
+ end
17
+
18
+ it "should pull from web api" do
19
+ acquisition = Acquisition.get("7a3d7915ed43073c0e4b5b0d7601def8")
20
+
21
+ acquisition.name.should == "Acquisition"
22
+ acquisition.permalink.should == "7a3d7915ed43073c0e4b5b0d7601def8"
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,8 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+ require 'net/http'
3
+
4
+ module Crunchbase
5
+ describe API do
6
+
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe BoardMembersAndAdvisor do
5
+ describe "advanced indexing" do
6
+ before(:all) do
7
+ @all_board_members_and_advisors = BoardMembersAndAdvisor.lists_for_permalink("facebook")
8
+ end
9
+
10
+ it "should pull from web api" do
11
+ @all_board_members_and_advisors.per_page.should == 1000
12
+ @all_board_members_and_advisors.current_page.should == 1
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe Category do
5
+
6
+ describe "advanced indexing" do
7
+ before(:all) do
8
+ @all_categories = Category.lists_for_permalink("facebook")
9
+ end
10
+
11
+ it "should pull from web api" do
12
+ @all_categories.per_page.should == 1000
13
+ @all_categories.current_page.should == 1
14
+ @all_categories.size.should == 7
15
+ @all_categories.items.count.should == 7
16
+ end
17
+ end
18
+
19
+ it "return categories lists" do
20
+ results = Category.list(1)
21
+ results.per_page.should == 1000
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe Competitor do
5
+
6
+ describe "advanced indexing" do
7
+ before(:all) do
8
+ @all_competitors = Competitor.lists_for_permalink("facebook")
9
+ end
10
+
11
+ it "should pull from web api" do
12
+ @all_competitors.per_page.should == 1000
13
+ @all_competitors.current_page.should == 1
14
+ @all_competitors.size.should == 9
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe CurrentTeam do
5
+ describe "advanced indexing" do
6
+ before(:all) do
7
+ @all_current_teams = CurrentTeam.lists_for_permalink("facebook")
8
+ end
9
+
10
+ it "should pull from web api" do
11
+ @all_current_teams.per_page.should == 1000
12
+ @all_current_teams.current_page.should == 1
13
+ @all_current_teams.size.should == 137
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe Customer do
5
+
6
+ describe "advanced indexing" do
7
+ before(:all) do
8
+ @all_customers = Customer.lists_for_permalink("facebook")
9
+ end
10
+
11
+ it "should pull from web api" do
12
+ @all_customers.per_page.should == 1000
13
+ @all_customers.current_page.should == 1
14
+ @all_customers.size.should == 1
15
+ @all_customers.items.count.should == 1
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe Founder do
5
+
6
+ describe "advanced indexing" do
7
+ before(:all) do
8
+ @all_founders = Founder.lists_for_permalink("facebook")
9
+ end
10
+
11
+ it "should pull from web api" do
12
+ @all_founders.per_page.should == 1000
13
+ @all_founders.current_page.should == 1
14
+ @all_founders.size.should == 5
15
+ @all_founders.items.count.should == 5
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe FundingRound do
5
+
6
+ describe "advanced indexing" do
7
+ before(:all) do
8
+ @all_funding_rounds = FundingRound.lists_for_permalink("facebook")
9
+ end
10
+
11
+ it "check the return results is correct" do
12
+ @all_funding_rounds.per_page.should == 1000
13
+ @all_funding_rounds.current_page.should == 1
14
+ @all_funding_rounds.size.should == 11
15
+ @all_funding_rounds.items.count.should == 11
16
+ end
17
+ end
18
+
19
+ it "should pull from web api" do
20
+ funding_round = FundingRound.get("37bd05f961af726ba3c1b279da842805")
21
+
22
+ funding_round.permalink.should == '37bd05f961af726ba3c1b279da842805'
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe Headquarter do
5
+ describe "advanced indexing" do
6
+ before(:all) do
7
+ @all_headquarters = Headquarter.lists_for_permalink("facebook")
8
+ end
9
+
10
+ it "should pull from web api" do
11
+ @all_headquarters.per_page.should == 1000
12
+ @all_headquarters.current_page.should == 1
13
+ @all_headquarters.items.count.should == 1
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe Investment do
5
+
6
+ describe "advanced indexing" do
7
+ before(:all) do
8
+ @all_investments = Investment.lists_for_permalink("facebook")
9
+ end
10
+
11
+ it "should pull from web api" do
12
+ @all_investments.per_page.should == 1000
13
+ @all_investments.current_page.should == 1
14
+ @all_investments.size.should == 3
15
+ @all_investments.items.count.should == 3
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,29 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe Ipo do
5
+
6
+ describe "advanced indexing" do
7
+ before(:all) do
8
+ @all_ipos = Ipo.lists_for_permalink("facebook")
9
+ end
10
+
11
+ it "should pull from web api" do
12
+ @all_ipos.per_page.should == 1000
13
+ @all_ipos.current_page.should == 1
14
+ @all_ipos.size.should == 3
15
+ @all_ipos.items.count.should == 3
16
+
17
+ puts @all_ipos.items.inspect
18
+ end
19
+ end
20
+
21
+ it "should pull from web api" do
22
+ ipo = Ipo.get("a3bc391490d52ba8529d1cfc20550a87")
23
+
24
+ ipo.permalink.should == 'a3bc391490d52ba8529d1cfc20550a87'
25
+ ipo.funded_companies[0].name.should == 'Facebook'
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe Location do
5
+
6
+ it "return location lists" do
7
+ results = Location.list(1)
8
+
9
+ results.per_page.should == 1000
10
+ results.current_page.should == 1
11
+
12
+ puts results.items.first(3).inspect
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,33 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe NewItem do
5
+
6
+ describe "advanced indexing" do
7
+ before(:all) do
8
+ @all_news = NewItem.lists_for_permalink("facebook")
9
+ end
10
+
11
+ it "should pull from web api" do
12
+ puts @all_news.items.first.title
13
+ puts @all_news.next_page_url
14
+
15
+ @all_news.per_page.should == 1000
16
+ @all_news.current_page.should == 1
17
+ end
18
+
19
+ it "should get oranization all news list" do
20
+ @all_news.items.count.should == 3116
21
+ end
22
+ end
23
+
24
+ it "Fetched all news data paging" do
25
+ page = 4
26
+ second_news = NewItem.lists_for_permalink("facebook", {page: page})
27
+
28
+ second_news.next_page_url.should == nil
29
+ second_news.per_page.should == 1000
30
+ second_news.current_page.should == page
31
+ end
32
+ end
33
+ end