crunchbase-api 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/.travis.yml +0 -3
- data/lib/crunchbase-api.rb +9 -5
- data/lib/crunchbase-api/configuration.rb +1 -1
- data/lib/crunchbase-api/version.rb +1 -1
- data/test/crunchbase-api/organization_test.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 452abeab234d7e3409496d5492c949ee37a229cc
|
4
|
+
data.tar.gz: fc5890fc883db7e945be0c2b9a9d3d532c899c9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac4e0833a76240b40cd3a1f24ef943defc812f89e5836e5598043ec00d5b3a16f70e437c613fcbc21696e64f315f28aaefea2867783c1895543ecc3b30d18a68
|
7
|
+
data.tar.gz: 997587789ea3dabb92bc4ae1015c0e7686aee66ea1b3ad8839959ef8c1df6cb8f3999b36a0074d589088b0be951b5cafa8c86890571a388e8d42b5fcc6a154d7
|
data/.travis.yml
CHANGED
data/lib/crunchbase-api.rb
CHANGED
@@ -26,21 +26,25 @@ module Crunchbase
|
|
26
26
|
|
27
27
|
def fetch(resource, data = {})
|
28
28
|
data[:user_key] = self.user_key
|
29
|
-
|
30
|
-
|
29
|
+
uri_str = "#{self.api_endpoint}/#{resource}?"
|
30
|
+
uri_str << data.map { |k, v| "#{URI::escape(k.to_s)}=#{URI::escape(v.to_s)}" }.join('&')
|
31
31
|
|
32
32
|
begin
|
33
|
-
|
33
|
+
uri = URI.parse(uri_str)
|
34
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
35
|
+
http.use_ssl = true
|
36
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
37
|
+
response = http.request(request)
|
34
38
|
raise CrunchbaseException, response.body.to_s unless response.code.to_i == 200
|
35
39
|
body = response.body.to_s
|
36
40
|
rescue => e
|
37
|
-
raise CrunchbaseException, "Failed to fetch #{
|
41
|
+
raise CrunchbaseException, "Failed to fetch #{uri_str}: #{e}"
|
38
42
|
end
|
39
43
|
|
40
44
|
begin
|
41
45
|
response = JSON.parse body
|
42
46
|
rescue => e
|
43
|
-
raise CrunchbaseException, "Failed to parse response for #{
|
47
|
+
raise CrunchbaseException, "Failed to parse response for #{uri_str}: #{e}"
|
44
48
|
end
|
45
49
|
|
46
50
|
if response['data']['error'] and response['data']['error']['message']
|
@@ -3,10 +3,10 @@ require 'helper'
|
|
3
3
|
describe 'Organization', :vcr do
|
4
4
|
|
5
5
|
it 'should retrieve organization by domain' do
|
6
|
-
relation = Crunchbase::Organization.find_all_by_domain_name('
|
6
|
+
relation = Crunchbase::Organization.find_all_by_domain_name('infogr.am').first
|
7
7
|
c = relation.fetch
|
8
8
|
c.must_be_instance_of Crunchbase::Organization
|
9
|
-
c.name.must_equal '
|
9
|
+
c.name.must_equal 'Infogram'
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should retrieve organization by name' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crunchbase-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandis Klakovskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|