require 'net/http' require 'net/smtp' require 'rss/1.0' class BookmarkInfo attr_reader :title, :description def initialize(title, description) @title = title @description = description end end class Bookmark attr_reader :link, :infos def initialize (link) @link = link @infos = [] end def add(info) @infos.push info end end class BookmarkReader def initialize(user) @user = user @bookmarkByLink = {} end def proxy(host,port,user,password) @proxyHost = host @proxyPort = port @proxyUser = user @proxyPassword = password end def read Net::HTTP::Proxy( @proxyHost, @proxyPort, @proxyUser, @proxyPassword ).start('del.icio.us', 80) { |http| response = http.get("/rss/subscriptions/#{@user}") rss = RSS::Parser.parse(response.body, true) rss.items.each { |item| bookmark = @bookmarkByLink[item.link] if bookmark.nil? bookmark = Bookmark.new(item.link) @bookmarkByLink[item.link] = bookmark end bookmark.add(BookmarkInfo.new(item.title, item.description)) } } end def export temp = '' @bookmarkByLink.each { |link, bookmark| temp += bookmark.link + "\n" bookmark.infos.each { |info| temp += " #{info.title}\n" temp += " #{info.description}" if info.description } } temp end end class MailSender def initialize(host,port) @host = host @port = port end def send(from,to,subject,text) msgstr = <