I want to edit Ruby files using Python scripts and I need to
- Check if a function call exists within a class, add if not present, check function call args if present and change accordingly
- Check if a function def exists and if not insert a function definition inside a class
- Points 1 and 2 for blocks (and also for classes and modules)
- When rebuilding the edited file comments should be intact
Suggest me a Ruby/Rails parser written in Python. Also, tell me if it is a lot easier in Ruby itself rather than finding a library in Python, and if that would give me a lot more flexibility and even more abilities to control the Ruby files.