New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

curt-wren

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

curt-wren

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Wren

A very lightweight Ruby wrapper for the Twitter REST API

== Author

Curt Gilman, Reductive Reason LLC

curt.gilman [at] reductivereason.com

  • http://twitter.com/curtg72 - Twitter ego
  • http://reductivereason.com - Corporate identity
  • http://pearlsofnonsense.com - Personal soapbox
  • http://w8track.com - Online weight tracking

== Description

Wren is a very lightweight Ruby wrapper for the Twitter REST API. It implements only basic authentication and JSON parsing. SSL is used automatically whenever credentials are sent and for all post requests. OAuth authentication, search API, and XML parsing are not implemented. PUT and DELETE methods are also not implemented.

== Installation

Add GitHub to your gem sources, if you haven't already: gem sources -a http://gems.github.com

Install the gem. sudo gem install curt-wren

== Usage

The first thing you'll need to do is require Wren. require 'wren'

=== Configuration

Before you make any Twitter API calls, you'll want to set up the configuration.

==== Using no authentication

If you're not using any parts of the Twitter API requiring authentication, you can use the default configuration. Congratulations, you're done!

==== Using basic authentication

The simplest configuration for basic authentication is just your Twitter username and password. config = Wren::Configuration.new do |c| c.user = 't123' c.pwd = 'fido' # <= not recommended end

You could also do this as a one-liner.

config = Wren::Configuration(:user => 't123', :pwd => 'fido')

==== Other settings

If you've created a configuration, you can change the logger, which is STDOUT by default. config.logger = my_logger

=== Calling the API

You'll first need to "new" up an instance of Client. client = Wren::Client.new(config)

If you call the initializer with a hash, it'll create a Configuration object for you. client = Wren::Client.new(:user => 't123', :pwd => 'fido')

If you're just using the default configuration, that's fine too. client = Wren::Client.new

==== GET requests

To call the GET method on a resource, simply chain method calls together like they were parts of the URI. The request will replace the periods with slashes. At the end of the chain, call the "get" method. client.account.rate_limit_status.get

=> returns a Hash object

If your request requires authentication, call the "auth" method as part of the chain. client.direct_messages.auth.get

=> returns an Array object

If your request requires query parameters, pass them in as a hash using the "options" method as part of the query chain. client.friends.ids.options(:screen_name => 't123').get

=> returns an Array object

And, of course, you can use both "auth" and "options" methods. client.favorites.auth.options(:id => 't123', :page => 3)

=> returns an Array object

==== POST requests

Calling a POST method on a resource behaves much like a GET resource, except that you call the "post" method. The "post" method takes a hash of data to send. Authentication is assumed, so you don't need to call the "auth" method. client.statuses.update.post(:status => 'Is this thing on?')

=> returns a Hash object

Some POST methods require query parameters, and that's fine. client.friendships.destroy.options(:screen_name => 't123').post

=> returns a Hash object

==== One-liner?

It's certainly possible to combine much of this into a one-liner, if you have a screen that's wide enough. Wren::Client.new(:user => 't123', :pwd => 'fido').statuses.update.post(:status => 'Wow!')

=> returns a Hash object

== License

(MIT License)

Copyright (c) 2009 Reductive Reason LLC

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.

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc