being a linux enthusiast, when looking for quotes for this blog – and playing with ruby / learning how to write and package gems – what else could have been my first thought than displaying random quotes using the ‘notorious’ fortune program on this blog.
a quick search on github resulted lacco’s ruby-fortunes — a library that provides fortunes using a network service.
well, i’m wondering why one needs a fortune webservice (assuming that fortune is needed in a linux-box-hosted-project; others rather need luck and spend a fortune ;-) ), though it’s definitely a convenient idea to provide network access to fortune.
anyway, since i have fortune right at my fingertips to my servertops and wanted to play with ruby gem creation, thought to create a gem for linux / unix machines with rails projects. (though it might work on win-whatever too, having cygwin installed for example; have not tested, nor researched this matter or the existence of fortune ports to win)
the current, humble version 0.0.2 was in fact only tested on gentoo and a demo has been installed to this blog, on the home page
installing it was simple as:
- install gem
sudo gem install linux_fortune
- use the gem (edit config/environment.rb)
config.gem "linux_fortune"
- finally call fortune from the site index template the following line:
<div class="fortune"><%= LinuxFortune.generate.body.gsub(/\n/, "<br/>") %></div>
for more details and source code, see the project page on GitHub and the gem page