Raygun: Hit the Ground Running When You Start Your Next Project

Posted on by in Web

We start new Rails projects all the time, for client, side and internal projects. Each time we do the dance to get things just the way we like them. You probably have a similar process: switch the view library, set the database, use rspec, tweak this and that, etc. Even when you do it all the time, it still takes a little while to get to the point where you’re cranking on features.

We want to hit the ground running when starting a new project, so we created Raygun, an opinionated app generator. There are others out there, two that come to mind are Appscrolls and Suspenders. Folks have been talking about the “prime” stack (see Primo) too. We want something that captures how we do things at Carbon Five (at least on most of our projects).

What does the stack look like?


Raygun generates a new app with these libraries, all configured and ready to use:

Tweaks, Recipes, and Best Practices

Raygun also bakes in a handful of configuration tweaks that we think are useful for most projects. Here’s a sample:

  • User model with sign in, sign up, password recovery and administration (see auth* below)
  • Ready for deploying to Heroku
  • Transactional acceptance specs
  • rake db:sample_data to load a small set of data for development
  • Pull the secret token from the environment
  • Threadsafe enabled by default (as will be the case with Rails 4)
  • Enable basic auth by setting an environment variable
  • Create .ruby-version and .rvmrc
  • Use mailcatcher if it’s listening
  • Bootstrap compatible layout and custom view generator templates
  • Custom spec generator templates that use factory girl when appropriate

Code Generation

Code generated by default is usually far enough from what I want that I don’t use generators. Raygun includes custom generator templates so that scaffold (view, controllers, and specs) includes what you would expect for use with Slim, Sorcery, Cancan, Bootstrap, Rspec, and Factory Girl. It’s not perfect, but it’s more useful than what you would get otherwise.

The templates are right in the project’s lib directory, so you can tweak them for your project and its evolution.

Auth*

Raygun also includes a simple user scaffold with authentication views/controllers based on Sorcery. These may be useful and also serves as examples of how to use Cancan for authorization. Not every app needs auth and a future version of Raygun will have a flag for leaving it out.

Usage

Start with gem install raygun. Be sure to check the requirements before doing anything with your freshly generated app. Otherwise you may experience a misfire. Then, fire away…

Then explore the code to see what’s included.

What’s Next?

I created Raygun not only to have something that might be useful, but also so that it could focus discussion about the Carbon Five Stack within our organization. We don’t all share the same preferences and that’s okay. Raygun is going to evolve as our preferences and options change. In the near term, I hope to roll out Rails 4 support and add a flag for leaving out the auth bits. Submit a pull request if there’s something you think should be part of it.

We’ve used it on a couple of projects and want to let others know about it. Be kind, this is Raygun’s first exposure to the outside world. Something will probably break. Let us know and we’ll fix it up real quick. Enjoy!

Updates

  • v0.0.22 includes a fix for ubuntu users

Feedback

  Comments: 16


  1. I’m getting a lot of these: sed: can’t read s/AppPrototype/Blogger/g: No such file or directory

    Shelling out to sed seems like a strange choice.


  2. Love it….apart from LESS – can’t live without Compass. I know, I know, omkase etc :)

    • Christian Nelson


      Dom, to be honest we’re a little torn here between less and sass. I like less because it’s simpler and has the features I need without much else. It also compiles quite a bit faster than sass. Sass has some great stuff and some folks really like compass. Like many things, it’s not an easy choice. :)


  3. Rockin! Thank you C5!


  4. Didn’t Mythbusters disprove the “hit the ground running” concept? :P


  5. I’ve just installed this using ‘gem install raygun’ and I get this :

    raygun blogger

    Creating new app Blogger in directory /home/chris/files/code/play/blogger…

    sed: can’t read s/app_prototype/blogger/g: No such file or directory
    sed: can’t read s/app-prototype/blogger/g: No such file or directory
    sed: can’t read s/AppPrototype/Blogger/g: No such file or directory
    sed: can’t read s/App Prototype/Blogger/g: No such file or directory
    sed: can’t read s/SUPER_SECRET_TOKEN_REPLACE_ME_TODO/e7533a2491ef867eb86918d0c27412dd2de1eea02ec0455aa9da4b6c1c2773124ede1b2378f0fd78253ac17d84e91f454defe0df5b83ac7b8dbe110df5f119f05ee5bd0a0ffc79f2d570a8111e92e3de93dd2cd6d7788f0e11ae348a5abd6e72123899c09e9c7a85464879da298bb915ece1598cf4cf3149ca3dd1fdb6aa885c/: No such file or directory
    sed: can’t read s/1.9.3-p327/1.8.7-p371/g: No such file or directory
    sed: can’t read s/1.9.3/1.8.7/g: No such file or directory
    Done! Next steps…


  6. Is that a DoTA 2 T-shirt you’re wearing? ;-)


  7. Anyway to manually flag out the auth for now? I’d like to roll in Devise instead of Sorcery.


    • No flag yet. It’s a little tedious, but pretty easy to pull the authentication stuff from the project, as a stop gap.

Your feedback