Bind actions to various file system events, helping aid in automation of tasks such as refreshing browser(s) when you update a css / sass / js file.
Install [Gemcutter](http://gemcutter.org) and execute: $ sudo gem install bind
The ‘bind’ executable allows you to perform arbitrary actions based on several events. Currently only the change (mtime) event is supported.
Bind to a single file, outputting its path when changed
$ rbind to style.css -e 'puts file.path'
Bind to glob
$ rbind to stylesheets/*.css -e 'puts file.path'
Bind to ruby glob (allows recursion) note the quotes
$ rbind to 'stylesheets/**/*.css' -e 'puts file.path'
Refresh Safari, and Firefox in the background to the uri specified when style.css or reset.css are modified.
$ rbind refresh http://localhost/page --paths style.css,reset.css --browsers Safari,Firefox
Refresh local static html when the style you are working on is modified.
$ rbind refresh examples/demo.html -f style.css -b Safari
Bind of course supplies a Ruby library as well, which provides the same functionality as the executable above.
Refresh Safari and Firefox, using the RefreshBrowsersHaml action, whenever a haml or sass file is modified, it will be compiled to ‘..’ (up a directory) preceding the refresh.
path = 'http://localhost' action = Bind::Actions::RefreshBrowsersHaml.new path, '..', 'Safari', 'Firefox' listener = Bind::Listener.new :interval => 1, :debug => $stdout, :action => action, :paths => Dir['*.haml'] + Dir['*.sass'] listener.run!
(The MIT License)
Copyright © 2009 TJ Holowaychuk <tj@vision-media.ca>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, an d/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. GS IN THE SOFTWARE.