middleman/middleman — pull request #1322 by tdreyno (2014-07-16 01:11:21+00:00)
Title: Multiple Source watchers

Work-in-progress second refactor of file watching.

`app.files.watch` now fires up it's own `Listen` object allowing watching files outside the project (Sprockets gems, shared folders across projects, etc). By doing this, Listen is pulled out of `PreviewServer` and now available to all `Application` instances, such as Rack running on Heroku.

Sources now have a "type" which extensions can choose to care about. The majority of content is of type `:source`, but there is also `:data` which could allow the injection of outside Data content or whatever. It's a side-effect, but could be useful.

Finally, all references to a file are of type `Middleman::SourceFile` which is a `Struct` with information about the file "type", relative to project path and global/system path. This means anything relying on file content doesn't have to care about `app.root` or `app.config[:source]`. They can just rely on the project path or full path of the File descriptor they receive. Not everything is ported to this yet, but it will happen before merge.

This change makes the "grunt building into temp dir" approach as easy as:

```
app.files.watch :grunt, :source, "tmp/grunt-output"
```