soda-ruby 0.2.19 → 0.2.21

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: 02d3559111d07cf16cb51d2e2ed9324cb45679ac
4
- data.tar.gz: 13ea33266e56d7c05761ff0b978e7c076859b44c
3
+ metadata.gz: bb0ecea2eeb8861b66705aa11a692635d14f17bf
4
+ data.tar.gz: 7e1f50944e47de5274798f43aa275ccc84d6698b
5
5
  SHA512:
6
- metadata.gz: 1c447fd8cf0ffd2a7ebfd73c112e4cd17c47c5874f90312386bcc0afa371914d7fd60e55c1d9d2ffbd9477a17221747d2cea743c075daa9dbdc4c23111a0aaaa
7
- data.tar.gz: 500e60cdd207ca6ee117cab2b6790789f12d9115d14a5c990d27f06f0315398f25477eaf8f0e27365611c7c516514a46e9ddd66850af2670f28ac4757fef4af2
6
+ metadata.gz: a1a445b253752db1ccdcf65108c148fdd5ed38567d5deca045877b487580d32c3f2fd566081dfb1b634255526eeb933af6c79c89a445240011084177074c02f9
7
+ data.tar.gz: 0f657b55f094bfe55c7419356365c2fc5935d01bacc02d5a95b9e4b4ffc83aebbeb42e808fe697c8ff5676c71754a3620f999e28bb4bc2bb544515186b05636d
@@ -6,9 +6,9 @@ module OmniAuth
6
6
  option :name, 'socrata'
7
7
 
8
8
  option :client_options,
9
- :site => 'https://opendata.socrata.com',
10
- :authorize_url => 'http://opendata.socrata.com/oauth/authorize',
11
- :provider_ignores_state => true
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'] }
@@ -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| s.nil? || s.empty? }.join "&"
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?("https://")
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 "No base domain specified!" unless @config[:domain]
179
- return "https://#{@config[:domain]}#{resource}#{extension}"
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 response.body.nil? || response.body.empty?
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| s.nil? || s.empty? }.join "&"
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 method === :Post || :Put || :Delete
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
@@ -87,11 +87,8 @@ module SODA
87
87
 
88
88
  def http_code
89
89
  # return integer for compatibility
90
- if @response
91
- @response.code.to_i
92
- else
93
- @initial_response_code
94
- end
90
+ return @response.code.to_i if @response
91
+ @initial_response_code
95
92
  end
96
93
 
97
94
  def http_headers
@@ -1,3 +1,3 @@
1
1
  module SODA
2
- VERSION = '0.2.19'
2
+ VERSION = '0.2.21'
3
3
  end
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.19
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-01-08 00:00:00.000000000 Z
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie