soda-ruby 0.2.19 → 0.2.21
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/omniauth-socrata.rb +3 -3
- data/lib/soda/client.rb +13 -10
- data/lib/soda/exceptions.rb +2 -5
- data/lib/soda/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: bb0ecea2eeb8861b66705aa11a692635d14f17bf
|
4
|
+
data.tar.gz: 7e1f50944e47de5274798f43aa275ccc84d6698b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1a445b253752db1ccdcf65108c148fdd5ed38567d5deca045877b487580d32c3f2fd566081dfb1b634255526eeb933af6c79c89a445240011084177074c02f9
|
7
|
+
data.tar.gz: 0f657b55f094bfe55c7419356365c2fc5935d01bacc02d5a95b9e4b4ffc83aebbeb42e808fe697c8ff5676c71754a3620f999e28bb4bc2bb544515186b05636d
|
data/lib/omniauth-socrata.rb
CHANGED
@@ -6,9 +6,9 @@ module OmniAuth
|
|
6
6
|
option :name, 'socrata'
|
7
7
|
|
8
8
|
option :client_options,
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
:site => 'https://opendata.socrata.com',
|
10
|
+
:authorize_url => 'http://opendata.socrata.com/oauth/authorize',
|
11
|
+
:provider_ignores_state => true
|
12
12
|
|
13
13
|
# Sets the UID from the user's info
|
14
14
|
uid { raw_info['id'] }
|
data/lib/soda/client.rb
CHANGED
@@ -20,13 +20,16 @@ module SODA
|
|
20
20
|
class << self
|
21
21
|
def generate_user_agent
|
22
22
|
if Gem.win_platform?
|
23
|
-
"soda-ruby/#{SODA::VERSION} (Windows; Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL})"
|
24
|
-
else
|
25
|
-
"soda-ruby/#{SODA::VERSION} (#{Uname.uname.sysname}/#{Uname.uname.release}; Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL})"
|
23
|
+
return "soda-ruby/#{SODA::VERSION} (Windows; Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL})"
|
26
24
|
end
|
25
|
+
"soda-ruby/#{SODA::VERSION} (#{Uname.uname.sysname}/#{Uname.uname.release}; Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL})"
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
29
|
+
def blank?(object)
|
30
|
+
object.nil? || object.empty?
|
31
|
+
end
|
32
|
+
|
30
33
|
##
|
31
34
|
#
|
32
35
|
# Creates a new SODA client.
|
@@ -138,7 +141,7 @@ module SODA
|
|
138
141
|
query = [
|
139
142
|
base.query,
|
140
143
|
query_string(params)
|
141
|
-
].reject { |s|
|
144
|
+
].reject { |s| blank?(s) }.join '&'
|
142
145
|
|
143
146
|
uri = URI.parse("https://#{base.host}#{base.path}?#{query}")
|
144
147
|
|
@@ -163,7 +166,7 @@ module SODA
|
|
163
166
|
|
164
167
|
def parse_resource(resource)
|
165
168
|
# If our resource starts with HTTPS, assume they've passed in a full URI
|
166
|
-
return resource if resource.start_with?(
|
169
|
+
return resource if resource.start_with?('https://')
|
167
170
|
|
168
171
|
# If we didn't get a full path, assume "/resource/"
|
169
172
|
resource = '/resource/' + resource unless resource.start_with?('/')
|
@@ -175,14 +178,14 @@ module SODA
|
|
175
178
|
extension = matches.captures[1]
|
176
179
|
end
|
177
180
|
|
178
|
-
raise
|
179
|
-
|
181
|
+
raise 'No base domain specified!' unless @config[:domain]
|
182
|
+
"https://#{@config[:domain]}#{resource}#{extension}"
|
180
183
|
end
|
181
184
|
|
182
185
|
def handle_response(response)
|
183
186
|
# Check our response code
|
184
187
|
check_response_fail(response)
|
185
|
-
if
|
188
|
+
if blank?(response.body)
|
186
189
|
return nil
|
187
190
|
elsif response['Content-Type'].include?('application/json')
|
188
191
|
# Return a bunch of mashes if we're JSON
|
@@ -220,7 +223,7 @@ module SODA
|
|
220
223
|
query = [
|
221
224
|
base.query,
|
222
225
|
query_string(params)
|
223
|
-
].reject { |s|
|
226
|
+
].reject { |s| blank?(s) }.join '&'
|
224
227
|
|
225
228
|
uri = URI.parse("https://#{base.host}#{base.path}?#{query}")
|
226
229
|
|
@@ -250,7 +253,7 @@ module SODA
|
|
250
253
|
end
|
251
254
|
|
252
255
|
def request_by_method(method, body, request, uri)
|
253
|
-
if
|
256
|
+
if [:Post, :Put, :Get].include?(method)
|
254
257
|
request.content_type = 'application/json'
|
255
258
|
request.body = body.to_json(:max_nesting => false)
|
256
259
|
end
|
data/lib/soda/exceptions.rb
CHANGED
data/lib/soda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soda-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Metcalf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|