livingsocial / rake-pipeline

An extension to Rake for dealing with a directory of inputs, a number of filters, and a directory of outputs
MIT License
276 stars 38 forks source link

rakep watch #64

Closed melindaweathers closed 12 years ago

melindaweathers commented 12 years ago

Greetings. I was very happy to find the rake pipeline project - thanks!

I wanted to be able to have it automatically update my output for cases when I need to use the output files directly (rather than going through rakep server). I saw that someone else had also requested this feature ( https://github.com/livingsocial/rake-pipeline/issues/36 ) so I went ahead and implemented "rakep watch" using the the FSSM gem. It watches for changes in your input directories and the Assetfile itself, and just does an invoke_clean to rebuild everything when any changes are detected.

Please let me know if you have any feedback. And thanks again!

wycats commented 12 years ago

You can get away with doing an invoke (not invoke_clean) if no files were created. invoke_clean will also rebuild the rake tasks, which is only needed if new files were created or files were deleted.

dudleyf commented 12 years ago

You'd also need to invoke_clean when the Assetfile changes to regenerate the tmp directory.

dudleyf commented 12 years ago

@wycats This is how I was planning on implementing rakep watch, but I know you had some doubts. Is this okay to pull, or do you have something else in mind?

wycats commented 12 years ago

We should make the server use the same underlying infrastructure.

Also, if files only CHANGED, but not files were created or deleted, it's fine to invoke without invoke_clean. The purpose of invoke_clean is to also rebuild the rake tasks, which won't be necessary unless new inputs exist.

dudleyf commented 12 years ago

Right, that's what happens here. On update, it only does invoke_clean if it's the Assetfile that changed, otherwise it does invoke.

melindaweathers commented 12 years ago

@wycats - Sure, I'll take a look at making the server use the same underlying infrastructure. Just so I'm clear, I think you're saying I should take out the invoke_clean that happens on every server request in the middleware, and instead have FSSM running in the background whenever the server is running, to update the output automatically, so the server just has to serve up the file. Is that correct?

melindaweathers commented 12 years ago

I had some time to work with this again, and found that the FSSM gem was deprecated in favor of the listen gem. I have modified my code to work with the listen gem instead, which I'll open as a separate pull request momentarily. The new pull request will also take the server into account.