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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0782e1d64dc63adc16fc79be8821241dcf405dea
4
- data.tar.gz: 5bba425efd018c2fc2581944a7968fae39d25a71
3
+ metadata.gz: d00d361a87bdc5ee192553bf474274690713f9b7
4
+ data.tar.gz: 7890da574470685b487450f491bb69941fcaaf36
5
5
  SHA512:
6
- metadata.gz: 7c602e578abe213d3084579f335810f8a50df04d3a5036076c8fff04e0d0a4ca723d32f4d10d5b80886eb7f30ab41ac58f351678fbab75842aba3d4aad20d104
7
- data.tar.gz: b8de2f1fba73987836ea4089e4f15c8491f8241296d99621b6579d35aab1ea7091aa9151229320cd161bced8bad79fbbf3704a3a8c866b996ddde3718be8b85e
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. The return object is an array of [Hashie::Mash](https://github.com/intridea/hashie) objects:
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"})
@@ -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
- return nil
190
- elsif response['Content-Type'].include?('application/json')
191
- # Return a bunch of mashes if we're JSON
192
- response = JSON.parse(response.body, :max_nesting => false)
193
- if response.is_a? Array
194
- return response.map { |r| Hashie::Mash.new(r) }
195
- else
196
- return Hashie::Mash.new(response)
197
- end
198
- else
199
- # We don't partically care, just return the raw body
200
- return response.body
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
@@ -1,3 +1,3 @@
1
1
  module SODA
2
- VERSION = '0.2.25'
2
+ VERSION = '1.0.0'
3
3
  end
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.2.25
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: 2018-01-22 00:00:00.000000000 Z
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: chris.metcalf@socrata.com
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.4.5
215
+ rubygems_version: 2.5.2.3
215
216
  signing_key:
216
217
  specification_version: 4
217
218
  summary: Ruby for SODA 2.0