Module: Pushify

Defined in:
lib/pushify.rb,
lib/pushify/rack.rb,
lib/pushify/rails.rb,
lib/pushify/helper.rb,
lib/pushify/server.rb,
lib/pushify/install.rb,
lib/pushify/juggernaut.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Helper, Install, Juggernaut, Rails Classes: Rack, Server

Class Method Summary collapse

Class Method Details

.installObject



6
7
8
# File 'lib/pushify.rb', line 6

def self.install
  ActionView::Base.send(:include, Pushify::Helper)
end

.javascript_srcObject



14
15
16
# File 'lib/pushify/helper.rb', line 14

def self.javascript_src
  '<script type="text/javascript" src="/pushify/pushify.js"></script>'
end

.juggernaut_src(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pushify/helper.rb', line 18

def self.juggernaut_src(options = {})
  hosts = Pushify::Juggernaut::CONFIG[:hosts].select {|h| !h[:environment] or h[:environment] == ENV['RAILS_ENV'].to_sym }
  random_host = hosts[rand(hosts.length)]
  options = {
    :host                 => (random_host[:public_host] || random_host[:host]),
    :port                 => (random_host[:public_port] || random_host[:port]),
    :width                => '0px',
    :height               => '0px',
    :swf_address          => "/pushify/juggernaut.swf",
    :ei_swf_address       => "/pushify/expressinstall.swf",
    :flash_version        => 8,
    :flash_color          => "#fff",
    :swf_name             => "juggernaut_flash",
    :bridge_name          => "juggernaut",
    :debug                => false,
    :reconnect_attempts   => 3,
    :reconnect_intervals  => 3
  }.merge(options)

  "new Juggernaut(#{options.to_json});"
end