soda-ruby 0.2.17 → 0.2.18
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/README.mkd +3 -0
- data/lib/omniauth-socrata.rb +6 -7
- data/lib/soda/client.rb +3 -1
- data/lib/soda/exceptions.rb +68 -70
- data/lib/soda/version.rb +1 -1
- metadata +3 -4
- data/lib/soda/smartupdate.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b31234fb24d9b3e2a6e895c687f8c5036b8c2f9
|
4
|
+
data.tar.gz: 4b60658e6a62db5cf3c42a74819c0018b32059a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e27a9b90898ec21331984a8ac4b7d79db6516ceb7d047e8a8c3fac9f3dc6383ffa65e1e48a1ebb205d22b2573d357fb10fe3890d775df84d858590973863e36
|
7
|
+
data.tar.gz: 69117b56f9280ffeea188b074c0409f7835e36f3f250e6be302c20830675b627b899687c21bf83ce9fac62feb6125206ee9b9ea8d08ddac770eca12429c3e40c
|
data/README.mkd
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[](https://ci.appveyor.com/project/chrismetcalf/soda-ruby)
|
2
|
+
[](https://travis-ci.org/socrata/soda-ruby)
|
3
|
+
|
1
4
|
For more details and for documentation, check out <http://socrata.github.io/soda-ruby> or our [developer portal](http://dev.socrata.com).
|
2
5
|
|
3
6
|
## Installation
|
data/lib/omniauth-socrata.rb
CHANGED
@@ -3,20 +3,19 @@ require 'omniauth-oauth2'
|
|
3
3
|
module OmniAuth
|
4
4
|
module Strategies
|
5
5
|
class Socrata < OmniAuth::Strategies::OAuth2
|
6
|
-
option :name,
|
6
|
+
option :name, 'socrata'
|
7
7
|
|
8
|
-
option :client_options,
|
9
|
-
:site
|
10
|
-
:authorize_url
|
8
|
+
option :client_options,
|
9
|
+
:site => 'https://opendata.socrata.com',
|
10
|
+
:authorize_url => 'http://opendata.socrata.com/oauth/authorize',
|
11
11
|
:provider_ignores_state => true
|
12
|
-
}
|
13
12
|
|
14
13
|
# Sets the UID from the user's info
|
15
|
-
uid{ raw_info['id'] }
|
14
|
+
uid { raw_info['id'] }
|
16
15
|
|
17
16
|
info do
|
18
17
|
{
|
19
|
-
:name
|
18
|
+
:name => raw_info['name'],
|
20
19
|
:email => raw_info['email']
|
21
20
|
}
|
22
21
|
end
|
data/lib/soda/client.rb
CHANGED
@@ -40,7 +40,8 @@ module SODA
|
|
40
40
|
# * +:password+ - Your Socrata password (optional, only necessary for modifying data)
|
41
41
|
# * +:app_token+ - Your Socrata application token (register at http://dev.socrata.com/register)
|
42
42
|
# * +:access_token+ - Your Socrata OAuth token (optional, https://dev.socrata.com/docs/authentication.html)
|
43
|
-
# * +:ignore_ssl+ - Ignore
|
43
|
+
# * +:ignore_ssl+ - Ignore SSL errors, which is very unsafe and only should be done in desperate circumstances (defaults to false)
|
44
|
+
# * +:debug_stream+ - Set an output stream for debugging
|
44
45
|
#
|
45
46
|
# Returns a SODA::Client instance.
|
46
47
|
#
|
@@ -246,6 +247,7 @@ module SODA
|
|
246
247
|
http.use_ssl = true
|
247
248
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @config[:ignore_ssl]
|
248
249
|
http.read_timeout = @config[:timeout] if @config[:timeout]
|
250
|
+
http.set_debug_output(@config[:debug_stream]) if @config[:debug_stream]
|
249
251
|
http
|
250
252
|
end
|
251
253
|
|
data/lib/soda/exceptions.rb
CHANGED
@@ -1,70 +1,70 @@
|
|
1
1
|
# Adapted (lifted) from RestClient: https://github.com/rest-client/rest-client/blob/master/lib/restclient/exceptions.rb
|
2
2
|
module SODA
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
3
|
+
STATUSES = {
|
4
|
+
100 => 'Continue',
|
5
|
+
101 => 'Switching Protocols',
|
6
|
+
102 => 'Processing', # WebDAV
|
7
|
+
|
8
|
+
200 => 'OK',
|
9
|
+
201 => 'Created',
|
10
|
+
202 => 'Accepted',
|
11
|
+
203 => 'Non-Authoritative Information', # http/1.1
|
12
|
+
204 => 'No Content',
|
13
|
+
205 => 'Reset Content',
|
14
|
+
206 => 'Partial Content',
|
15
|
+
207 => 'Multi-Status', # WebDAV
|
16
|
+
|
17
|
+
300 => 'Multiple Choices',
|
18
|
+
301 => 'Moved Permanently',
|
19
|
+
302 => 'Found',
|
20
|
+
303 => 'See Other', # http/1.1
|
21
|
+
304 => 'Not Modified',
|
22
|
+
305 => 'Use Proxy', # http/1.1
|
23
|
+
306 => 'Switch Proxy', # no longer used
|
24
|
+
307 => 'Temporary Redirect', # http/1.1
|
25
|
+
|
26
|
+
400 => 'Bad Request',
|
27
|
+
401 => 'Unauthorized',
|
28
|
+
402 => 'Payment Required',
|
29
|
+
403 => 'Forbidden',
|
30
|
+
404 => 'Not Found',
|
31
|
+
405 => 'Method Not Allowed',
|
32
|
+
406 => 'Not Acceptable',
|
33
|
+
407 => 'Proxy Authentication Required',
|
34
|
+
408 => 'Request Timeout',
|
35
|
+
409 => 'Conflict',
|
36
|
+
410 => 'Gone',
|
37
|
+
411 => 'Length Required',
|
38
|
+
412 => 'Precondition Failed',
|
39
|
+
413 => 'Request Entity Too Large',
|
40
|
+
414 => 'Request-URI Too Long',
|
41
|
+
415 => 'Unsupported Media Type',
|
42
|
+
416 => 'Requested Range Not Satisfiable',
|
43
|
+
417 => 'Expectation Failed',
|
44
|
+
418 => 'I\'m A Teapot', # RFC2324
|
45
|
+
421 => 'Too Many Connections From This IP',
|
46
|
+
422 => 'Unprocessable Entity', # WebDAV
|
47
|
+
423 => 'Locked', # WebDAV
|
48
|
+
424 => 'Failed Dependency', # WebDAV
|
49
|
+
425 => 'Unordered Collection', # WebDAV
|
50
|
+
426 => 'Upgrade Required',
|
51
|
+
428 => 'Precondition Required', # RFC6585
|
52
|
+
429 => 'Too Many Requests', # RFC6585
|
53
|
+
431 => 'Request Header Fields Too Large', # RFC6585
|
54
|
+
449 => 'Retry With', # Microsoft
|
55
|
+
450 => 'Blocked By Windows Parental Controls', # Microsoft
|
56
|
+
|
57
|
+
500 => 'Internal Server Error',
|
58
|
+
501 => 'Not Implemented',
|
59
|
+
502 => 'Bad Gateway',
|
60
|
+
503 => 'Service Unavailable',
|
61
|
+
504 => 'Gateway Timeout',
|
62
|
+
505 => 'HTTP Version Not Supported',
|
63
|
+
506 => 'Variant Also Negotiates',
|
64
|
+
507 => 'Insufficient Storage', # WebDAV
|
65
|
+
509 => 'Bandwidth Limit Exceeded', # Apache
|
66
|
+
510 => 'Not Extended',
|
67
|
+
511 => 'Network Authentication Required', # RFC6585
|
68
68
|
}
|
69
69
|
|
70
70
|
# This is the base exception class. Rescue it if you want to
|
@@ -79,7 +79,7 @@ module SODA
|
|
79
79
|
attr_accessor :data
|
80
80
|
attr_writer :message
|
81
81
|
|
82
|
-
def initialize
|
82
|
+
def initialize(response = nil, initial_response_code = nil)
|
83
83
|
@response = response
|
84
84
|
@message = nil
|
85
85
|
@initial_response_code = initial_response_code
|
@@ -121,7 +121,6 @@ module SODA
|
|
121
121
|
|
122
122
|
# The request failed with an error code not managed by the code
|
123
123
|
class RequestFailed < ExceptionWithResponse
|
124
|
-
|
125
124
|
def default_message
|
126
125
|
"HTTP status code #{http_code}"
|
127
126
|
end
|
@@ -144,7 +143,7 @@ module SODA
|
|
144
143
|
# Create HTTP status exception classes
|
145
144
|
STATUSES.each_pair do |code, message|
|
146
145
|
klass = Class.new(RequestFailed) do
|
147
|
-
send(:define_method, :default_message) {"#{http_code ? "#{http_code} " : ''}#{message}"}
|
146
|
+
send(:define_method, :default_message) { "#{http_code ? "#{http_code} " : ''}#{message}" }
|
148
147
|
end
|
149
148
|
klass_constant = const_set(message.delete(' \-\''), klass)
|
150
149
|
Exceptions::EXCEPTIONS_MAP[code] = klass_constant
|
@@ -163,7 +162,7 @@ module SODA
|
|
163
162
|
# NB: Previous releases of rest-client would raise RequestTimeout both for
|
164
163
|
# HTTP 408 responses and for actual connection timeouts.
|
165
164
|
class Timeout < SODA::RequestTimeout
|
166
|
-
def initialize(message=nil, original_exception=nil)
|
165
|
+
def initialize(message = nil, original_exception = nil)
|
167
166
|
super(nil, nil)
|
168
167
|
self.message = message if message
|
169
168
|
self.original_exception = original_exception if original_exception
|
@@ -187,7 +186,6 @@ module SODA
|
|
187
186
|
end
|
188
187
|
end
|
189
188
|
|
190
|
-
|
191
189
|
# The server broke the connection prior to the request completing. Usually
|
192
190
|
# this means it crashed, or sometimes that your network connection was
|
193
191
|
# severed before it could complete.
|
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.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Metcalf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -177,7 +177,6 @@ files:
|
|
177
177
|
- lib/soda.rb
|
178
178
|
- lib/soda/client.rb
|
179
179
|
- lib/soda/exceptions.rb
|
180
|
-
- lib/soda/smartupdate.rb
|
181
180
|
- lib/soda/version.rb
|
182
181
|
homepage: http://github.com/socrata/soda-ruby
|
183
182
|
licenses: []
|
@@ -198,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
197
|
version: 1.3.6
|
199
198
|
requirements: []
|
200
199
|
rubyforge_project: soda-ruby
|
201
|
-
rubygems_version: 2.
|
200
|
+
rubygems_version: 2.4.5
|
202
201
|
signing_key:
|
203
202
|
specification_version: 4
|
204
203
|
summary: Ruby for SODA 2.0
|
data/lib/soda/smartupdate.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# A Ruby client to the Socrata SmartUpdate API
|
4
|
-
#
|
5
|
-
# For more details, check out http://socrata.github.io/soda-ruby
|
6
|
-
#
|
7
|
-
|
8
|
-
require 'soda/client'
|
9
|
-
|
10
|
-
module SODA
|
11
|
-
class SmartUpdate
|
12
|
-
##
|
13
|
-
#
|
14
|
-
# Creates a new SmartUpdate client.
|
15
|
-
#
|
16
|
-
# * +config+ - A hash of the options to initialize the client with. The options are the same as SODA::Client
|
17
|
-
#
|
18
|
-
# == Config Options
|
19
|
-
#
|
20
|
-
# * +:domain+ - The domain you want to access
|
21
|
-
# * +:username+ - Your Socrata username (optional, only necessary for modifying data)
|
22
|
-
# * +:password+ - Your Socrata password (optional, only necessary for modifying data)
|
23
|
-
# * +:app_token+ - Your Socrata application token (register at http://dev.socrata.com/register)
|
24
|
-
# * +:ignore_ssl+ - Ignore ssl errors (defaults to false)
|
25
|
-
#
|
26
|
-
# Returns a SODA::Client instance.
|
27
|
-
#
|
28
|
-
# == Example
|
29
|
-
#
|
30
|
-
# client = SODA::Client.new({ :domain => "data.agency.gov", :app_token => "CGxarwoQlgQSev4zyUh5aR5J3" })
|
31
|
-
#
|
32
|
-
def initialize(config = {})
|
33
|
-
@config = config.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
34
|
-
@client = SODA::Client.new(@config)
|
35
|
-
|
36
|
-
# Fetch version and blocksize information from the service
|
37
|
-
@blocksize = @client.get("/datasync/version.json")["max-block-size"]
|
38
|
-
end
|
39
|
-
|
40
|
-
# Chunks a file for smart-updating and uploads it
|
41
|
-
def upload(uid, filename, options = {})
|
42
|
-
options = DEFAULT_OPTIONS.merge(options)
|
43
|
-
|
44
|
-
# Determine the file size, and ideal chunk size
|
45
|
-
filesize = File.size(filename)
|
46
|
-
blocks = (0..filesize).step(@blocksize).collect do |offset|
|
47
|
-
@client.post("/datasync/id/#{uid}",
|
48
|
-
IO.read(filename, @blocksize, offset)).blobId
|
49
|
-
end
|
50
|
-
return blocks
|
51
|
-
end
|
52
|
-
|
53
|
-
# Commits a set of chunks to be written
|
54
|
-
def commit(uid, filename, chunks)
|
55
|
-
@client.post("/datasync/id/#{uid}/commit", {:filename => filename, :chunks => chunks}).jobId
|
56
|
-
end
|
57
|
-
|
58
|
-
# Check on the status of a job
|
59
|
-
def check(uid, job_id)
|
60
|
-
@client.get("/datasync/id/#{uid}/status/#{job_id}", nil, nil)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|