guard-pusher
Pusher guard allows to automatically send a Pusher message to any number of browserswhen files are modified. That message can for instance be used to reload a page during development. Sort of Livereload but for iPad, iPhone etc. without the ability to install the necessary extension.
-
Tested on Ruby 1.8.7 & 1.9.2.
Install
Please be sure to have Guard installed before continue.
Install the gem:
gem install guard-pusher
Or add it to your Gemfile
gem 'guard-pusher'
and run
bundle install
Add guard definition to your Guardfile by running this command:
guard init pusher
Get a free Pusher developer account: pusherapp.com (also available as Heroku add-on).
Create a YAML file containing your API credentials for the development environment and save it in the config directory:
# config/pusher.yml
development:
app_id: ...
key: ...
secret: ...
You can also pass these credentials as option in your guard definition, see Options below.
Include the following JavaScript:
<script src="http://js.pusherapp.com/1.8/pusher.min.js"></script>
<script>
new Pusher(<key>).subscribe('guard-pusher').bind('guard', function() {
// do something - for instance simply reload the page:
location.reload();
});
</script>
Usage
Please read Guard usage doc
Options
Pass Pusher API credentials as option:
guard 'pusher', :app_id => ..., :key => '...', :secret => '...' do
...
end
Set the name of the event you’re binding to:
guard 'pusher', :event => 'ping' do
...
end
new Pusher(...).subscribe('guard-pusher').bind('ping', function() { ... });
Development
-
Source hosted at GitHub
-
Report issues, questions, feature requests on GitHub Issues
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.