At CookiesHQ we always seek to accelerate our known and repeatable processes, so we took our Rails template up a notch with the help of Suspenders
As you know, starting a brand new Rails project implies doing a certain amount of tasks that is always the same, mainly hooking up the new application with third party services (Heroku, your bug tracker of choice, etc) and setting up the gems that are part of all your new developments (the usual suspects here: Devise, RSpec, Bootstrap, etc).
In the past, we created a Rails application template that did this all for us with a series of questions prompted to the user, but some time after that we discovered thoughtbot’s Suspenders, which was very well tailored, organized, and most importantly, kept up to date with developments in Ruby, Rails and the Rails ecosystem.
So we tried using Suspenders on some projects, and it worked fairly well for us. We eventually found that although we had lots of work already done for us, we preferred to use some different libraries (Bootstrap instead of Bourbon and Neat), or that we preferred to keep writing Coffeescript instead of turning to EcmaScript6. We thought, why not take it to the next level?
Enter Hebillas
Nicolas found out that we could just invoke suspenders
with the flags we could normally use with rails new
, so why not try to pass our template to suspenders and see how it fared? It worked! But on our template we were installing gems and doing some file manipulations that needed some sorting out, as they were already done by Suspenders or were being applied on files that changed significantly in newer versions of the files.
The last thing we wanted to end up with was maintaining another fork of Suspenders. We only wanted to have a flexible way to amend it, without having to fork its core.
What does Hebillas do, then?
It’s a simple template file that will ask the user some questions to add or change new libraries to the newly created Rails project, keeping in mind that we want all the changes we do to be optional. Here’s a list of installed gems (without listing dependencies):
- devise – optional
- haml-rails – we’ll convert all .erb files to .haml while generating the application
- bootstrap-sass – we’ll remove bourbon, neat, refills and associated files.
- active_admin – optional (available if you choose to install Devise)
- paperclip – optional
- roadie 2.4.3
On the :development
group:
- mailcatcher – not required
- html2haml – not required (needed to convert the devise views)
- guard-livereload
- brakeman
On the :test
and :development
groups:
- faker
- guard-rspec – optional
On the :test
group:
- capybara
- capybara-email
- capybara-webkit
- database_cleaner
- launchy
- email_spec
- shoulda-matchers
- formulaic
- webmock
- vcr – optional
Also, if needed, it manipulates files on the project to have the following:
- Generates a
.gitignore
file with some common files and folders that we add. - Puts in a default skeleton for JS code organization, as explained in this post
- Puts in an email template and style as explained in this post
- Creates a stylesheet skeleton that is SMACSS compliant.
- Edits
application.css
(.scss) andapplication.js
to use Bootstrap. - Edits
application.rb
to add RSpec and ActionMailer config. - Edits
development.rb
to add ActionMailer config. - Creates a simple test and runs it (it will fail!) to get your TDD/BDD on 😉
- If you choose to, it will create a tmuxinator configuration file on the root of the project, add it to the gitignore and link it on the
~/tmuxinator/
folder. Keep in mind that it wont install thetmuxinator
gem, nortmux
, for you.
Can I use it?
Well of course! In fact we’d love not only to hear your feedback, but to receive pull requests with new additions, fixes or suggestions. We’d like Hebillas to be useful for everybody out there. 🙂
What does the future hold for Hebillas?
We have a list of things we would like to have working as options in Hebillas:
- Remove EcmaScript6 and use CoffeeScript.
- Use Bugsnag or Airbrake (or none).
- User letter_opener instead of mailcatcher (or none).
As well as some other useful things:
- Check Heroku option on Suspenders and get in additional options if needed/available.
- Create a version that can be run from the raw link on github (i.e.: embedding all files on the template).
- Separate long strings into auxiliary methods, for the sake of code readability.
Finally, what’s in the name?
Hebillas is Spanish for ‘buckle’. It’s quite generic since it can refer to buckles in belts, the plastic ones in backpacks, and even on hair accesories. We think this works well to reflect the ‘companion’ character of Hebillas, as well as its flexibility and extensibility.
And that’s it! We hope you find Hebillas useful and inspiring for you to use and modify as it better suits you, or to help us expand it.
Image credit to Theilr on Flickr.com. Used under CC2.0 BY-SA