Ruby: Portable Social Network Lib
October 24th, 2007 by Steve IvySteve Ivy, steveivy@gmail.com
PSN is a ruby library for consuming/providing Portable Social Network services in social web apps, written by Steve Ivy (http://redmonk.net). This code is GPL’d, and I hope that it will help others who are just starting out (like me! :-))
What Does It Do?
PSN provides a set of ruby classes that spider, parse and provide facilities for storing social network data. The basic classes are Profile and Friend (Person).
include PSN
profile = Profile.new_from_uri('http://redmonk.net/about-this-site',
:enforce_reciprocal_related=>true,
:do_related=>true)
puts "# NAME: #{profile.hcard.fn}"
puts "#{profile.hcard.note}"
pp profile
puts "## RELATED PROFILES"
profile.related_profiles.each do |uri, rp|
puts "* #{uri} #{rp.hcard.fn} (from #{rp.uri})"
rp.friends.each do |f|
puts "** #{f.name} (#{f.link})"
end
end
Goal
The goal is to create a library of classes that can be mixed into an existing application or used as a foundation for a new application. The app would provide basic storage, while the library makes it easy for the host app to consume and provide PSN services.
Try It Out
Be aware that this is very very early code - only about 1/3rd of what I want to do has been done.
Further Reading
- Kevin Lawver: Portable Social Networks at Mashup Camp — I really want to see if this work and Kevin’s can be (ready drum roll) mashed up somehow
- Gavin Bell: What is your provenance?
- Jeremy Keith: Twittering
Here’s what I want: when I go to the latest social networking fadsite, I want it to ask for my URL. Then it can go off and fetch my hCard and XFN list. A pre-filled form for my details and a pre-filled list of potential contacts can then be presented to me. I’m not saying that this should be the only way of signing up but wouldn’t it be a nice added extra for those of us already using microformats?
TODO:
So much:- implement validation for reciprocal relationships on profile.related_profiles
- hcard -> profile
- friend list -> xfn
Done:
- implement validation for xfn relationships
- tests for Friend and relation vlidation



