Rake gem explained

So what is a task? and how is it different than a function?

Ok, what is a side effect then?

Task is the polar opposite of Pure Function because it’s pure side effect.

Basic syntax


Appending a task

Dependent tasks

Loading your rails app

Ok let’s compare Rake with some other build tools:





Cool, let’s see some more advanced usage of rake

Referencing a task in another part of your app

already_invoked feature

Enhance your tasks


File tasks


* Shamelessly stolen from Avdi Grimm’s blog.
  1. Grabs all the files with `.md` or `.markdown` extension.
  2. Excludes the one that starts with `~`.
  3. Excludes the one in the scratch folder.
  4. Excludes the ones that are not tracked by git.


  1. Getting the task name (tn).
  2. Changing `.class` to `.java`.
  3. Changing the `classes` folder name to `src`.

Passing variables

Ok, I’m done!


Useful links for further reading



Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store