eplaced the bash version with a ruby version

This also includes tests