GithubHelp home page GithubHelp logo

arnabc / www-delicious Goto Github PK

View Code? Open in Web Editor NEW

This project forked from weppos/www-delicious

1.0 2.0 0.0 253 KB

Ruby client for del.icio.us API.

Home Page: http://code.simonecarletti.com/www-delicious

License: Other

www-delicious's Introduction

WWW::Delicious

WWW::Delicious is a Ruby client for delicious.com XML API.

It provides both read and write functionality. You can read user Posts, Tags and Bundles but you can create new Posts, Tags and Bundles as well.

WWW::Delicious maps all the original del.icio.us API calls and provides some additional convenient methods to perform common tasks. For a full API overview, visit the official Delicious API documentation.

WWW::Delicious is compatible with all delicious.com API constraints, including the requirement to set a valid user agent or wait at least one second between queries. Basically, the main benefit from using this library is that you don’t need to take care of all these low level details, if you don’t want: WWW::Delicious will try to give you the most with less efforts.

Requirements

  • Ruby >= 1.8.6 or Ruby 1.9.x

Download and Installation

This library is intended to be installed as a Gem.

$ gem install www-delicious

You might need administrator privileges on your system to install it.

If you need the latest development version you can download the source code from GitHub. Beware that the code might not be as stable as the official release.

Getting Started

In order to use this library you need a valid Delicious account. Go to delicious.com and register for a new account if you don’t already have one.

Then create a valid instance of WWW::Delicious providing your account credentials.

require 'www/delicious'

# create a new instance with given username and password
d = WWW::Delicious.new('username', 'password')

Now you can use your instance to interact with the API interface.

Last account update

The following example show you how to get the last account update Time.

require 'www/delicious'
d = WWW::Delicious.new('username', 'password')

time = d.update # => Fri May 02 18:02:48 UTC 2008

Reading Posts

You can fetch your posts in 3 different ways:

require 'www/delicious'
d = WWW::Delicious.new('username', 'password')

# 1. get all posts
posts = d.posts_all

# 2. get recent posts
posts = d.posts_recent

# 3. get a single post (the latest one if no criteria is given)
posts = d.posts_get(:tag => 'ruby')

Each post call accepts some options to refine your search. For example, you can always search for posts matching a specific tag.

posts = d.posts_all(:tag => 'ruby')
posts = d.posts_recent(:tag => 'ruby')
posts = d.posts_get(:tag => 'ruby')

Creating a new Post

require 'www/delicious'
d = WWW::Delicious.new('username', 'password')

# add a post from options
d.posts_add(:url => 'http://www.simonecarletti.com/', :title => 'Cool site!')

# add a post from WWW::Delicious::Post
d.posts_add(WWW::Delicious::Post.new(:url => 'http://www.simonecarletti.com/', :title => 'Cool site!'))

Deleting a Posts

require 'www/delicious'
d = WWW::Delicious.new('username', 'password')

# delete given post (the URL can be either a string or an URI)
d.posts_delete('http://www.foobar.com/')

Note. Actually you cannot delete a post from a WWW::Delicious::Post instance. It means, the following example doesn’t work as some ActiveRecord user might expect.

post = WWW::Delicious::Post.new(:url => 'http://www.foobar.com/')
post.delete

This feature is already in the TODO list. For now, use the following workaround to delete a given Post.

# delete a post from an existing post = WWW::Delicious::Post
d.posts_delete(post.url)

Tags

Working with tags it’s really easy. You can get all your tags or rename an existing tag.

require 'www/delicious'
d = WWW::Delicious.new('username', 'password')

# get all tags
tags = d.tags_get

# print all tag names
tags.each { |t| puts t.name }

# rename the tag gems to gem
d.tags_rename('gems', 'gem')

Bundles

WWW::Delicious enables you to get all bundles from given account.

require 'www/delicious'
d = WWW::Delicious.new('username', 'password')

# get all bundles
bundles = d.bundles_all

# print all bundle names
bundles.each { |b| puts b.name }

You can also create new bundles or delete existing ones.

require 'www/delicious'
d = WWW::Delicious.new('username', 'password')

# set a new bundle for tags ruby, rails and gem
d.bundles_set('MyBundle', %w(ruby rails gem))

# delete the old bundle
d.bundles_delete('OldBundle')

Credits

Author

Simone Carletti <[email protected]>

Resources

FeedBack and Bug reports

Feel free to email Simone Carletti with any questions or feedback.

Please use the Ticket System to submit bug reports or feature request.

Changelog

See the CHANGELOG.rdoc file for details.

License

Copyright © 2008-2010 Simone Carletti, WWW::Delicious is released under the MIT license.

www-delicious's People

Contributors

weppos avatar

Stargazers

Arnab Chakraborty avatar

Watchers

Arnab Chakraborty avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.