Module: Pusher
- Defined in:
- lib/pusher.rb,
lib/pusher/json.rb,
lib/pusher/channel.rb,
lib/pusher/request.rb
Defined Under Namespace
Modules: JSON Classes: AuthenticationError, Channel, ConfigurationError, Error, Request
Class Attribute Summary collapse
-
.app_id ⇒ Object
Returns the value of attribute app_id.
-
.host ⇒ Object
Returns the value of attribute host.
-
.key ⇒ Object
Returns the value of attribute key.
- .logger ⇒ Object
-
.port ⇒ Object
Returns the value of attribute port.
-
.scheme ⇒ Object
Returns the value of attribute scheme.
-
.secret ⇒ Object
Returns the value of attribute secret.
Class Method Summary collapse
- .[](channel_name) ⇒ Object
- .authentication_token ⇒ Object
-
.encrypted=(boolean) ⇒ Object
Configure ssl by setting Pusher.encrypted = true.
-
.url ⇒ Object
Builds a connection url for Pusherapp.
-
.url=(url) ⇒ Object
Allows configuration from a url.
Class Attribute Details
.app_id ⇒ Object
Returns the value of attribute app_id.
12 13 14 |
# File 'lib/pusher.rb', line 12 def app_id @app_id end |
.host ⇒ Object
Returns the value of attribute host.
10 11 12 |
# File 'lib/pusher.rb', line 10 def host @host end |
.key ⇒ Object
Returns the value of attribute key.
12 13 14 |
# File 'lib/pusher.rb', line 12 def key @key end |
.logger ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/pusher.rb', line 14 def logger @logger ||= begin log = Logger.new(STDOUT) log.level = Logger::INFO log end end |
.port ⇒ Object
Returns the value of attribute port.
10 11 12 |
# File 'lib/pusher.rb', line 10 def port @port end |
.scheme ⇒ Object
Returns the value of attribute scheme.
10 11 12 |
# File 'lib/pusher.rb', line 10 def scheme @scheme end |
.secret ⇒ Object
Returns the value of attribute secret.
12 13 14 |
# File 'lib/pusher.rb', line 12 def secret @secret end |
Class Method Details
.[](channel_name) ⇒ Object
68 69 70 71 72 |
# File 'lib/pusher.rb', line 68 def self.[](channel_name) raise ConfigurationError, 'Missing configuration: please check that Pusher.url is configured' unless configured? @channels ||= {} @channels[channel_name.to_s] ||= Channel.new(url, channel_name) end |
.authentication_token ⇒ Object
22 23 24 |
# File 'lib/pusher.rb', line 22 def authentication_token Signature::Token.new(@key, @secret) end |
.encrypted=(boolean) ⇒ Object
Configure ssl by setting Pusher.encrypted = true
47 48 49 50 51 |
# File 'lib/pusher.rb', line 47 def encrypted=(boolean) Pusher.scheme = boolean ? 'https' : 'http' # Configure port if it hasn't already been configured Pusher.port ||= boolean ? 443 : 80 end |
.url ⇒ Object
Builds a connection url for Pusherapp
27 28 29 30 31 32 33 34 |
# File 'lib/pusher.rb', line 27 def url URI::Generic.build({ :scheme => self.scheme, :host => self.host, :port => self.port, :path => "/apps/#{self.app_id}" }) end |
.url=(url) ⇒ Object
Allows configuration from a url
37 38 39 40 41 42 43 44 |
# File 'lib/pusher.rb', line 37 def url=(url) uri = URI.parse(url) self.app_id = uri.path.split('/').last self.key = uri.user self.secret = uri.password self.host = uri.host self.port = uri.port end |