Resourceful

Description

A ruby gem to abstract web resource handling. You configure the server, resource format, etc… and the gem will provide interactions with that resource in a restful manner, with data returned in a de-serialized object format.

The supported formats are:

* JSON (objects returned as Ruby Hash)
* XML (objects returned as Nokogiri Xml object)

Installation

sudo gem install kelredd-resourceful --source http://gems.github.com

Dependencies

* nokogiri (xml resource format handling)
* json (json resource format handling)
* rest_client (rest web resource access)
* log4r (for resource interaction logging)
* kelredd-useful (some nice ruby helpers)

Usage

# Single host resource handling
require 'resourceful'
Resourceful::Resource.configure :host => 'localhost:3000'
Resourceful::Resource::Cache.clear
Resourceful::Resource.get '/widgets', :format => 'json'  # specify explicit format
Resourceful::Resource.get '/widgets.json'                # or, imply format from resource request

# TODO: extend to create Resource instances that have per instance host, path, format settings

Testing

A suite of cucumber features are available for you to run as an acceptance test. You should look to the features for additional documentation and usage scenarios. To run the features:

# make sure you have these gems
$ sudo gem install cucumber
$ sudo gem install fakeweb
# change to the resourceful gem installed location
$ cd /opt/local/lib/ruby/gems/x.x/gems/kelredd-resourceful-xxx
$ rake features

License

Copyright © 2009 Kelly Redding

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.