To gain the benefit of integrated code-quality analysis within my continuous integration process for my Ruby projects, I’ve been integrating the excellent Metric_Fu package by Jake Scruggs. I’ve now completed an installation on OS-X, CentOS and Red-Hat where I had some quirks to resolve on CentOS and RedHat. This post provides my view on the best install procedure I can offer.
First the underlying OS package pre-requisites…
sudo yum install libxml2 => v2.6.26-184.108.40.206
sudo yum install libxml2-devel => v2.6.26-2.1.2
sudo yum install libxslt => v1.1.17-2
sudo yum install libxslt-devel => v1.1.17-2
sudo yum install ImageMagick => v220.127.116.11-3.el5.4(see note) sudo yum install ImageMagick-devel => v18.104.22.168-3.el5.4
Note the version of the ImageMagick package I have installed. There is a version depenency here with the rmagick gem which is installed in the next section. As far as I can see, for this version of the ImageMagick package, you must install the v1.x gem. As such I installed the highest version of the gem v1.15.17 below the v2.x.x baseline. If you have later versions of this ImageMagick package then I believe you can avoid this particular issue.
The TrueType Fonts dependency…
The rmagick gem has an installation dependency on the the presence of a set of true-type fonts in the base OS installation. On both the CentOS and RedHat installs I have done, this issue has been present. So before we go ahead and install the gems, we need to rectify this issue.The dependency relates to the presence of the /usr/share/fonts/default/TrueType folder which needs to be created with the following steps. (Note – you don’t need to install these fonts if you already have TrueType fonts installed – in which case skip to the next section).
yum install rpm-build wget http://www.cabextract.org.uk/cabextract-1.2-1.i386.rpm rpm -ivh cabextract-1.2-1.i386.rpm wget http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec rpmbuild -ba msttcorefonts-2.0-1.spec rpm -ivh /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm cd /usr/share/fonts/default ln -s /usr/share/fonts/msttcorefonts/ TrueType
Now the Gems…
Then install the gems:
sudo gem sources -a http://gems.github.com sudo gem install jscruggs-metric_fu
Note at this point one of the installed depenencies, the ‘flog’ gem at v2.1.2, has an issue that will prevent it from running. I have explicitly modified the following file to get this to work:
Change the line: flogger.flog_files ARGV to flogger.flog ARGV and save the file. This is only a quick-n-dirty solution to get the flog integration to work within metric_fu.
sudo gem install reek sudo gem install roodi sudo gem install gruff sudo gem install rmagick -v 1.15.17
When these gem installations complete you’re now ready to play with Metric_Fu. For more information on next steps refer to this article about some more version specific fixes or Jakes Metric_fu home.