This gem is a delicious.com oAuth API client. It supports pretty much everything delicious API allows to do:
- Manage bookmarks (get, create, delete)
- Manage bundles (get, create, delete)
- Manage tags (get, rename, delete)
Delicious API requires you to obtain user's oAuth token in order to access his/her account programmatically.
Ruby versions higher than or equal to 1.9.3
are supported.
Add the following line into your Gemfile:
gem 'delicious', '~> 1.0.0'
You should obtain access token first.
client = Delicious::Client.new do |config|
config.access_token = 'my-access-token'
end
client.bookmarks.all
returns all bookmarks created by user associated with access token. You can paginate results:
client.bookmarks.all.offset(50).limit(100)
It's possible to filter by tag, starting and ending dates:
client.bookmarks.all.tag('angular').from('2013/11/12 10:23:00').to('2013/11/13 12:10:00')
client.bookmarks.create url: 'http://example.com',
description: 'Example bookmark',
tags: 'tag1,tag2,tag3'
It returns an instance of Delicious::Post
which responds to persisted?
.
If you have an instance of Delicious::Post
which was saved, you can call delete
on it:
post = client.bookmarks.create url: 'http://example.com', description: 'Example bookmark'
post.delete if post.persisted? # => true if bookmark was deleted, false otherwise
You can also delete bookmark with a client:
client.bookmarks.delete url: 'http://example.com' # => true if bookmark was deleted, false otherwise
Bundles are named list of tags. See the following example for how to create a new bundle:
bundle = client.bundles.set 'bundlename', %w(tag1 tag2)
It returns an instance of Delicious::Bundle
on success and throws Delicious::Error
if something went wrong on the server.
You can call bundle.delete
or client.bundles.delete('bundlename')
to delete existing bundle. It returns true
on successful deletion and false
otherwise.
bundle = client.bundles.find 'bundlename'
bundles = client.bundles.all
tags = client.tags.all
client.tags.delete 'tag'
client.tags.rename 'old_name', 'new_name'