Rails: Quick overview of licenses in used Gems

1 minute read

Out Of Date Warning

This article was published on 23/06/2013, this means the content may be out of date or no longer relevant.
You should verify that the technical information in this article is still up to date before relying upon it for your own purposes.

Using Gems is easy, but most people forget that Gems usually comes with a license. Here is a short command do find out used licenses:

  flat_map{|k,v| v.licenses.map{|license| [k, license]}}.
  reduce({}){|a,e| gem,license = e; a[license] ||= []; a[license] << gem; a}.
  map{|k,v|"#{k}: #{v.join(", ")}"}

Works great with bundler, which requires all Gems before. Most Gems are licensed under MIT, but some require more attention.

Caveat: Some Gems have no license written and/or the Rubygems licenses array is empty, dispite looking into the Gem, you can find one.