Updating the official Ruby libraries
We’re happy to announce a big update for both of our official Ruby libraries: postmark 1.0 — Ruby developer’s little helper — and postmark-rails 0.5.0, specifically crafted for Ruby on Rails and ActionMailer.
Keeping up with the latest improvements #
Recently, while writing documentation for the Postmark Heroku Add-on, I had an opportunity to play with Postmark libraries for different programming languages and frameworks, built by our awesome community. It didn’t take too long to realise that we might learn a lot from them. When we first released the gems in 2009, our goals were pragmatic: by integrating with the TMail library we targeted Ruby on Rails projects and the other software already running in production. Later we added more features and support for the Ruby Mail library, which now finally replaced TMail. Still it was clear that at some point we’d need to rethink what our customers want from the libraries. At that same time, the Ruby community evolved peculiarly fast: new tools and gems appeared, became popular and faded out quickly. So we took time to focus on Postmark development, while only issuing bug fixes for the libraries.
So, what has changed in Ruby since 2009? First, the tools and the whole infrastructure have significantly matured. Bundler, RSpec 2 and the new language features have brought the developer’s experience to a new level. Thanks to the amazing Travic-CI continuous integration service, the value of automated testing has grown even more, although it had always been particularly high in the Ruby community. Practicality of Ruby development has moved further with automated monitoring of projects’ code quality provided by Code Climate for free to all open source projects. The other trend is the uprising demand for concurrency support, popularised by JRuby’s real threading, Celluloid and Sidekiq. I’m glad to see how the influence of functional programming languages is affecting the Ruby community, which now favours pure data structures and tries to avoid unneeded abstractions and reduce the amount of mutable state in code.
The goal was not to just bring all those amazing new things to the libraries, but to see how it affects the real value, how it makes our customers’ happy. Whenever you think about the architectural changes, backward compatibility is always a concern. We were able to keep the public interfaces fully compatible with the legacy versions, while changing almost everything behind it. The new architecture is ready to be used by concurrent applications: whenever the old version failed or used memory locking, the new one allows you to take the most from the multi-threaded approach.
Better integration and more features #
While Postmark as a service has always tried to simplify the way you send your application’s emails, the postmark gem required you to additionally install the Ruby Mail library, which was designed to work with traditional email interfaces. It’s no longer true: the gem now allows you to send emails right away, as easy as using the pure ruby hashes.
While making sure the new libraries are architecturally tidy, we introduced the support for some lesser-known features of the Postmark API. Now you can send emails in batches, work with bounces and change a server’s info easily. We also added a way to give Postmark’s inbound JSON some Ruby flavour, so the keys are underscored symbols instead of camelized strings. Check out the README file for more examples.
The biggest challenge was to properly test the new libraries and take advantage of the Travis-CI service. After adding a sufficient unit test suite written in RSpec 2.0, I took advantage of the Postmark test API key, which allowed me to interact with the real API in the integration tests. This way it doesn’t unveil any sensitive information or require fake HTTP requests to be used. As a finishing touch I added Code Climate monitoring for the libs, and they both received the highest score of 4.0. Of course, that result can not be fully trusted, and personally I see a lot of room for improvement, but it definitely makes us proud of the achieved results.
We’re sorry it took so long, but we sincerely hope you’ll love the updates now that they’re released. Please file issues on Github or email support if you face any problems with the updated libraries. We’re always open for contributions, and if you’re willing to add something to the libraries, we’ll be happy to accept your pull requests.