That depends on the project in question. Some projects have a *.gemspec file in their root directory. In that case, it would be:
gem build GEMNAME.gemspec
gem install gemname-version.gem
Other projects have a rake task, called gem or build or something like that. In that case you have to invoke rake <taskname>, but that depends on the project.
In both cases you have to download the source.