Rotor

Rotor is a build system for Elixir projects. Use it to compile things, run commands or do anything that needs to be run when files change.

Wreckers don't call for backup, they call for cleanup ~!

Example: Compile CoffeeScript files whenever they change

paths = ["assets/libs/*.coffee", "assets/*.coffee"]
Rotor.watch :coffee_assets, paths, fn(changed_files, all_files)->
read_files(all_files)
|> coffee
|> concat
|> write_to("priv/static/assets/app.js")
end
# Either touch a file that's in the path provided or forcefully run the task like below
Rotor.run :coffee_assets

The above example uses the coffee_rotor.

NOTE: Rotor is not a replacement for mix. It is intended to be used as your sidekick during development.

Features

Usage

A set of paths you want to watch is called a watch group. Each watch group has the following

Adding watch groups

Rotor.watch(name, files, rotor_function)

The rotor function is passed info about the list of files that match the paths specified. The rotor function calls other little functions called rotors, that run certain tasks.

paths = ["assets/javascripts/libs/*.js", "assets/javascripts/*.js"]
Rotor.watch :javascripts, paths, fn(changed_files, all_files)->
read_files(all_files)
|> concat
|> write_to("priv/static/assets/app.js")
end

Rotors

Rotor ships with a few simple rotors in the Rotor.Basic module.

You can also write your own. Check the "Writing custom rotors" section below.

Other stuff

Examples

paths = ["assets/stylesheets/libs/*.css", "assets/stylesheets/*.css"]
Rotor.watch :stylesheets, paths, fn(changed_files, all_files)->
read_files(all_files)
|> concat
|> write_to("app.css")
end
paths = ["assets/images/*", "assets/fonts/*"]
Rotor.watch :images_and_fonts, paths, fn(changed_files, all_files)->
copy_files(files, "priv/static/assets")
end

Writing custom rotors

Rotors are just functions that accept data and do something.

Checkout coffee_rotor, which provides a rotor to compile CoffeeScript files.

License

Copyright © 2014, Akash Manohar J, under the MIT License