Scribd_fu Paperclip goodness

So over the past month or so I refactored Matt Darby's awesome scribd_fu plugin ( to work with Paperclip in addition to attachment_fu. I'm more a fan of Paperclip, as it turns out, and had been meaning to switch OpenStudy to Paperclip. Well, I finally got around to doing both, but then I sat on my code for a little while before working on merging it back into mdarby's main repository.

First lesson learned: before you start a crazy refactoring job, make sure to pull from the repository you forked. At least if you intend on merging back. Turns out, when I started hacking, the main scribd_fu repository was about 8 commits ahead of mine. I realized this about 10 commits into mine, at which point I was past the point of no return. I finished up my refactoring, and, over the last week or so, I merged the changes from the main repository back into the newly refactored code, making it work for both attachment_fu and Paperclip. All in all, it was a fun exercise in `think before you start hacking'.

Still, the end result is sexy: installing the mdarby-scribd_fu gem from github will work happily, and you can use config.gem from Rails 2.1+ to delightfully have that taken care of for you. Meantime, it ensures that the rscribd gem is present, as well. Plus, it automatically figures out whether you are using Paperclip or attachment_fu and behaves accordingly.

One thing to note is that, since you are installing from, the rscribd dependency will only be resolved automatically if you have in your Rubygems sources and do a

  $ gem install mdarby-scribd_fu

If you include a --source directive, things won't go so well, and you will instead get this nasty bugger:

 $ sudo gem install mdarby-scribd_fu --source
  ERROR:  Error installing mdarby-scribd_fu:
        mdarby-scribd_fu requires rscribd (>= 0, runtime)

Icky! Anyway, if you'd rather not add github to your sources, then go ahead and install the rscribd gem manually first. If you still want to use config.gem, just make sure to config.gem 'rscribd' before mdarby-scribd_fu.

A few notes about the release:

* The old acts_as_scribd_document method should continue to work without your doing anything if you use attachment_fu.
* Optionally, you can switch to the has_scribdable_attachment method with no parameters for attachment_fu.
* When using Paperclip, you have to use has_scribdable_attachment and pass it the attachment that should be sent to scribd for conversion as a symbol.
* Validations now work. Before, uploads happened after_save, and validations relied on results that came only after the upload took place (e.g., the presence of scribd_id). Now the upload is run before_validation, so that the validations have the data available. The price for this is that an extra temporary file may have to be created to execute the upload.

All Paperclip-related methods take the scribdable attachment as a symbol. In the case of the view helper, the attribute is the second parameter. This gives the scribd_document method two forms:

* scribd_document(model, alternate_text) for attachment_fu and
* scribd_document(model, attachment, alternate_text) for Paperclip.

The alternate_text can be left off for both.

I haven't had a chance to really hammer this thing with tests, though my limited testing does show that it works just spiffily. Any bugs can be reported by listing them on the scribd_fu wiki ( Enjoy, and let us know about problems!

I'm Caving...

Slowly but surely, I'm caving to OS X. I mean, I have principles, right: I run Kubuntu on my Lenovo X60 tablet, and I run OpenSUSE
(11.0, soon 11.1, natch) on my desktop. But recently I had an encounter with a dual-monitor Mac Pro at work, where I've been doing most of my work.
I hate fanboyism, really. But damn, OS X looks sexy. KDE 4 is slowly getting there, of course. It's been looking more sexy every week since it was released (at least if you follow SVN). But... Damn, OS X looks sexy. There's no two ways about it. So I find myself caving. Sometime soon, when I start my new job, I can ask for a new laptop from the company (of course, it will stay with the company if and when I decide to leave). And I am seriously considering asking for a Macbook Pro instead of a Lenovo X200 tablet. Sure, the Lenovo is a tablet (which I have found to be quite useful), and sure the documentation says it's got an estimated battery life of 10 hours (!!!). But... Damn, OS X looks sexy.
I'm a coder, right. So I spend a lot of my time reading text, be it code or blog posts. And the thing that most stands out for me about OS X is those damn awesome fonts. They just look great. It's kind of like being used to Word docs and then looking at LaTeX for the first time. Your eyes kind of burst out in song, y'know? In case you're thinking `oh, but that's not reason enough to switch'... Well, it can be.
I'm also getting tired of tinkering. I mean, I love tinkering, but I'm getting tired of tinkering with my OS. I'm sort of sick of my laptop
occasionally deciding to stop accepting my mouse (when someone decides to blacklist the ohci driver) or deciding not to go to sleep. I'm annoyed by the fact that my darn nvidia card in my desktop still won't play nice with KDE 4 (by the way, I have no illusions about where the blame lies: nvidia, your drivers kick ass, but clearly they still need some work).
So my current plan is this: ask for a Macbook Pro for work. This will be my work computer, and it will work flawlessly and all that.
Meantime, I'll slowly be upgrading my home desktop. It's going to stick to dual-booting Windows and Linux, and that way I have all three environments to toy with. In particular, my recently-acquired copy of Crysis Warhead will be played on a newly-tricked-out desktop. It'll be on Vista, but that's acceptable just for playing a game. And I will continue to use KDE 4 to code on the desktop. I'm looking forward to KDE's continued development in the direction of awesome, so I definitely want to keep an eye on it. I'm even considering starting to contribute to KDevelop.
Anyway, notice that TextMate is not important in my evaluations of whether to switch to a Mac or not. Vim all the way, baby. That, and some NetBeans goodness (with the jVi plugin) when necessary, should do the trick.
Oh, and that piece of crap called FlexBuilder, of course..