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)->
# Either touch a file that's in the path provided or forcefully run the task like below
*The above example uses the [coffee_rotor](https://github.com/HashNuke/coffee_rotor).*
> **NOTE:** Rotor is *not* a replacement for mix. It is intended to be used as your sidekick during development.
* Works with any web framework or even plain mix projects
* Easy to use
* Extendable with simple functions
* Can be configured to run commands or code or go to the moon.
* Inspired by [gulp](https://github.com/gulpjs/gulp)
A set of paths you want to watch is called a *watch group*. Each watch group has the following
* a list of paths to watch
* a function, which we'll call the *rotor function*, that is run everytime any of the files in the paths changes. It should accept 2 arguments
* *changed_files* - a list of maps, each containing info about changed files
* *all_files* - a list of maps, each containing info about all files that matched the path
#### 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.
Rotor ships with a few simple rotors in the `Rotor.Basic` module.
* `read_files(files)` - reads contents of files, and returns files with a property called `contents`
* `copy_files(files, destination_dir)` - copies files to destination_dir
* `concat(files)` - concats contents of files and returns a string
* `write_to(contents, output_path)` - writes the contents to the file path specified in output path
You can also write your own. Check the *"Writing custom rotors"* section below.
### Other stuff
* To remove a watch group
* To list groups
* To run a watch group's rotor functions forcefully
paths = ["assets/stylesheets/libs/*.css", "assets/stylesheets/*.css"]
Rotor.watch :stylesheets, paths, fn(changed_files, all_files)->
paths = ["assets/images/*", "assets/fonts/*"]
Rotor.watch :images_and_fonts, paths, fn(changed_files, all_files)->
### Writing custom rotors
Rotors are just functions that accept data and do something.
Checkout [coffee_rotor](https://github.com/HashNuke/coffee_rotor), which provides a rotor to compile CoffeeScript files.
Copyright © 2014, Akash Manohar J, under the [MIT License](http://opensource.org/licenses/MIT)