1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
= WWW::Delicious
WWW::Delicious is a Ruby client for http://del.icio.us 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.
== Overview
WWW::Delicious maps all the original del.icio.us API calls and provides some
additional convenient methods to perform common tasks.
Please read the official documentation (http://del.icio.us/help/api/)
to learn more about del.icio.us API.
WWW::Delicious is 100% compatible with all del.icio.us 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.
== Dependencies
* Ruby >= 1.8.6 (not tested with previous versions)
As of release 0.3.0, WWW::Delicious is compatible with Ruby 1.9.1.
== Download and Installation
RubyGems[http://rubyforge.org/projects/rubygems/] is the preferred install method.
To get the latest version, simply type the following instruction into your command prompt:
$ sudo gem install www-delicious
Depending on your system, you might need su privileges.
To install the library manually, downlad the latest version from
navigate to the root library directory and enter:
$ sudo ruby setup.rb
If you need the latest development version you can download the source code
from one of the GIT repositories listed above.
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 del.icio.us account.
Go to http://del.icio.us/ 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')
== Author
{Simone Carletti}[http://www.simonecarletti.com/] <weppos@weppos.net>
== Resources
* {Homepage}[http://code.simonecarletti.com/www-delicious]
* {API}[http://www-delicious.rubyforge.org/]
* {GitHub}[http://github.com/weppos/www-delicious/]
* {RubyForge}[http://rubyforge.org/projects/www-delicious/]
== FeedBack and Bug reports
Feel free to email {Simone Carletti}[mailto:weppos@weppos.net] with any questions or feedback.
Please use the {Ticket System}[http://code.simonecarletti.com/projects/show/www-delicious] to submit bug reports or feature request.
== Changelog
See the CHANGELOG.rdoc file for details.
== License
Copyright (c) 2008-2009 Simone Carletti, WWW::Delicious is released under the MIT license.
|