crunchbase-ruby-library 0.1.4 → 0.1.5
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/lib/crunchbase/api.rb +13 -10
- data/lib/crunchbase/version.rb +1 -1
- 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: 70add44a8187274163e2ebebe90a4cbd4536cb40
|
4
|
+
data.tar.gz: 034652384460e1077d33451305a2c0498ffe3b5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f7728325c752ff1bf20a50ccdd7748db12711540b3128b5a50d131d600e2664776c6ff09d1879f239ca1750799ef4ba90a8ebcb3716f7b68a17178c806370df
|
7
|
+
data.tar.gz: 74a570a20cf828de4b9a369ba157a94e6be22bec015fcd82de866f1f2fe4d153e3ea62638e34f0f9200f584280d6c69fa65ea55ab503ef14cd720b87d3d4dc70
|
data/lib/crunchbase/api.rb
CHANGED
@@ -47,7 +47,7 @@ module Crunchbase
|
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
50
|
-
|
50
|
+
|
51
51
|
# Returns the JSON parser, whether that's an instance of Yajl or JSON
|
52
52
|
def self.parser
|
53
53
|
if defined?(Yajl)
|
@@ -61,28 +61,28 @@ module Crunchbase
|
|
61
61
|
def self.fetch(permalink, object_name)
|
62
62
|
get_json_response( api_url + "#{object_name}/#{permalink}" )
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
# Fetches URI for the search interface.
|
66
66
|
def self.search(options, resource_list)
|
67
67
|
options[:page] = 1 if options[:page].nil?
|
68
68
|
options[:order] = ORDER_CREATED_AT_ASC if options[:order].nil?
|
69
|
-
|
69
|
+
|
70
70
|
uri = api_url + "#{resource_list}?" + collect_parameters(options)
|
71
71
|
|
72
72
|
get_json_response(uri)
|
73
73
|
end
|
74
|
-
|
75
|
-
|
74
|
+
|
75
|
+
|
76
76
|
# Fetches URI for the search interface.
|
77
77
|
def self.list(options, resource_list)
|
78
78
|
options[:page] = 1 if options[:page].nil?
|
79
79
|
model_name = options.delete(:model_name)
|
80
|
-
|
80
|
+
|
81
81
|
uri = api_url + "#{resource_list}?" + collect_parameters(options)
|
82
82
|
|
83
83
|
Crunchbase::Model::Search.new options, get_json_response(uri), model_name
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
def self.collect_parameters(options)
|
87
87
|
require "cgi"
|
88
88
|
|
@@ -112,8 +112,8 @@ module Crunchbase
|
|
112
112
|
|
113
113
|
Crunchbase::Model::Search.new options, get_json_response(uri), model_name
|
114
114
|
end
|
115
|
-
|
116
|
-
# Gets specified URI, then parses the returned JSON. Raises Timeout error
|
115
|
+
|
116
|
+
# Gets specified URI, then parses the returned JSON. Raises Timeout error
|
117
117
|
# if request time exceeds set limit. Raises Crunchbase::Exception if returned
|
118
118
|
# JSON contains an error.
|
119
119
|
def self.get_json_response(uri)
|
@@ -123,8 +123,11 @@ module Crunchbase
|
|
123
123
|
resp = Timeout::timeout(@timeout_limit) {
|
124
124
|
get_url_following_redirects(uri, @redirect_limit)
|
125
125
|
}
|
126
|
-
response = parser.parse(resp)["data"]
|
127
126
|
|
127
|
+
_response = parser.parse(resp)
|
128
|
+
raise Crunchbase::Exception, { message: _response["error"], code: _response["status"].to_i } unless _response["error"].blank?
|
129
|
+
|
130
|
+
response = _response["data"]
|
128
131
|
raise Crunchbase::Exception, response["error"] if response.class == Hash && response["error"] && response["error"]["code"] != 500
|
129
132
|
|
130
133
|
response
|
data/lib/crunchbase/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Encore Shao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|