Some improvements to define ruby in script