Open Source Roundup: Rails, Rubygems.org, and LicenseFinder

September 7, 2012 Matthew Parker

Having just come off a project, Ian Lesperance and I spent the week working on some open source initiatives. We also spent the week showing new pivot David Edwards the ropes.

We started the week with a feature request to rails for customized STI (Single Table Inheritance) type serialization. On the project we just finished, we needed to model a legacy database that serialized integers instead of class names for the STI type, and unfortunately we found that Rails had no real API for overriding the type serialization, so we added the following:

class Foo < ActiveRecord::Base
  self.inheritance_serializer = ->(klass) do
    # Map the class to the appropriate type identifier.
    # Defaults to `klass.name`.
  end

  self.inheritance_deserializer = ->(type_before_cast) do
    # Map the type identifier back into the appropriate class.
    # Defaults (approximately) to `type_before_cast.constantize`.
  end
end

Ian also contributed a bug fix to ActiveRecord, fixing the pluck method when the column name plucked is a reserved word.

We then continued with a pull request to rubygems.org for adding license information to gem version pages and version api requests. In our line of work, we have to keep a vigilant eye on the software licenses of our dependencies; adding more exposure of licenses can’t hurt.

This segued nicely into some much needed work on LicenseFinder, an open source project Pivotal Labs created and maintains to automate the process of keeping track of your project’s license dependencies. We’ve added detection for two more license types (”LGPL” and “ISC”), added proper integration tests to the project, put the project on Travis-CI, and refactored some of the code along the way. In the future, we’d like to create a proper command line interface for license_finder so that you can use it without rake.

About the Author

Matthew Parker

Matt Parker is Head of Engineering for Pivotal Labs

Previous
Camp Fun All Year Long With Timber Lake Camps App
Camp Fun All Year Long With Timber Lake Camps App

Kids won't have to say goodbye to summer with the Timber Lake Camp apps. Timber Lake Camp, based in New Yo...

Next
"Data Is" or "Data Are"?
"Data Is" or "Data Are"?

“Data is” or “data are”? It’s the type of sticky linguistic thicket that invites vociferous debate. Working...