0.01
No commit activity in last 3 years
No release in over 3 years
Pusher guard allows to automatically send a Pusher message to any number of browsers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0.3
>= 0.8
 Project Readme

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¶ ↑

Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.

Authors¶ ↑

Klaus Hartl