crunchbase-api 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef9073779e5e711bc290b94082c9d1d6667454b8
4
+ data.tar.gz: 1ab2c2bd7d8a37b10b4c375afa31f658fd30f7da
5
+ SHA512:
6
+ metadata.gz: c17a069e9b15294c49bd57b6dbb0e1410727c5720e7a4c63dd5fd86e9e2a9fcfa55ffaaf41368be291d1ef532362618c3c1aab864f3912b5fd8239a3f56a307a
7
+ data.tar.gz: 0666f64d10d757fafbd982c34104ffc151f85ea622a12bd1f1dfa0be6dd545d16f1ff99a28cb92dd0264a5d536194fa8f031a79b46bbcefaae75f30b7ed9b846
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .idea/
24
+ test/user_key.yml
25
+ test/cassettes/
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+
7
+ secure: "KVB7wcUFXijzIHebnXDbvSvhArBgDlyX19P/r9X+e0+3gXBPh7B0omAFaPdqb6iHye7RimJduab3hGlmKv/4wYfz09gcIQYu5i1YhNaKSuZI+/gBT6t8c0nzVzNWenISNt/+mTExD7Ew65+F7SY57NbZNpnYT4Nis2DFFPNIgYQ="
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in crunchbase-api.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 sandisk
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,128 @@
1
+ # Crunchbase API
2
+
3
+ An API wrapper for [Crunchbase API](https://developer.crunchbase.com/docs) version 2.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'crunchbase-api'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install crunchbase-api
18
+
19
+ ## Usage
20
+
21
+ You will need a Crunchbase API key. You can get one by [signing up here](https://developer.crunchbase.com).
22
+
23
+ ```ruby
24
+ require 'crunchbase-api'
25
+ Crunchbase.user_key = 'YOUR_API_KEY'
26
+ ```
27
+
28
+ ### Example
29
+ ```ruby
30
+ # Print acquisitions done by Facebook
31
+ company = Crunchbase::Organization.get 'facebook'
32
+ company.acquisitions.each do |a|
33
+ acquisition = a.fetch
34
+ sum = acquisition.price.nil? ? 'Unknown amount' : "#{acquisition.price} #{acquisition.price_currency_code}"
35
+ puts "#{acquisition.announced_on.to_s}: #{acquisition.name} (#{sum})"
36
+ end
37
+
38
+ # 2014-07-02: Acquisition (500000000 USD)
39
+ # 2014-06-03: Acquisition (Unknown amount)
40
+ # 2014-04-24: Acquisition (Unknown amount)
41
+ # 2014-03-25: Facebook acquired Oculus VR (2000000000 USD)
42
+ # 2014-02-19: Facebook acquired WhatsApp (19000000000 USD)
43
+ # 2014-01-13: Facebook acquired Branch (15000000 USD)
44
+ # 2014-01-08: Facebook acquired Little Eye Labs (Unknown amount)
45
+ # 2013-12-17: Facebook acquired SportStream (Unknown amount)
46
+ ```
47
+
48
+ ### Notes
49
+ Failed requests (such as the ones requesting non-existent entities) will throw `Crunchbase::CrunchbaseException`.
50
+ ##### Ordering
51
+ `.list` methods take an `order` argument. Valid options are `Crunchbase::ORDER_CREATED_AT_DESC` (default), `Crunchbase::ORDER_CREATED_AT_ASC`, `Crunchbase::ORDER_UPDATED_AT_DESC` and `Crunchbase::ORDER_UPDATED_AT_ASC`.
52
+ ##### Relation objects
53
+ `.list` methods return an array of `Relation` objects, as do the relationship getters for most individual entities. These are summary objects returned by Crunchbase API, containing `type` and `name` of the target entity, along with timestamps. You can retrieve the "full" entity by calling `.fetch` method on the relation object.
54
+
55
+ --
56
+
57
+ ### Organizations
58
+
59
+ **Organization.get** – Retrieve an organization by permalink
60
+ ```ruby
61
+ Crunchbase::Organization.get(permalink)
62
+ ```
63
+ Properties: `name`, `permalink`, `description`, `short_description`, `homepage_url`, `founded_on`, `is_closed`, `closed_on`, `primary_role`, `total_funding_usd`, `number_of_investments`, `number_of_employees`, `stock_symbol`, `stock_exchange`, `created_at`, `updated_at`.
64
+
65
+ Relationships: `competitors`, `funding_rounds`, `founders`, `products`, `acquisitions`, `ipo`.
66
+
67
+
68
+ **Organization.list** – Retrieves a list of organizations
69
+ ```ruby
70
+ Crunchbase::Organization.list(page, order)
71
+ ```
72
+ --
73
+
74
+ ### People
75
+
76
+ **Person.get** – Retrieve a person profile by permalink
77
+ ```ruby
78
+ Crunchbase::Person.get(permalink)
79
+ ```
80
+ Properties: `first_name`, `last_name`, `permalink`, `bio`, `born_on`, `died_on`, `is_deceased`, `location_uuid`, `created_at`, `updated_at`.
81
+
82
+ Relationships: `founded_companies`.
83
+
84
+
85
+ **Person.list** – Retrieve a list of people
86
+ ```ruby
87
+ Crunchbase::Person.list(page, order)
88
+ ```
89
+ --
90
+
91
+ ### Products
92
+
93
+ **Product.get** – Retrieve product details by permalink
94
+ ```ruby
95
+ Crunchbase::Product.get(permalink)
96
+ ```
97
+ Properties: `name`, `permalink`, `lifecycle_stage`, `owner_id`, `launched_on`, `died_on`, `created_at`, `updated_at`.
98
+
99
+ **Product.list** – Retrieve a list of products
100
+ ```ruby
101
+ Crunchbase::Product.list(page, order)
102
+ ```
103
+ --
104
+
105
+ ### Funding rounds, Acquisitions and IPOs
106
+ **FundingRound.get** – Retrieve information about funding round by uuid
107
+ ```ruby
108
+ Crunchbase::FundingRound.get(uuid)
109
+ ```
110
+ Properties: `name`, `permalink`, `funding_type`, `money_raised`, `money_raised_currency_code`, `announced_on`, `canonical_currency_code`, `created_at`, `updated_at`.
111
+
112
+ Relationships: `funded_organization`.
113
+
114
+ **Acquisition.get** – Retrieve information about acquisition by uuid
115
+ ```ruby
116
+ Crunchbase::Acquisition.get(uuid)
117
+ ```
118
+ Properties: `name`, `permalink`, `acquisition_type`, `price`, `price_currency_code`, `announced_on`, `disposition_of_acquired`, `created_at`, `updated_at`.
119
+
120
+ Relationships: `acquirer`, `acquiree`.
121
+
122
+ **Ipo.get** – Retrieve information about IPO by uuid
123
+ ```ruby
124
+ Crunchbase::Ipo.get(uuid)
125
+ ```
126
+ Properties: `name`, `permalink`, `opening_share_price`, `opening_share_price_currency_code`, `stock_symbol`, `stock_exchange_symbol`, `went_public_on`, `canonical_currency_code`, `money_raised`, `money_raised_currency_code`, `opening_valuation`, `opening_valueation_currency_code`, `created_at`, `updated_at`.
127
+
128
+ Relationships: `funded_company`.
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new do |test|
5
+ test.libs << 'lib' << 'test'
6
+ test.ruby_opts << "-rubygems"
7
+ test.pattern = 'test/**/*_test.rb'
8
+ test.verbose = true
9
+ end
10
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'crunchbase-api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "crunchbase-api"
8
+ spec.version = Crunchbase::VERSION
9
+ spec.authors = ["Sandis Klakovskis"]
10
+ spec.email = ["m@sandis.lv"]
11
+ spec.summary = %q{Wrapper for Crunchbase API v2}
12
+ spec.description = ""
13
+ spec.homepage = "https://github.com/sandisk/crunchbase-api"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "json"
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "webmock"
25
+ spec.add_development_dependency "minitest"
26
+ spec.add_development_dependency "vcr"
27
+ spec.add_development_dependency "minitest-vcr"
28
+ end
@@ -0,0 +1,50 @@
1
+ require 'crunchbase-api/configuration'
2
+ require 'crunchbase-api/crunchbase_exception'
3
+ require 'crunchbase-api/relation'
4
+ require 'crunchbase-api/entity'
5
+ require 'crunchbase-api/person'
6
+ require 'crunchbase-api/product'
7
+ require 'crunchbase-api/organization'
8
+ require 'crunchbase-api/acquisition'
9
+ require 'crunchbase-api/funding_round'
10
+ require 'crunchbase-api/ipo'
11
+ require 'crunchbase-api/version'
12
+
13
+ module Crunchbase
14
+ extend Configuration
15
+
16
+ ORDER_CREATED_AT_ASC = 'created_at asc'
17
+ ORDER_CREATED_AT_DESC = 'created_at desc'
18
+ ORDER_UPDATED_AT_ASC = 'updated_at asc'
19
+ ORDER_UPDATED_AT_DESC = 'updated_at desc'
20
+
21
+ class << self
22
+
23
+ def fetch(resource, data = {})
24
+ data[:user_key] = self.user_key
25
+ uri = "#{self.api_endpoint}/#{resource}?"
26
+ uri << data.map { |k, v| "#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}" }.join('&')
27
+
28
+ begin
29
+ response = Net::HTTP.get_response(URI.parse uri)
30
+ raise CrunchbaseException, response.body.to_s unless response.code.to_i == 200
31
+ body = response.body.to_s
32
+ rescue => e
33
+ raise CrunchbaseException, "Failed to fetch #{uri}: #{e}"
34
+ end
35
+
36
+ begin
37
+ response = JSON.parse body
38
+ rescue => e
39
+ raise CrunchbaseException, "Failed to parse response for #{uri}: #{e}"
40
+ end
41
+
42
+ if response['data']['error'] and response['data']['error']['message']
43
+ raise CrunchbaseException, response['data']['error']['message']
44
+ end
45
+
46
+ response['data']
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,42 @@
1
+ module Crunchbase
2
+
3
+ class Acquisition < Entity
4
+
5
+ RESOURCE_FIND = 'acquisition'
6
+
7
+ attr_reader :name
8
+ attr_reader :permalink
9
+ attr_reader :acquisition_type
10
+ attr_reader :price
11
+ attr_reader :price_currency_code
12
+ attr_reader :announced_on
13
+ attr_reader :disposition_of_acquired
14
+ attr_reader :created_at
15
+ attr_reader :updated_at
16
+
17
+ attr_reader :acquirer
18
+ attr_reader :acquiree
19
+
20
+ def self.get(uuid)
21
+ self.fetch_one uuid
22
+ end
23
+
24
+ private
25
+
26
+ def property_keys
27
+ %w[
28
+ name permalink acquisition_type price price_currency_code announced_on disposition_of_acquired created_at updated_at
29
+ ]
30
+ end
31
+
32
+ def date_keys
33
+ %w[announced_on]
34
+ end
35
+
36
+ def relationships
37
+ %w[acquirer acquiree]
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,23 @@
1
+ module Crunchbase
2
+ module Configuration
3
+
4
+ OPTIONS = [:user_key, :api_endpoint].freeze
5
+ USER_KEY = nil
6
+ API_ENDPOINT = 'http://api.crunchbase.com/v/2'
7
+
8
+ attr_accessor *OPTIONS
9
+
10
+ def configure
11
+ yield self
12
+ end
13
+
14
+ def self.extended(base)
15
+ base.reset
16
+ end
17
+
18
+ def reset
19
+ self.user_key, self.api_endpoint = USER_KEY, API_ENDPOINT
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ module Crunchbase
2
+ class CrunchbaseException < StandardError
3
+ end
4
+ end
@@ -0,0 +1,47 @@
1
+ require 'net/http'
2
+ require 'json'
3
+ require 'cgi'
4
+ require 'date'
5
+
6
+ module Crunchbase
7
+ class Entity
8
+
9
+ def initialize(data)
10
+ property_keys.each { |v| instance_variable_set("@#{v}", data['properties'][v] || nil) }
11
+ date_keys.each { |v| instance_variable_set("@#{v}", data['properties'][v].nil? ? nil : Date.parse(data['properties'][v])) }
12
+ %w[created_at updated_at].each { |v| instance_variable_set("@#{v}", Time.at(data['properties'][v])) }
13
+ relationships.each { |v| set_relationships(v, data['relationships'][v] || nil) }
14
+ end
15
+
16
+ private
17
+
18
+ def self.fetch_one(permalink)
19
+ self.new Crunchbase::fetch("#{self::RESOURCE_FIND}/#{permalink}")
20
+ end
21
+
22
+ def self.fetch_list(page = 1, order = ORDER_CREATED_AT_DESC)
23
+ r = Crunchbase::fetch(self::RESOURCE_LIST, {page: page, order: order})['items']
24
+ r.map { |i| Relation.new i }
25
+ end
26
+
27
+ def property_keys
28
+ []
29
+ end
30
+
31
+ def date_keys
32
+ []
33
+ end
34
+
35
+ def relationships
36
+ []
37
+ end
38
+
39
+ def set_relationships(key, data)
40
+ return unless data and data['items'].respond_to?(:each)
41
+ items = []
42
+ data['items'].each { |v| items << Relation.new(v) }
43
+ instance_variable_set "@#{key}", items
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,42 @@
1
+ module Crunchbase
2
+
3
+ class FundingRound < Entity
4
+
5
+ RESOURCE_FIND = 'funding-round'
6
+
7
+ attr_reader :name
8
+ attr_reader :permalink
9
+ attr_reader :funding_type
10
+ attr_reader :money_raised
11
+ attr_reader :money_raised_currency_code
12
+ attr_reader :announced_on
13
+ attr_reader :canonical_currency_code
14
+ attr_reader :created_at
15
+ attr_reader :updated_at
16
+
17
+ attr_reader :funded_organization
18
+
19
+ def self.get(uuid)
20
+ self.fetch_one uuid
21
+ end
22
+
23
+ private
24
+
25
+ def property_keys
26
+ %w[
27
+ name permalink funding_type money_raised money_raised_currency_code
28
+ announced_on canonical_currency_code created_at updated_at
29
+ ]
30
+ end
31
+
32
+ def date_keys
33
+ %w[announced_on]
34
+ end
35
+
36
+ def relationships
37
+ %w[funded_organization]
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,48 @@
1
+ module Crunchbase
2
+
3
+ class Ipo < Entity
4
+
5
+ RESOURCE_FIND = 'ipo'
6
+
7
+ attr_reader :name
8
+ attr_reader :permalink
9
+ attr_reader :opening_share_price
10
+ attr_reader :opening_share_price_currency_code
11
+ attr_reader :stock_symbol
12
+ attr_reader :stock_exchange_symbol
13
+ attr_reader :went_public_on
14
+ attr_reader :canonical_currency_code
15
+ attr_reader :money_raised
16
+ attr_reader :money_raised_currency_code
17
+ attr_reader :opening_valuation
18
+ attr_reader :opening_valuation_currency_code
19
+ attr_reader :created_at
20
+ attr_reader :updated_at
21
+
22
+ attr_reader :funded_company
23
+
24
+ def self.get(uuid)
25
+ self.fetch_one uuid
26
+ end
27
+
28
+ private
29
+
30
+ def property_keys
31
+ %w[
32
+ name permalink opening_share_price opening_share_price_currency_code stock_symbol stock_exchange_symbol went_public_on
33
+ canonical_currency_code money_raised money_raised_currency_code opening_valuation opening_valuation_currency_code
34
+ created_at updated_at
35
+ ]
36
+ end
37
+
38
+ def date_keys
39
+ %w[went_public_on]
40
+ end
41
+
42
+ def relationships
43
+ %w[funded_company]
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,61 @@
1
+ module Crunchbase
2
+
3
+ class Organization < Entity
4
+
5
+ RESOURCE_FIND = 'organization'
6
+ RESOURCE_LIST = 'organizations'
7
+
8
+ attr_reader :name
9
+ attr_reader :permalink
10
+ attr_reader :description
11
+ attr_reader :short_description
12
+ attr_reader :homepage_url
13
+ attr_reader :founded_on
14
+ attr_reader :is_closed
15
+ attr_reader :closed_on
16
+ attr_reader :primary_role
17
+ attr_reader :total_funding_usd
18
+ attr_reader :number_of_investments
19
+ attr_reader :number_of_employees
20
+ attr_reader :stock_symbol
21
+ attr_reader :stock_exchange
22
+ attr_reader :created_at
23
+ attr_reader :updated_at
24
+
25
+ attr_reader :competitors
26
+ attr_reader :funding_rounds
27
+ attr_reader :founders
28
+ attr_reader :products
29
+ attr_reader :acquisitions
30
+ attr_reader :ipo
31
+
32
+ def self.get(permalink)
33
+ self.fetch_one permalink
34
+ end
35
+
36
+ def self.list(page = 1, order = ORDER_CREATED_AT_DESC)
37
+ self.fetch_list page, order
38
+ end
39
+
40
+ private
41
+
42
+ def property_keys
43
+ %w[
44
+ description short_description founded_on permalink primary_role is_closed closed_on homepage_url
45
+ name created_at updated_at total_funding_usd number_of_investments number_of_employees stock_symbol stock_exchange
46
+ ]
47
+ end
48
+
49
+ def date_keys
50
+ %w[founded_on closed_on]
51
+ end
52
+
53
+ def relationships
54
+ %w[
55
+ competitors funding_rounds founders products acquisitions ipo
56
+ ]
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,47 @@
1
+ module Crunchbase
2
+
3
+ class Person < Entity
4
+
5
+ RESOURCE_FIND = 'person'
6
+ RESOURCE_LIST = 'people'
7
+
8
+ attr_reader :first_name
9
+ attr_reader :last_name
10
+ attr_reader :permalink
11
+ attr_reader :bio
12
+ attr_reader :born_on
13
+ attr_reader :died_on
14
+ attr_reader :is_deceased
15
+ attr_reader :location_uuid
16
+ attr_reader :created_at
17
+ attr_reader :updated_at
18
+
19
+ attr_reader :founded_companies
20
+
21
+ def self.get(permalink)
22
+ self.fetch_one permalink
23
+ end
24
+
25
+ def self.list(page = 1, order = ORDER_CREATED_AT_DESC)
26
+ self.fetch_list page, order
27
+ end
28
+
29
+ private
30
+
31
+ def property_keys
32
+ %w[
33
+ first_name last_name permalink bio born_on died_on is_deceased location_uuid created_at updated_at
34
+ ]
35
+ end
36
+
37
+ def date_keys
38
+ %w[born_on died_on]
39
+ end
40
+
41
+ def relationships
42
+ %w[founded_companies]
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -0,0 +1,41 @@
1
+ module Crunchbase
2
+
3
+ class Product < Entity
4
+
5
+ RESOURCE_FIND = 'product'
6
+ RESOURCE_LIST = 'products'
7
+
8
+ attr_reader :name
9
+ attr_reader :permalink
10
+ attr_reader :lifecycle_stage
11
+ attr_reader :owner_id
12
+ attr_reader :description
13
+ attr_reader :homepage_url
14
+ attr_reader :launched_on
15
+ attr_reader :created_at
16
+ attr_reader :updated_at
17
+
18
+ def self.get(permalink)
19
+ self.fetch_one permalink
20
+ end
21
+
22
+ def self.list(page = 1, order = ORDER_CREATED_AT_DESC)
23
+ self.fetch_list page, order
24
+ end
25
+
26
+ private
27
+
28
+ def property_keys
29
+ %w[
30
+ lifecycle_stage owner_id description permalink homepage_url name launched_on
31
+ created_at updated_at
32
+ ]
33
+ end
34
+
35
+ def date_keys
36
+ %w[launched_on]
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,30 @@
1
+ module Crunchbase
2
+
3
+ class Relation
4
+
5
+ attr_reader :type
6
+ attr_reader :name
7
+ attr_reader :path
8
+ attr_reader :created_at
9
+ attr_reader :updated_at
10
+
11
+ def initialize(data)
12
+ @type = data['type']
13
+ @name = data['name']
14
+ @path = data['path']
15
+ @created_at = Time.at(data['created_at'])
16
+ @updated_at = Time.at(data['updated_at'])
17
+ end
18
+
19
+ def fetch
20
+ supported_relations = %w[Organization Person Product FundingRound Acquisition Ipo]
21
+ unless supported_relations.include?(@type)
22
+ raise CrunchbaseException, "Fetching of '#{@type}' relations is not supported at this time"
23
+ end
24
+ result = Crunchbase.fetch @path
25
+ Crunchbase.const_get(@type).new result
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,3 @@
1
+ module Crunchbase
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,32 @@
1
+ require 'helper'
2
+
3
+ describe 'Acquisition', :vcr do
4
+
5
+ it 'should retrieve acquisition by uuid' do
6
+ c = Crunchbase::Acquisition.get '860a1cf3033ea1c3d16df80053360021'
7
+ c.permalink.must_equal '860a1cf3033ea1c3d16df80053360021'
8
+ c.acquisition_type.must_equal 'Acquisition'
9
+ c.announced_on.must_equal Date.new(2014, 7, 2)
10
+ c.price.must_equal 500000000
11
+ c.price_currency_code.must_equal 'USD'
12
+ c.name.wont_be_empty
13
+ c.disposition_of_acquired.must_equal 'Combined'
14
+ c.created_at.must_be_instance_of Time
15
+ c.updated_at.must_be_instance_of Time
16
+ end
17
+
18
+ it 'should return relationships' do
19
+ c = Crunchbase::Acquisition.get '860a1cf3033ea1c3d16df80053360021'
20
+
21
+ c.acquirer.first.must_be_instance_of Crunchbase::Relation
22
+ c.acquirer.first.type.must_equal 'Organization'
23
+ c.acquirer.first.name.wont_be_empty
24
+ c.acquirer.first.path.wont_be_empty
25
+
26
+ c.acquiree.first.must_be_instance_of Crunchbase::Relation
27
+ c.acquiree.first.type.must_equal 'Organization'
28
+ c.acquiree.first.name.wont_be_empty
29
+ c.acquiree.first.path.wont_be_empty
30
+ end
31
+
32
+ end
@@ -0,0 +1,28 @@
1
+ require 'helper'
2
+
3
+ describe 'FundingRound', :vcr do
4
+
5
+ it 'should retrieve funding round by uuid' do
6
+ c = Crunchbase::FundingRound.get '37bd05f961af726ba3c1b279da842805'
7
+ c.permalink.must_equal '37bd05f961af726ba3c1b279da842805'
8
+ c.funding_type.must_equal 'private_equity'
9
+ c.money_raised.must_equal 1500000000
10
+ c.money_raised_currency_code.must_equal 'USD'
11
+ c.announced_on.must_equal Date.new(2011, 1, 21)
12
+ c.canonical_currency_code.must_equal 'USD'
13
+ c.permalink.wont_be_empty
14
+ c.name.wont_be_empty
15
+ c.created_at.must_be_instance_of Time
16
+ c.updated_at.must_be_instance_of Time
17
+ end
18
+
19
+ it 'should return relationships' do
20
+ c = Crunchbase::FundingRound.get '37bd05f961af726ba3c1b279da842805'
21
+
22
+ c.funded_organization.first.must_be_instance_of Crunchbase::Relation
23
+ c.funded_organization.first.type.must_equal 'Organization'
24
+ c.funded_organization.first.name.wont_be_empty
25
+ c.funded_organization.first.path.wont_be_empty
26
+ end
27
+
28
+ end
@@ -0,0 +1,30 @@
1
+ describe 'IPO', :vcr do
2
+
3
+ it 'should retrieve IPO by uuid' do
4
+ c = Crunchbase::Ipo.get '8fd30bb39eb9839d452685f82c1bfdf7'
5
+ c.permalink.must_equal '8fd30bb39eb9839d452685f82c1bfdf7'
6
+ c.opening_share_price.must_equal '38.0'
7
+ c.opening_share_price_currency_code.must_equal 'USD'
8
+ c.stock_symbol.must_equal 'FB'
9
+ c.stock_exchange_symbol.must_equal 'NASDAQ'
10
+ c.went_public_on.must_equal Date.new(2012, 5, 18)
11
+ c.canonical_currency_code.must_equal 'USD'
12
+ c.money_raised.must_equal 18400000000
13
+ c.money_raised_currency_code.must_equal 'USD'
14
+ c.name.wont_be_empty
15
+ c.opening_valuation.must_equal 104000000000
16
+ c.opening_valuation_currency_code.must_equal 'USD'
17
+ c.created_at.must_be_instance_of Time
18
+ c.updated_at.must_be_instance_of Time
19
+ end
20
+
21
+ it 'should return relationships' do
22
+ c = Crunchbase::Ipo.get '8fd30bb39eb9839d452685f82c1bfdf7'
23
+
24
+ c.funded_company.first.must_be_instance_of Crunchbase::Relation
25
+ c.funded_company.first.type.must_equal 'Organization'
26
+ c.funded_company.first.name.wont_be_empty
27
+ c.funded_company.first.path.wont_be_empty
28
+ end
29
+
30
+ end
@@ -0,0 +1,75 @@
1
+ require 'helper'
2
+
3
+ describe 'Organization', :vcr do
4
+
5
+ it 'should retrieve organization by permalink' do
6
+ c = Crunchbase::Organization.get 'facebook'
7
+ c.name.must_equal 'Facebook'
8
+ c.permalink.must_equal 'facebook'
9
+ c.description.wont_be_empty
10
+ c.short_description.wont_be_empty
11
+ c.homepage_url.must_include 'facebook.com'
12
+ c.founded_on.must_equal Date.new(2004, 02, 01)
13
+ c.total_funding_usd.must_be_instance_of Fixnum
14
+ c.number_of_investments.must_be_instance_of Fixnum
15
+ c.number_of_employees.must_be_instance_of Fixnum
16
+ c.stock_symbol.must_equal 'FB'
17
+ c.stock_exchange.must_equal 'NASDAQ'
18
+ c.created_at.must_be_instance_of Time
19
+ c.updated_at.must_be_instance_of Time
20
+ end
21
+
22
+ it 'should retrieve a list of organizations' do
23
+ c = Crunchbase::Organization.list
24
+ c.size.must_equal 1000
25
+ c.first.must_be_instance_of Crunchbase::Relation
26
+ c.first.type.must_equal 'Organization'
27
+ c.first.name.wont_be_empty
28
+ c.first.path.wont_be_empty
29
+ c.first.created_at.must_be_instance_of Time
30
+ c.first.updated_at.must_be_instance_of Time
31
+ end
32
+
33
+ it 'should fetch organizations returned by the list' do
34
+ relation = Crunchbase::Relation.new({
35
+ 'type' => 'Organization',
36
+ 'name' => 'Facebook',
37
+ 'path' => 'organization/facebook',
38
+ 'created_at' => 1180153335,
39
+ 'updated_at' => 1404773288
40
+ })
41
+ c = relation.fetch
42
+ c.must_be_instance_of Crunchbase::Organization
43
+ c.name.must_equal 'Facebook'
44
+ end
45
+
46
+ it 'should return relationships' do
47
+ c = Crunchbase::Organization.get 'apple'
48
+
49
+ c.competitors.first.must_be_instance_of Crunchbase::Relation
50
+ c.competitors.first.type.must_equal 'Organization'
51
+ c.competitors.first.name.wont_be_empty
52
+ c.competitors.first.path.wont_be_empty
53
+
54
+ c.founders.first.must_be_instance_of Crunchbase::Relation
55
+ c.founders.first.type.must_equal 'Person'
56
+ c.founders.first.name.wont_be_empty
57
+ c.founders.first.path.wont_be_empty
58
+
59
+ c.products.first.must_be_instance_of Crunchbase::Relation
60
+ c.products.first.type.must_equal 'Product'
61
+ c.products.first.name.wont_be_empty
62
+ c.products.first.path.wont_be_empty
63
+
64
+ c.acquisitions.first.must_be_instance_of Crunchbase::Relation
65
+ c.acquisitions.first.type.must_equal 'Acquisition'
66
+ c.acquisitions.first.name.wont_be_empty
67
+ c.acquisitions.first.path.wont_be_empty
68
+
69
+ c.ipo.first.must_be_instance_of Crunchbase::Relation
70
+ c.ipo.first.type.must_equal 'Ipo'
71
+ c.ipo.first.name.wont_be_empty
72
+ c.ipo.first.path.wont_be_empty
73
+ end
74
+
75
+ end
@@ -0,0 +1,52 @@
1
+ require 'helper'
2
+
3
+ describe 'Person', :vcr do
4
+
5
+ it 'should retrieve person by permalink' do
6
+ c = Crunchbase::Person.get 'steve-jobs'
7
+ c.first_name.must_equal 'Steve'
8
+ c.last_name.must_equal 'Jobs'
9
+ c.permalink.must_equal 'steve-jobs'
10
+ c.bio.wont_be_empty
11
+ c.born_on.must_equal Date.new(1955, 2, 24)
12
+ c.died_on.must_equal Date.new(2011, 10, 5)
13
+ c.is_deceased.must_equal true
14
+ c.location_uuid.wont_be_empty
15
+ c.created_at.must_be_instance_of Time
16
+ c.updated_at.must_be_instance_of Time
17
+ end
18
+
19
+ it 'should retrieve a list of people' do
20
+ c = Crunchbase::Person.list
21
+ c.size.must_equal 1000
22
+ c.first.must_be_instance_of Crunchbase::Relation
23
+ c.first.type.must_equal 'Person'
24
+ c.first.name.wont_be_empty
25
+ c.first.path.wont_be_empty
26
+ c.first.created_at.must_be_instance_of Time
27
+ c.first.updated_at.must_be_instance_of Time
28
+ end
29
+
30
+ it 'should fetch persons returned by the list' do
31
+ relation = Crunchbase::Relation.new({
32
+ 'type' => 'Person',
33
+ 'name' => 'Steve Jobs',
34
+ 'path' => 'person/steve-jobs',
35
+ 'created_at' => 1401124619,
36
+ 'updated_at' => 1401124619
37
+ })
38
+ c = relation.fetch
39
+ c.must_be_instance_of Crunchbase::Person
40
+ c.first_name.must_equal 'Steve'
41
+ end
42
+
43
+ it 'should return relationships' do
44
+ c = Crunchbase::Person.get 'steve-jobs'
45
+
46
+ c.founded_companies.first.must_be_instance_of Crunchbase::Relation
47
+ c.founded_companies.first.type.must_equal 'Organization'
48
+ c.founded_companies.first.name.wont_be_empty
49
+ c.founded_companies.first.path.wont_be_empty
50
+ end
51
+
52
+ end
@@ -0,0 +1,40 @@
1
+ require 'helper'
2
+
3
+ describe 'Product', :vcr do
4
+
5
+ it 'should retrieve product by permalink' do
6
+ c = Crunchbase::Product.get 'digg'
7
+ c.lifecycle_stage.wont_be_empty
8
+ c.owner_id.wont_be_empty
9
+ c.description.wont_be_empty
10
+ c.name.must_equal 'Digg'
11
+ c.permalink.must_equal 'digg'
12
+ c.created_at.must_be_instance_of Time
13
+ c.updated_at.must_be_instance_of Time
14
+ end
15
+
16
+ it 'should retrieve a list of products' do
17
+ c = Crunchbase::Product.list
18
+ c.size.must_equal 1000
19
+ c.first.must_be_instance_of Crunchbase::Relation
20
+ c.first.type.must_equal 'Product'
21
+ c.first.name.wont_be_empty
22
+ c.first.path.wont_be_empty
23
+ c.first.created_at.must_be_instance_of Time
24
+ c.first.updated_at.must_be_instance_of Time
25
+ end
26
+
27
+ it 'should fetch persons returned by the list' do
28
+ relation = Crunchbase::Relation.new({
29
+ 'type' => 'Product',
30
+ 'name' => 'Digg',
31
+ 'path' => 'product/digg',
32
+ 'created_at' => 1398758998,
33
+ 'updated_at' => 1398758998
34
+ })
35
+ c = relation.fetch
36
+ c.must_be_instance_of Crunchbase::Product
37
+ c.name.must_equal 'Digg'
38
+ end
39
+
40
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ describe Crunchbase do
4
+ it 'should have a version number' do
5
+ Crunchbase::VERSION.wont_be_nil
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ require 'crunchbase-api'
2
+ require 'vcr'
3
+ require 'webmock'
4
+ require 'minitest/spec'
5
+ require 'minitest/autorun'
6
+ require 'minitest-vcr'
7
+
8
+ VCR.configure do |c|
9
+ c.cassette_library_dir = 'test/cassettes'
10
+ c.hook_into :webmock
11
+ end
12
+
13
+ MinitestVcr::Spec.configure!
14
+
15
+ if ENV['CRUNCHBASE_USER_KEY']
16
+ Crunchbase.user_key = ENV['CRUNCHBASE_USER_KEY']
17
+ else
18
+ api_config = YAML.load_file File.join(File.dirname(__FILE__), 'user_key.yml')
19
+ Crunchbase.user_key = api_config['user_key']
20
+ end
@@ -0,0 +1 @@
1
+ user_key: ~
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crunchbase-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sandis Klakovskis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest-vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: ''
112
+ email:
113
+ - m@sandis.lv
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - crunchbase-api.gemspec
125
+ - lib/crunchbase-api.rb
126
+ - lib/crunchbase-api/acquisition.rb
127
+ - lib/crunchbase-api/configuration.rb
128
+ - lib/crunchbase-api/crunchbase_exception.rb
129
+ - lib/crunchbase-api/entity.rb
130
+ - lib/crunchbase-api/funding_round.rb
131
+ - lib/crunchbase-api/ipo.rb
132
+ - lib/crunchbase-api/organization.rb
133
+ - lib/crunchbase-api/person.rb
134
+ - lib/crunchbase-api/product.rb
135
+ - lib/crunchbase-api/relation.rb
136
+ - lib/crunchbase-api/version.rb
137
+ - test/crunchbase-api/acquisition_test.rb
138
+ - test/crunchbase-api/funding_round_test.rb
139
+ - test/crunchbase-api/ipo_test.rb
140
+ - test/crunchbase-api/organization_test.rb
141
+ - test/crunchbase-api/person_test.rb
142
+ - test/crunchbase-api/product_test.rb
143
+ - test/crunchbase-api/version_test.rb
144
+ - test/helper.rb
145
+ - test/user_key.example.yml
146
+ homepage: https://github.com/sandisk/crunchbase-api
147
+ licenses:
148
+ - MIT
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.2.2
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Wrapper for Crunchbase API v2
170
+ test_files:
171
+ - test/crunchbase-api/acquisition_test.rb
172
+ - test/crunchbase-api/funding_round_test.rb
173
+ - test/crunchbase-api/ipo_test.rb
174
+ - test/crunchbase-api/organization_test.rb
175
+ - test/crunchbase-api/person_test.rb
176
+ - test/crunchbase-api/product_test.rb
177
+ - test/crunchbase-api/version_test.rb
178
+ - test/helper.rb
179
+ - test/user_key.example.yml