Module: Pusher::IO
- Defined in:
- lib/pusher.io.rb,
lib/pusher.io/engine.rb,
lib/pusher.io/version.rb,
lib/pusher.io/view_helpers.rb,
lib/generators/pusher.io/install_generator.rb
Defined Under Namespace
Modules: Generators, ViewHelpers
Classes: Channel, Engine
Constant Summary
collapse
- VERSION =
"0.0.3"
Class Method Summary
collapse
Class Method Details
.[](channel_name) ⇒ Object
99
100
101
|
# File 'lib/pusher.io.rb', line 99
def [] channel_name
Channel.new channel_name
end
|
.config ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/pusher.io.rb', line 53
def config
@config ||= begin
cfg = {}
filename = "#{Rails.root}/config/pusher.io.yml"
yaml = YAML.load_file(filename)[Rails.env]
raise ArgumentError, "The #{Rails.env} environment does not exist in #{filename}" if yaml.nil?
yaml.each { |k, v| cfg[k.to_sym] = v }
cfg
end
end
|
.io_auth_query ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/pusher.io.rb', line 68
def io_auth_query
args = [
'auth',
config[:app_id],
Time.now.utc.to_i,
config[:key]
]
sign = psignature(args)
args << sign
query = ""
[:pusher, :app_id, :timestamp, :key, :signature].zip(args) do |key, value|
query << "&#{key}=#{value}"
end
query
end
|
.psignature(params) ⇒ Object
64
65
66
|
# File 'lib/pusher.io.rb', line 64
def psignature(params)
OpenSSL::HMAC.hexdigest('sha1', config[:secret], params.join("\n"))
end
|
.socket_base_uri ⇒ Object
84
85
86
87
88
89
|
# File 'lib/pusher.io.rb', line 84
def socket_base_uri
uri = config[:ssl_key].present? ? "https" : "http"
uri << "://#{config[:host]}"
uri << ":#{config[:port]}" if config[:port] && config[:port] != 80
uri
end
|
.socket_js_uri ⇒ Object
95
96
97
|
# File 'lib/pusher.io.rb', line 95
def socket_js_uri
socket_base_uri + "/socket.io/socket.io.js"
end
|
.socket_uri ⇒ Object
91
92
93
|
# File 'lib/pusher.io.rb', line 91
def socket_uri
socket_base_uri + "?#{io_auth_query}"
end
|