soda-ruby 0.2.25 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.mkd +13 -1
- data/lib/soda/client.rb +16 -13
- data/lib/soda/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d00d361a87bdc5ee192553bf474274690713f9b7
|
4
|
+
data.tar.gz: 7890da574470685b487450f491bb69941fcaaf36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee00eac803e3caf668d78cfcffcba1ebc3c1b72500d72a185f8863529b5d25ba70e396a4f8b860958cbbd9d72e43b362d518f0444b7cf15cee38d544e13ff42f
|
7
|
+
data.tar.gz: be7e11c9fce1c786a456db2fdd70f3c6bb7627a7dc82d57ea5a6a7765615c4f661ff3f03e98901931d6ebc4d3f291f17aef884fa3fe420c3f9209d3b92420f65
|
data/README.mkd
CHANGED
@@ -26,7 +26,19 @@ Create a new client. Register for an application token at <http://dev.socrata.co
|
|
26
26
|
client = SODA::Client.new({:domain => "explore.data.gov", :app_token => "CGxadgoQlgQSev4zyUh5aR5J3"})
|
27
27
|
```
|
28
28
|
|
29
|
-
Issue a filter query. `644b-gaut` is the identifier for the dataset we want to access.
|
29
|
+
Issue a filter query. `644b-gaut` is the identifier for the dataset we want to access.
|
30
|
+
|
31
|
+
### As of version 1.0.0+
|
32
|
+
|
33
|
+
The return object is the complete response object with a pre parsed body. The response.body object is an array of [Hashie::Mash].
|
34
|
+
|
35
|
+
If you are upgrading from a version < 1.0.0 The previous object returned is now the response.body object.
|
36
|
+
|
37
|
+
### Prior to version 1 (<1.0.0)
|
38
|
+
|
39
|
+
The return object is an array of [Hashie::Mash] that represents the body of the response.
|
40
|
+
|
41
|
+
(https://github.com/intridea/hashie) objects:
|
30
42
|
|
31
43
|
```ruby
|
32
44
|
response = client.get("644b-gaut", {"$limit" => 1, :namelast => "WINFREY", :namefirst => "OPRAH"})
|
data/lib/soda/client.rb
CHANGED
@@ -182,22 +182,24 @@ module SODA
|
|
182
182
|
"https://#{@config[:domain]}#{resource}#{extension}"
|
183
183
|
end
|
184
184
|
|
185
|
+
# Returns a response with a parsed body
|
185
186
|
def handle_response(response)
|
186
187
|
# Check our response code
|
187
188
|
check_response_fail(response)
|
188
|
-
if blank?(response.body)
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
response = JSON.parse(response.body, :
|
193
|
-
if response.is_a? Array
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
189
|
+
return nil if blank?(response.body)
|
190
|
+
|
191
|
+
# Return a bunch of mashes as the body if we're JSON
|
192
|
+
begin
|
193
|
+
response.body = JSON.parse(response.body, max_nesting: false)
|
194
|
+
response.body = if response.body.is_a? Array
|
195
|
+
response.body.map { |r| Hashie::Mash.new(r) }
|
196
|
+
else
|
197
|
+
Hashie::Mash.new(response.body)
|
198
|
+
end
|
199
|
+
rescue => exception
|
200
|
+
raise "JSON parsing failed. Error details: #{exception}"
|
201
|
+
ensure
|
202
|
+
return response
|
201
203
|
end
|
202
204
|
end
|
203
205
|
|
@@ -265,6 +267,7 @@ module SODA
|
|
265
267
|
http = Net::HTTP.new(host, port)
|
266
268
|
http.use_ssl = true
|
267
269
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @config[:ignore_ssl]
|
270
|
+
http.open_timeout = @config[:timeout] if @config[:timeout]
|
268
271
|
http.read_timeout = @config[:timeout] if @config[:timeout]
|
269
272
|
http.set_debug_output(@config[:debug_stream]) if @config[:debug_stream]
|
270
273
|
http
|
data/lib/soda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soda-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Metcalf
|
8
|
+
- Dominic Cicilio
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: hashie
|
@@ -180,7 +181,7 @@ dependencies:
|
|
180
181
|
version: '0'
|
181
182
|
description: A simple wrapper for SODA 2.0. Includes an OmniAuth provider for OAuth
|
182
183
|
2.0
|
183
|
-
email:
|
184
|
+
email: dominic.cicilio@tylertech.com
|
184
185
|
executables: []
|
185
186
|
extensions: []
|
186
187
|
extra_rdoc_files: []
|
@@ -211,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
212
|
version: 1.3.6
|
212
213
|
requirements: []
|
213
214
|
rubyforge_project: soda-ruby
|
214
|
-
rubygems_version: 2.
|
215
|
+
rubygems_version: 2.5.2.3
|
215
216
|
signing_key:
|
216
217
|
specification_version: 4
|
217
218
|
summary: Ruby for SODA 2.0
|