Class | Rubilicious |
In: |
rubilicious.rb
(CVS)
|
Parent: | Object |
Rubilicious - Delicious (del.icio.us/) bindings for Ruby.
You‘ll need to create an account at Delicious (del.icio.us/) in order to use this API.
Simple Examples:
# connect to delicious and get a list of your recent posts r = Rubilicious.new('user', 'password') r.recent.each do |post| puts "#{post['desc']}: #{post['href']}" end # add a new link to delicious r.add('http://pablotron.org/', 'Pablotron.org') # save recent funny posts to an XBEL file File::open('funny_links.xbel', 'w') do |file| file.puts r.recent('funny').to_xbel end
VERSION | = | '0.1.4' |
base_uri | [RW] | |
use_proxy | [RW] | |
user | [R] |
Connect to del.icio.us with username ‘user’ and password ‘pass’.
Note: if the username or password is incorrect, Rubilicious will not raise an exception until you make an actual call.
Example:
r = Rubilicious.new('pabs', 'password')
Post a link to delicious, along with an optional extended description, tags (as a space-delimited list), and a timestamp.
Raises an exception on error.
Example:
# add a link to pablotron to delicious r.add('http://pablotron.org/', 'Pablotron.org : The most popular site on Internet?') # add a link to paulduncan.org to delicious with an extended # description r.add('http://paulduncan.org/', "Paul Duncan", "Damn he's smooth!") # add a link with an extended description and some tags r.add('http://raggle.org/', 'Raggle', 'Console RSS Aggregator, written in Ruby.', 'rss programming ruby console xml')
Return an array of all your posts ever, optionally filtered by tag.
WARNING: This method can generate a large request to del.icio.us, and should be used sparingly, and at your own risk.
Raises an exception on error.
Example:
# save all 'art' posts to file "art_posts.txt" art_posts = r.all('art') File::open('art_posts.txt', 'w') do |file| file.puts art_posts.sort do |a, b| a['time'] <=> b['time'] end.map { |post| post['href'] } end
Returns a list of dates with the number of posts at each date. If a tag is given, return a list of dates with the number of posts with the specified tag at each date.
Raises an exception on error.
Examples:
dates = r.dates puts "date,count" dates.keys.sort.each do |date| puts "#{date},#{dates[date]}" end # same as above, but only display 'politics' tags dates = r.dates('politics') puts "date,count", dates.map { |args| args.join(',') }.join("\n")
Delete a link from Delicious.
Raises an exception on error.
Example:
# delete a link to example.com from delicious r.delete('http://example.com/')
Returns a array of inbox entries, optionally filtered by date.
Raises an exception on error.
Example:
# print a list of posts and who posted them r.inbox.each { |post| puts "#{post['user']},#{post['href']}" }
Returns a hash of dates containing inbox entries.
Raises an exception on error.
Example:
# print out a list of the 10 busiest inbox dates dates = r.inbox_dates puts dates.keys.sort { |a, b| dates[b] <=> dates[a] }.slice(0, 10)
Returns an array of posts on a given date, filtered by tag. If no date is supplied, most recent date will be used.
Raises an exception on error.
Examples:
# print out a list of recent links from oldest to newest. posts = r.posts posts.sort { |a, b| a['time'] <=> b['time'] }.each do |post| puts post['href'] end # print out a list of link descriptions from the date '2004-09-22' posts = r.posts('2004-09-22') posts.sort { |a, b| a['description'] <=> b['description'] } posts.each { |post| puts post['description'] }
Returns an array of the most recent posts, optionally filtered by tag.
Raises an exception on error.
Example:
# get the most recent links recent_links = r.recent.map { |post| post['href'] } # get the 10 most recent 'music' links recent_links = r.recent('music', 10).map { |post| post['href'] }
Renames tags across all posts.
Note: Delicious has currently disabled this feature, so it will not work until they reenable it.
Raises an exception on error.
Example:
# rename tag "rss" to "xml" r.rename('rss', 'xml')
Add a subscription, optionally to a specific tag.
Raises an exception on error.
Example:
# subscribe to 'humor' links from solarce r.sub('solarce', 'humor')
Returns a hash of your subscriptions.
Raises an exception on error.
Example:
# print out a list of subscriptions subs = r.subs puts "user:tags" subs.keys.sort.each do |sub| puts "#{sub}:#{subs[sub].join(' ')}" end
Returns a hash of tags and the number of times they’ve been used.
Raises an exception on error.
Example:
tags = r.tags puts tags.keys.sort.map { |tag| "#{tag},#{tags[tag]}" }.join("\n")
Return an XBEL string of all your posts, optionally filtered by tag.
WARNING: This method can generate a large number of requests to del.icio.us, and could be construed as abuse. Use sparingly, and at your own risk.
Raises an exception on error.
Example:
# save all posts ever in XBEL format to file "delicious.xbel" File::open('delicious.xbel', 'w') do |file| file.puts r.to_xbel end
Removes a subscription, optionally only a specific tag.
Raises an exception on error.
Example:
# unsubscribe from all links from giblet r.unsub('giblet')
Return the last update time.
Note: this method should be used before calling methods like .posts or .all to conserve on bandwidth.
Example:
t = r.update #=> "Fri Mar 11 02:45:51 EST 2005"
Return all of a user’s posts, optionally filtered by tag.
WARNING: This method can generate a large number of requests to del.icio.us, and could be construed as abuse. Use sparingly, and at your own risk.
Raises an exception on error.
Example:
# save all posts every by 'delineator' to XBEL format to file # "delineator.xbel" File::open('delineator.xbel', 'w') do |file| file.puts r.user_posts('delineator').to_xbel end