Class: AutoRefresh
- Inherits:
-
Object
- Object
- AutoRefresh
- Defined in:
- lib/autorefresh.rb
Overview
Automatically refresh your browser using WebSockets
Constant Summary collapse
- @@pusher_key =
'a2024b659f492cab86cc'
- @@pusher_app_id =
'3735'
- @@pusher_secret =
'3ce64d76b4288e4ba449'
Class Method Summary collapse
Class Method Details
.channel(chan) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/autorefresh.rb', line 9 def self.channel(chan) %q{ <script src="http://js.pusherapp.com/1.6/pusher.js" type="text/javascript"></script> <script type="text/javascript"> var pusher = new Pusher('PUSHER_KEY'); pusher.subscribe('CHANNEL'); pusher.bind('refresh', function(data) { location.reload(true); }); </script> }.gsub(/CHANNEL/, chan).gsub(/PUSHER_KEY/, @@pusher_key) end |
.refresh(chan) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/autorefresh.rb', line 22 def self.refresh(chan) Pusher.app_id = @@pusher_app_id Pusher.key = @@pusher_key Pusher.secret = @@pusher_secret Pusher[chan].trigger('refresh', {}) end |