
Research
/Security News
Shai Hulud Strikes Again (v2)
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.
kaiwren-wrest
Advanced tools
= Wrest
(c) Copyright 2009 {Sidu Ponnappa}[http://blog.sidu.in]. All Rights Reserved.
Wrest is a ruby REST client library which allows you to quickly build object oriented wrappers around any web service. It has two components - Wrest Core and Wrest::Resource.
If you were wondering why the words 'demon', 'chi' and 'puppies' (among others) show up in nearly every example and spec, it's because they all refer to characters and ideas from {Roger Zelazny's}[http://en.wikipedia.org/wiki/Roger_Zelazny] last book, 'Lord Demon.'
== Wrest Core: Features
== Examples
See http://github.com/kaiwren/wrest/tree/master/examples
== Installation
The source is available at git://github.com/kaiwren/wrest.git
To install as a Rails plugin, do script/plugin install git://github.com/kaiwren/wrest.git
To install the Wrest gem, do (sudo) gem install wrest
Wrest is also available as a gem for JRuby; you can instally it by running (sudo) jruby -S gem install wrest.
=== Usage: Shell
You can launch the interactive Wrest shell by running bin/wrest if you have the source or invoking wrest from your prompt if you've installed the gem. $ wrest
y 'http://twitter.com/statuses/public_timeline.json'.to_uri.get.deserialise
=== Usage: Library
require 'rubygems' require 'wrest' y "http://search.yahooapis.com/NewsSearchService/V1/newsSearch".to_uri.get( :appid => 'YahooDemo', :output => 'xml', :query => 'India', :results=> '3', :start => '1' ) === Usage: Basic Http Calls
==== GET
A couple of ways to get Yahoo news as a hash map.
This example simply does a get on a uri and figures out the appropriate deserialiser using the content-type (in this case 'text/javascript', which uses Wrest::Translators::Json). See content_types.rb under lib/wrest/mappers/translators. "http://search.yahooapis.com/NewsSearchService/V1/newsSearch?appid=YahooDemo&output=json&query=India&results=3&start=1".to_uri.get.deserialise
This example does a get on a base uri with several parameters passed to it, resulting in a uri essentially the same as the one above. It also shows how you can specify a custom deserialiser to produce a hash-map from the response, as well as a hash mutator to clean up the deserialised hash. require 'rubygems' require 'wrest' include Wrest::Components y "http://search.yahooapis.com/NewsSearchService/V1/newsSearch".to_uri.get( :appid => 'YahooDemo', :output => 'xml', :query => 'India', :results=> '3', :start => '1' ).deserialise_using( Translators::Xml ).mutate_using( Mutators::XmlMiniTypeCaster.new )
==== DELETE
To delete a resource:
'https://api.del.icio.us/v1/posts/delete'.to_uri( :username => 'kaiwren', :password => 'fupupp1es' ).delete( :url => 'http://c2.com' )
==== OPTIONS
To find out what actions are permitted on a URI:
'http://www.yahoo.com'.to_uri.options.headers['allow']
=== Usage: Attributes Container
Allows any class to hold an attributes hash, somewhat like ActiveResource. It also supports several extensions to this base fuctionality such as support for typecasting attribute values.
Example:
class Demon include Wrest::Components::AttributesContainer include Wrest::Components::AttributesContainer::Typecaster
always_has :id
typecast :age => as_integer,
:chi => lambda{|chi| Chi.new(chi)}
end
kai_wren = Demon.new('id => '1', 'age' => '1500', 'chi' => '1024', 'teacher' => 'Viss') kai_wren.id # => '1' kai_wren.age # => 1500 kai_wren.chi # => #<Chi:0x113af8c @count="1024"> kai_wren.teacher # => 'Viss'
=== Usage: Logging
The Wrest logger can be set and accessed through Wrest.logger and is configured by default to log to STDOUT. If you're using Wrest in a Rails application, you can configure logging by placing the following line in your environment file: Wrest.logger = ActiveRecord::Base.logger
=== Build
Standard options are available and can be listed using rake -T. Use rake:rcov for coverage and rake:rdoc to generate documentation.
== Documentation
Wrest RDocs can be found at http://wrest.rubyforge.org
== Wrest::Resource
Wrest::Resource is an alternative to Rails' ActiveResource. It targets Rails REST (well, POX, since Rails isn't really RESTful) services and is currently under development. Since no single REST library can provide an object oriented wrapper suitable for all available web services, it follows that Wrest should focus on providing you with the tools to help you roll your own. Wrest::Resource is an example of this - an object oriented wrapper for the kind of REST APIs exposed by Rails applications, that you would otherwise use ActiveResource to consume.
== Dependencies
=== Source
=== Build
== Support
This project uses Assembla for ticketing: http://www.assembla.com/spaces/wrest/tickets
== Licence
Wrest is released under the Apache 2.0 licence
FAQs
Unknown package
We found that kaiwren-wrest demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.