Use gem1.8 if available

Trema now requires ruby 1.8 and does not support ruby 1.9.x.
When multiple versions of ruby is installed, we must use gem for
ruby 1.8. By this commit gem1.8 is checked first.