FEB 25
Wow. (Okay, not exactly “using”, but close enough.) Came upon RBook, another Facebook API library for Ruby. I think that makes three so far. This one apparently takes a few techniques out of my own ruby-facebook library, although I’m not quite sure what exactly.
However, I still really dig several things about my implementation that I haven’t seen in other ones (yet). One is how you get the query response back as a Hash. Making a call to Message.GetCount will return a hash with total and unread as keys. Currently, the values for each key are autoconverted into integers if possible, as I make the assumption that a string consisting of all numbers is meant to be an actual number.
Another nicety is that making API queries is a touch more natural (at least, in my opinion). Basically, the following calls are all valid (given that f is an instance of Facebook::Session):
f.messages.get_count f.messages.getCount f.messages_get_count f.messages_getCount f.session_request("messages.getCount")
I happen to think that this is pretty nifty. The implementation is somewhat nastier, as I create another class to handle the subsequent message of get_count or getCount. I have a feeling that there’s a more elegant way to handle this, but I’m punting for now, as this works. (Possibly making an eigenclass from the current object that holds the request category? Hmm, it seems possible. Don’t know if it would be more elegant though.)
The last nifty bit from my implementation is that to add new API calls, all you need to do (theoretically) is to dump them into Facebook::REQUESTS, which is an Array that holds the valid API calls.
Not that there’s a right or wrong way to go about implementation and design, but those are just features of my library that I really dig.
But speaking of ruby-facebook, it’s about time that I updated it to match Facebook’s updated API. I haven’t touched it since August, so hopefully I’ll find some time to fix it up later this week. Writing some test cases would probably be a good idea, but I really don’t want to muck with testing base_request, as that would require me to figure out how to fake the Facebook server. The other thing that I should do is figure out how to get rid of MetaSession, but honestly, I think doing so in an elegant way is going to require much more thought and work than I’m willing to put into the update.
Indeed, it is true. And as an added bonus, you also get a snippet of my .bash_profile in Cygwin.
pbcopy.cmd:
@ruby "c:/Documents and Settings/alphach.redmond/bin/pbcopy.rb"
pbcopy.rb:
#!/usr/bin/env ruby require 'win32/clipboard' Win32::Clipboard.set_data(ARGF.read)
pbpaste.cmd:
@ruby "c:/Documents and Settings/alphach.redmond/bin/pbpaste.rb"
pbpaste.rb:
#!/usr/bin/env ruby require 'win32/clipboard' puts Win32::Clipboard.data
.bash_profile:
if $cygwin; then alias pbpaste=/home/alphach/bin/pbpaste.cmd alias pbcopy=/home/alphach/bin/pbcopy.cmd fi
This aliasing is a hack to properly use pbpaste without calling pbpaste.cmd. Basically, being able to write pbpaste > temp.txt instead of pbpaste.cmd > temp.txt. Currently, Cygwin’s automatic command aliasing isn’t working quite right. I’m going to look into it when I have the time.
Edit: I later discovered that getclip and putclip accomplish the same thing in Cygwin, so I can just alias pbcopy and pbpaste to those commands! No need for all this hassle.