Skip to content

Instantly share code, notes, and snippets.

@karimmtarek
Forked from Patru/Make a Cuba Template.md
Created March 16, 2017 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karimmtarek/c82ccb86d8bdfb5beaf724c26a3fa140 to your computer and use it in GitHub Desktop.
Save karimmtarek/c82ccb86d8bdfb5beaf724c26a3fa140 to your computer and use it in GitHub Desktop.
How I got to my Cuba template

Since I did not want to constantly re-invent the wheel I will write down my choices for putting together my Cuba template.

  1. Choose your favorite version of ruby and install it using rbenv (I happened to use MRI 2.2.3 at this point).
  2. create your template directory and CD into it.
  3. fix your ruby version using rbenv local 2.2.3 or somesuch
  4. create a github repository and follow the instructions for the README.md and the first commit.
  5. get a Gemfile from a running project and edit away the stuff I considered project specific
  6. run bundle install, takes a while, but looks nice, remember to add Gemfile.lock to git too
  7. create routes and config directories, want to put stuff in there
  8. create an initial Cuba route in routes/default.rb
  9. create a config.ru which runs the default Cuba app
  10. when we start the app with rackup it already picks up puma and runs my app with default setting, first success, get a piece of chocolate :-)
  11. create the config/puma.rb, this is picked up automatically if you just run puma and allows for customization, I started out with the heroku defaults for rails, now we can run a multi-worker server with just the puma command, answers the /hello request in a sub-millisecond range
  12. roll your environment.rb with corresponding environments, this allows to configure the DB as you wish
  13. create the views directory, want to do HTML next
  14. I need a little plugin to roll with my favorite fortitude gem so make a plugins directory and put the forti.rb there in order to get an forti command to render a fortitude-class.
  15. Add the Page class to the views directory, customize to your likings.
  16. Add a simple page and check the basic layout.
  17. Assets are next, sprockets is cool. There is cuba-assets which did not quite fit my version of Cuba though, so I forked it to match the versions. I also found it did not exhibit the rack server to mount it so I added that too, just to not have to resort to Rack::URLMap, but on second thought that seems like a bad idea. Have to check out the way URLMaps work to be sure.
  18. Nevermind, once I got the rack server I was easily able to mount it within Cuba, serving of assets seemed a little slow at 30 ms odd though.
  19. Add the Rakefile, migrations and specs for now
  20. add a spec_helper.rb to the spec directory, basic stuff for minitest/spec.
  21. Get sidetracked for some time to make Capybara::Screenshot work with Minitest::Spec without ´ActionDispatch::IntegrationTest´
  22. fix some deprecation warning during testcases by updating to QT5, brew install qt5 was only half of the deal, I had to brew unlink qt and brew link --force qt5 and then gem uninstall capybara-webkit and bundle it again to get the tests working without the deprecation warning complaining about the QT version (in a "future release", mind you).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment