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:
- To have a unique RVM gemset setup automatically with an rvmrc file already trusted
- Have watchr running your unit and integrations tests on save, notifying you on Growl, working out of the box
- Have users using Devise and omniauth Facebook login working already and included in the layout?
- Automatically update the css/html/js in the browser after saving without needing to reload the page by using livereload?
- 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.
- A one click heroku deploy
- Ruby debugger, wirble, looksee and more ready for debugging
- A sensible gitignore
- All those annoying files you never use removed
- 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
- This is Mac only and will remain Mac only. Sorry.
- 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.
- Gems are installed inline instead of in one big file.
- Rspec and Cucumber are not included by default since the new best practice is to stay with Test::Unit. DHH was right all along.
- A commit is made after every step with a descriptive message.
- 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
- 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
- Omniauth too. Everyone wants to login with Facebook Twitter these days.
- Comments removed from routes and env files.
- Debugging tools: ruby-debug
- Terminal tools: awesome_print, looksee and map_by_method
- Exception Notification: because you should care
- Heroku deploy
- Fast backup using Heroku
- Set rid of annoying files like public/index.html
- Decent Exposure: finally controllers start making sense
- RVM gemsets. You are using these right?
- A sensible gitignore
- A Textile readme
- Automatically setting all attributes to protected. Anti-hacking glory.
- Google Analytics
- SEOHelper Methods
- Better Forms with SimpleForm
- Sitemaps
- Watchr. Encourage us to test more.
- CarrierWave: modern file uploading done right.
- Friendly-ID for permalinks
- Rails-erd for diagrams of your DB and its connections
Use with:
rake erd
Creates file ERD.pdf :-) May require brew installations to workbrew 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..
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