soda-ruby 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mkd +15 -6
- data/lib/soda/client.rb +3 -1
- data/lib/soda/version.rb +1 -1
- metadata +2 -2
data/README.mkd
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
1
|
+
For more details and for documentation, check out <http://socrata.github.io/soda-ruby> or our [developer portal](http://dev.socrata.com).
|
2
2
|
|
3
|
-
Installation
|
4
|
-
------------
|
3
|
+
## Installation
|
5
4
|
|
6
5
|
SODA is distributed as a gem, which is how it should be used in your app.
|
7
6
|
|
@@ -11,8 +10,18 @@ Include the gem and hashie in your Gemfile:
|
|
11
10
|
gem 'soda-ruby', :require => 'soda'
|
12
11
|
```
|
13
12
|
|
14
|
-
Quick Start
|
15
|
-
|
13
|
+
## Quick Start
|
14
|
+
|
15
|
+
Create a new client. Register for an application token at <http://dev.socrata.com/register>.
|
16
|
+
|
16
17
|
```ruby
|
17
|
-
|
18
|
+
client = SODA::Client.new({:domain => "explore.data.gov", :app_token => "CGxadgoQlgQSev4zyUh5aR5J3"})
|
19
|
+
```
|
20
|
+
|
21
|
+
Issue a simple query. `644b-gaut` is the identifier for the dataset we want to access:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
response = client.get("644b-gaut", {"$limit" => 1, :namelast => "WINFREY", :namefirst => "OPRAH"})
|
25
|
+
|
26
|
+
=> [#<Hashie::Mash appt_end_date="12/3/09 23:59" appt_made_date="12/2/09 18:05" appt_start_date="12/3/09 9:30" caller_name_first="SALLY" caller_name_last="ARMBRUSTER" last_updatedby="J7" lastentrydate="12/2/09 18:05" meeting_loc="WH" meeting_room="DIP ROOM" namefirst="OPRAH" namelast="WINFREY" post="WIN" release_date=1269586800 terminal_suffix="J7" total_people="10" type_of_access="VA" uin="U60816" visitee_namefirst="SEMONTI" visitee_namelast="STEPHENS">]
|
18
27
|
```
|
data/lib/soda/client.rb
CHANGED
@@ -81,7 +81,9 @@ module SODA
|
|
81
81
|
if response.code != "200"
|
82
82
|
raise "Error in request: #{response.body}"
|
83
83
|
else
|
84
|
-
if response
|
84
|
+
if response.body.nil? || response.body.empty?
|
85
|
+
return nil
|
86
|
+
elsif response["Content-Type"].include?("application/json")
|
85
87
|
# Return a bunch of mashes if we're JSON
|
86
88
|
response = JSON::parse(response.body, :max_nesting => false)
|
87
89
|
if response.is_a? Array
|
data/lib/soda/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|