crunchbase 0.2.2 → 0.3.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.
- data/README.rdoc +9 -0
- data/VERSION +1 -1
- data/crunchbase.gemspec +3 -2
- data/lib/crunchbase.rb +1 -1
- data/lib/crunchbase/api.rb +3 -2
- data/spec/apikey.example.yml +1 -0
- data/spec/crunchbase/api_spec.rb +8 -1
- data/spec/spec_helper.rb +6 -1
- metadata +4 -3
data/README.rdoc
CHANGED
|
@@ -9,12 +9,15 @@ use the {YAJL gem}[http://github.com/brianmario/yajl-ruby]; if not, it will
|
|
|
9
9
|
fall back to the {JSON gem}[http://flori.github.com/json/]. Please ensure one
|
|
10
10
|
of the two is installed.
|
|
11
11
|
|
|
12
|
+
You will need to get an API key from {Crunchbase}[http://developer.crunchbase.com/]
|
|
13
|
+
|
|
12
14
|
== Usage
|
|
13
15
|
|
|
14
16
|
If you already know the permalink for a given entity, you can grab the entry
|
|
15
17
|
with the +get+ method.
|
|
16
18
|
|
|
17
19
|
require 'crunchbase'
|
|
20
|
+
Crunchbase::API.key = 'your crunchbase api key'
|
|
18
21
|
steve = Crunchbase::Person.get("steve-jobs")
|
|
19
22
|
facebook = Crunchbase::Company.get("facebook")
|
|
20
23
|
|
|
@@ -66,6 +69,12 @@ list does not entail a delay every ten items. Of course, the list is enormous
|
|
|
66
69
|
(the list of all companies returns over 84,500 entries as of this writing), so
|
|
67
70
|
it's little consolation.
|
|
68
71
|
|
|
72
|
+
== Contributing
|
|
73
|
+
|
|
74
|
+
Contributions are welcome. Note that in order to run the test suite, you need to
|
|
75
|
+
include an API key in +spec/apikey.yml+. This file is ignored by git. An example
|
|
76
|
+
file is provided for convenience.
|
|
77
|
+
|
|
69
78
|
== Copyright
|
|
70
79
|
|
|
71
80
|
Copyright (c) 2011-12 Tyler Cunnion. This software is made available under the
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.3.0
|
data/crunchbase.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "crunchbase"
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.3.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Tyler Cunnion"]
|
|
12
|
-
s.date = "2012-
|
|
12
|
+
s.date = "2012-10-26"
|
|
13
13
|
s.email = "tyler.cunnion@gmail.com"
|
|
14
14
|
s.extra_rdoc_files = [
|
|
15
15
|
"LICENSE.txt",
|
|
@@ -41,6 +41,7 @@ Gem::Specification.new do |s|
|
|
|
41
41
|
"lib/crunchbase/search.rb",
|
|
42
42
|
"lib/crunchbase/search_result.rb",
|
|
43
43
|
"lib/crunchbase/service_provider.rb",
|
|
44
|
+
"spec/apikey.example.yml",
|
|
44
45
|
"spec/crunchbase/api_spec.rb",
|
|
45
46
|
"spec/crunchbase/company_spec.rb",
|
|
46
47
|
"spec/crunchbase/financial_organization_spec.rb",
|
data/lib/crunchbase.rb
CHANGED
data/lib/crunchbase/api.rb
CHANGED
|
@@ -20,8 +20,7 @@ module Crunchbase
|
|
|
20
20
|
SUPPORTED_ENTITIES = ['person', 'company', 'financial-organization', 'product', 'service-provider']
|
|
21
21
|
@timeout_limit = 60
|
|
22
22
|
@redirect_limit = 2
|
|
23
|
-
|
|
24
|
-
class << self; attr_accessor :timeout_limit, :redirect_limit end
|
|
23
|
+
class << self; attr_accessor :timeout_limit, :redirect_limit, :key end
|
|
25
24
|
|
|
26
25
|
def self.single_entity(permalink, entity_name)
|
|
27
26
|
raise CrunchException, "Unsupported Entity Type" unless SUPPORTED_ENTITIES.include?(entity_name)
|
|
@@ -69,6 +68,8 @@ module Crunchbase
|
|
|
69
68
|
# if request time exceeds set limit. Raises CrunchException if returned
|
|
70
69
|
# JSON contains an error.
|
|
71
70
|
def self.get_json_response(uri)
|
|
71
|
+
raise CrunchException, "API key required, visit http://developer.crunchbase.com" unless @key
|
|
72
|
+
uri = uri + "#{uri.match('\?') ? "&" : "?"}api_key=#{@key}"
|
|
72
73
|
resp = Timeout::timeout(@timeout_limit) {
|
|
73
74
|
get_url_following_redirects(uri, @redirect_limit)
|
|
74
75
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
key: <your_key_goes_here>
|
data/spec/crunchbase/api_spec.rb
CHANGED
|
@@ -4,9 +4,16 @@ require 'net/http'
|
|
|
4
4
|
module Crunchbase
|
|
5
5
|
describe API do
|
|
6
6
|
|
|
7
|
+
it "should raise exception for missing API key" do
|
|
8
|
+
key = API.key
|
|
9
|
+
API.key = nil
|
|
10
|
+
expect { API.fetch('steve-jobs', 'person') }.to raise_error
|
|
11
|
+
API.key = key
|
|
12
|
+
end
|
|
13
|
+
|
|
7
14
|
it "should remove control characters" do
|
|
8
15
|
cargurus = File.open(File.join(File.dirname(__FILE__), "..", "fixtures", "cargurus.js")).read
|
|
9
|
-
API.should_receive(:get_url_following_redirects).with(
|
|
16
|
+
API.should_receive(:get_url_following_redirects).with(/^http:\/\/api.crunchbase.com\/v\/1\/company\/cargurus.js/, 2).and_return(cargurus)
|
|
10
17
|
lambda { API.single_entity("cargurus", "company") }.should_not raise_error
|
|
11
18
|
end
|
|
12
19
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
$LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
|
|
2
2
|
require 'rspec'
|
|
3
3
|
require 'crunchbase'
|
|
4
|
-
require 'date'
|
|
4
|
+
require 'date'
|
|
5
|
+
require 'yaml'
|
|
6
|
+
|
|
7
|
+
key_yaml = YAML.load_file(File.join(File.dirname(__FILE__),'apikey.yml'))
|
|
8
|
+
|
|
9
|
+
Crunchbase::API.key = key_yaml["key"]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: crunchbase
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-10-26 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rspec
|
|
@@ -124,6 +124,7 @@ files:
|
|
|
124
124
|
- lib/crunchbase/search.rb
|
|
125
125
|
- lib/crunchbase/search_result.rb
|
|
126
126
|
- lib/crunchbase/service_provider.rb
|
|
127
|
+
- spec/apikey.example.yml
|
|
127
128
|
- spec/crunchbase/api_spec.rb
|
|
128
129
|
- spec/crunchbase/company_spec.rb
|
|
129
130
|
- spec/crunchbase/financial_organization_spec.rb
|
|
@@ -151,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
151
152
|
version: '0'
|
|
152
153
|
segments:
|
|
153
154
|
- 0
|
|
154
|
-
hash:
|
|
155
|
+
hash: 1391900359395549373
|
|
155
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
157
|
none: false
|
|
157
158
|
requirements:
|