Delicious_api
Description
delicious_api is a pure Ruby client for the Delicious API. It provides an easy
way to read/write bookmarks, tags and bundles to Delicious accounts.
Features
- an object oriented design:
Bookmark
,Tag
andBundle
classes - 100% covered by tests (check it for yourself!)
- 100% documented
- 100% Ruby 1.9 compatibility
Installation
The following gems are required:
sudo gem install activesupport hpricot
and then you can (and should) get it as a gem:
sudo gem install jbgutierrez-delicious_api --source http://gems.github.com
Basic Usage
Set up a DeliciousApi::Wrapper.
DeliciousApi::Base.wrapper = DeliciousApi::Wrapper.new 'account', 'secret'
Optionally, name your client (a.k.a. ‘user agent’) to something identifiable, such as your app’s name.
DeliciousApi::Base.wrapper = DeliciousApi::Wrapper.new 'account', 'secret', :user_agent => 'your-app-name'
In order not to get throttled, it will be a time gap of 1 second between each inner http request. Change this behaviour at your own risk:
DeliciousApi::Base.wrapper = DeliciousApi::Wrapper.new 'account', 'secret', :waiting_time_gap => 0
Easy examples
Bookmarks retrieval
bookmark = DeliciousApi::Bookmark.find 'http://www.yahoo.com/' bookmarks = DeliciousApi::Bookmark.find_by_date Date.now, :tags => %w[yahoo web search] bookmarks = DeliciousApi::Bookmark.find_recent :tag => 'yahoo', :limit => 10 bookmarks = DeliciousApi::Bookmark.find_all :tag => 'yahoo', :limit => 10 bookmarks = DeliciousApi::Bookmark.find_all :start_time => 2.days.ago, :end_time => Time.now
Creating a new bookmark
bookmark = DeliciousApi::Bookmark.new 'http://www.yahoo.com/' bookmark.save
Deleting a bookmark
bookmark = DeliciousApi::Bookmark.find :url => 'http://www.yahoo.com/' bookmark.destroy
Updating a bookmark
bookmark = DeliciousApi::Bookmark.find :url => 'http://www.yahoo.com/' bookmark.description = 'Yahoo!' bookmark.extended = 'My favorite site ever' bookmark.tags = %w[array of tags] bookmark.save # returns false bookmark.save! # returns true
Copy Bookmarks between diferent accounts
#!/usr/bin/env ruby -wKU require 'rubygems' require 'delicious_api' DeliciousApi::Base.wrapper = DeliciousApi::Wrapper.new 'source_account', 'secret' bookmarks = DeliciousApi::Bookmark.all DeliciousApi::Base.wrapper = DeliciousApi::Wrapper.new 'target_account', 'secret' bookmarks.each { |b| b.save }
Todo
The following specs are pending:
- should check to see when a user last posted an item. (PENDING: Not Yet Implemented)
- should list dates on which bookmarks were posted (PENDING: Not Yet Implemented)
- should fetch a change detection manifest of all items (PENDING: Not Yet Implemented)
- should set User-Agent to something identifiable (PENDING: Not Yet Implemented)
Author
License
See the terms of usage for the Delicious API
Copyright © 2009 by Javier Blanco Gutierrez under the MIT License
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.