Move Ruby code to gem