So I was writing my first iPhone on Rails app when my Google Reader dropped some pretty awful news on me. Somebody pre-empted my release with their (pretty excellent, but poorly named) “Bargain Bin with Push!” app (iTunes link).
The Bad News
“Bargain Bin with Push!” does pretty much exactly what my app was going to do. It provides push notifications when apps you’re interested in drop in price. Instead of raging against the dying of the light, I’ve decided to just user their app and let mine go gently into that good night.
The Good News
All was not lost. I learned a ton along the way and decided to open-source the module I was using to fetch app information out of Apple’s App Store.
A project I’m working on required a little more from Ruby’s TMail library than it offers out of the box. One of the things that make Ruby great is how you can dynamically extend classes.
TMail can parse a raw email and provide you with the headers, subject, body, etc. But what it doesn’t do is parse the body and pull out the html and/or plaintext from multi-part emails. Well, now it can.
Fernando’s code was great, but its intent was returning just the html from the email body. For my current project, I am more interested in just the plaintext from the email body, so I added this functionality.
Thanks to the openness of the Apache License 2.0, I was able to extend his script and re-release it on GitHub with my modifications.
Now its trivial to return just the html from an email body, or just the plaintext:
require"rubygems"require"action_mailer"require"tmail_mail_extension"
mail = TMail::Mail.parse(raw_email)
mail.body_html# returns just html if available or nil
mail.body_plain# returns just plaintext if available or nil
I decided to source out a few random Ruby scripts I use to interface with Amazon’s Simple Storage Service (S3) from the command line. Right now there are scripts which allow:
Duplicating a local folder in a specified S3 bucket (recursively)
Listing all buckets and files stored on an S3 account
Uploading a specified file to a specified S3 bucket
Downloading a specified file from a specified S3 bucket.
I’m sure the functionality will grow as needs arise. For now, check out the repo on GitHub