KittyGen: Rails 3.2 Application Template Management System

Shave hours off your next project and amaze your client and friends. This productivity crazed rails developer in london has put all his favourite configurations and gems into this Rails 3.1 app generator. How would you like:

  1. To have a unique RVM gemset setup automatically with an rvmrc file already trusted
  2. Have watchr running your unit and integrations tests on save, notifying you on Growl, working out of the box
  3. Have users using Devise and omniauth Facebook login working already and included in the layout?
  4. Automatically update the css/html/js in the browser after saving without needing to reload the page by using livereload?
  5. Have a simple RailsCast style layout (in sass) with homepage, about page and layout page written using slim, which is like haml, but faster and better.
  6. A one click heroku deploy
  7. Ruby debugger, wirble, looksee and more ready for debugging
  8. A sensible gitignore
  9. All those annoying files you never use removed
  10. All your configurations, e.g. for omniauth, aws, exception nofitifer and paypal filled in automatically via a global configuration file you maitain (~/.kittygenrc)

Unlike other application templates this one is packaged in a gem meaning you can call it from the command line as simply as this: $ kitty_gen new MY_NEW_APP_NAME

Not only that, but kitty_gen lets you upgrade existing applications with its modules. Want to setup “livereload”? Easy

$ kitty_gen add livereload

And to see a list of all available recipes:

$ kitty_gen list

Design Decisions

  1. This is Mac only and will remain Mac only. Sorry.
  2. Each recipe is self-contained and so should include all the gems, bundling and generation it needs to do its thing. Yes the generator is slower this way, but the advantage is modularity.
  3. Gems are installed inline instead of in one big file.
  4. Rspec and Cucumber are not included by default since the new best practice is to stay with Test::Unit. DHH was right all along.
  5. A commit is made after every step with a descriptive message.
  6. Each recipe is in its own namespace meaning that variables you assign in one recipe do not carry over to others #[not implemented] Your ~/.kitty_gen.rc file will contain the default recipes you use for new apps, alongside configuration information such as your aws, postgres password, paypal details, email address and son.

Features

  1. Create

Starts Up A Git Repo

initialize_git_repo

Railscasts style basic layout

railscasts_layout

Devise set up and installed with a user model to go.

devise_with_user

Reloads html and css changes

Assumes you have the Chrome extension installed guard Active the Live Reload button in the top right of your browser Watch the page reload on save

  1. Omniauth too. Everyone wants to login with Facebook Twitter these days.
  2. Comments removed from routes and env files.
  3. Debugging tools: ruby-debug
  4. Terminal tools: awesome_print, looksee and map_by_method
  5. Exception Notification: because you should care
  6. Heroku deploy
  7. Fast backup using Heroku
  8. Set rid of annoying files like public/index.html
  9. Decent Exposure: finally controllers start making sense
  10. RVM gemsets. You are using these right?
  11. A sensible gitignore
  12. A Textile readme
  13. Automatically setting all attributes to protected. Anti-hacking glory.
  14. Google Analytics
  15. SEOHelper Methods
  16. Better Forms with SimpleForm
  17. Sitemaps
  18. Watchr. Encourage us to test more.
  19. CarrierWave: modern file uploading done right.
  20. Friendly-ID for permalinks
  21. Rails-erd for diagrams of your DB and its connections Use with: rake erd Creates file ERD.pdf :-) May require brew installations to work brew install cairo pango graphviz

How To Use

kittygen your-new-app-name

All Possible Recipes kitty_gen_gem login_with_facebook_and_twitter reload_css_and_html_in_browser_on_save

formtastic factory_girl_with_generators decent_exposure debugging_and_console_helpers sensible_defaults setup_testing_with_capybara_testunit_and_watchr make_readme_a_textile_file basic_layout_with_login_using_slim devise_with_user_model rvm_with_gemset remove_unwanted_files add_handy_application_wide_helpers

How To Add New Recipes

Here’s the best part of this gem: it’s really easy to add your own recipes. Just follow this simple guide.

1) Choose a good, descriptive name from your recipe. For example you might one I already picked was “add_omniauth_login”.

2) Clone the gem locally and cd on in.

3)Type thor recipe:new remove_unwanted_files from within the gems source directory..

This adds a recipe_name_recipe.rb to lib/kitty_gen/recipes/. This recipe file contains the instructions you’d like KittyGen to follow when cooking up your piece of functionality.

4) Add any files you need to copy or templates you’d like to use to lib/kitty_gen/templates/recipe_name/.

5) Send a pull request and I’ll add your recipe. That way everyone can share the goodness.

6) Use these commands: copy_template file_name, final_location_in_rails_app empty_directory create an empty dir gem gem_name, :group => :gem_group

Gotcha1: If you are using a generator packaged with a gem, then you should add it to the gemspec. Solution: I’m going to do this automagically

Resources Guide to useful commands for making recipes