Refactoring ruby_app cookbook code.

Moving code complexity out of the recipe and templates and into the
libraries.