soda-ruby 0.2.10 → 0.2.11

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.
data/README.mkd CHANGED
@@ -1,7 +1,6 @@
1
- The humble beginnings of a [SODA 2.0](http://dev.socrata.com) wrapper for Ruby.
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
- @client = SODA::Client.new({:domain => "sandbox.demo.socrata.com", :app_token => "K6rLY8NBK0Hgm8QQybFmwIUQw" })
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["Content-Type"].include?("application/json")
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
@@ -1,3 +1,3 @@
1
1
  module SODA
2
- VERSION = "0.2.10"
2
+ VERSION = "0.2.11"
3
3
  end
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.10
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-17 00:00:00.000000000 Z
12
+ date: 2014-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie