gem is provided by ruby in Ubuntu Trusty.

The 'rubygems' package no longer exists in Ubuntu 14.04 LTS 'Trusty'.

This commit adds support for the distinction while keeping backwards compatibility.