quandl_cassinatra 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/quandl/cassinatra/version.rb +1 -1
- data/lib/quandl/her/patch.rb +19 -0
- metadata +2 -2
data/lib/quandl/her/patch.rb
CHANGED
@@ -6,4 +6,23 @@ module Her
|
|
6
6
|
remove_method :data=
|
7
7
|
end
|
8
8
|
end
|
9
|
+
module Middleware
|
10
|
+
class ParseJSON < Faraday::Response::Middleware
|
11
|
+
# @private
|
12
|
+
def parse_json(body = nil)
|
13
|
+
body ||= '{}'
|
14
|
+
message = "Response from the API must behave like a Hash or an Array (last JSON response was #{body.inspect})"
|
15
|
+
|
16
|
+
json = begin
|
17
|
+
Yajl.load(body, :symbolize_keys => true)
|
18
|
+
rescue MultiJson::LoadError
|
19
|
+
raise Her::Errors::ParseError, message
|
20
|
+
end
|
21
|
+
|
22
|
+
raise Her::Errors::ParseError, message unless json.is_a?(Hash) or json.is_a?(Array)
|
23
|
+
|
24
|
+
json
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
9
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_cassinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
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: 2013-
|
12
|
+
date: 2013-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|