Giter Club home page Giter Club logo

bind's Introduction

Bind

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.

Installation

Install [Gemcutter](http://gemcutter.org) and execute:
$ sudo gem install bind

Executable

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

Library

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!

License:

(The MIT License)

Copyright © 2009 TJ Holowaychuk <[email protected]>

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.

bind's People

Contributors

tj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bind's Issues

If --eval option to bind executable is not provided - default to system(ARGV.pop)

Basically I would like to write

rbind to 'lib/**/*.rb' 'rake spec'

instead of

rbind to 'lib/**/*.rb' -e 'system \"rake spec\"'

Does this seems reasonable?

Crude hack illustrating the concept:


diff --git a/bin/rbind b/bin/rbind
index 79bc0c6..faa9ebd 100644
--- a/bin/rbind
+++ b/bin/rbind
@@ -18,7 +18,9 @@ command :to do |c|
   c.example 'Bind to a file, and a directory of files', "rbind to stylesheets style.css -e 'puts file.path'"
   c.example 'Run specs when ruby files are modified', "rbind to 'lib/**/*.rb' -e 'system \"rake spec\"'"
   c.action do |args, options|
-    abort 'invalid option. --eval switch is required in order to perform any action on the bound file(s)' unless options.eval
+    unless options.eval
+      options.eval = "system('#{args.pop}')"
+    end    
     common_options options
     options.paths = args
     listener(options).run!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.