Module: PusherFake

Defined in:
lib/pusher-fake.rb,
lib/pusher-fake/server.rb,
lib/pusher-fake/channel.rb,
lib/pusher-fake/webhook.rb,
lib/pusher-fake/connection.rb,
lib/pusher-fake/configuration.rb,
lib/pusher-fake/channel/public.rb,
lib/pusher-fake/channel/private.rb,
lib/pusher-fake/channel/presence.rb,
lib/pusher-fake/server/application.rb

Overview

A Pusher fake.

Defined Under Namespace

Modules: Channel, Server Classes: Configuration, Connection, Webhook

Constant Summary collapse

VERSION =

The current version string.

"4.1.0"

Class Method Summary collapse

Class Method Details

.configurationConfiguration

Returns Current configuration.

Returns:



33
34
35
# File 'lib/pusher-fake.rb', line 33

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|Configuration| ... } ⇒ Object

Call this method to modify the defaults.

Examples:

PusherFake.configure do |configuration|
  configuration.port = 443
end

Yields:



28
29
30
# File 'lib/pusher-fake.rb', line 28

def self.configure
  yield configuration
end

.javascript(options = {}) ⇒ String

Convenience method for the JS to override the Pusher client host and port.

Parameters:

  • options (Hash) (defaults to: {})

    Custom options for Pusher client.

Returns:

  • (String)

    JavaScript overriding the Pusher client host and port.



41
42
43
44
45
46
47
48
# File 'lib/pusher-fake.rb', line 41

def self.javascript(options = {})
  arguments = [
    configuration.key,
    configuration.to_options(options)
  ].map(&:to_json).join(",")

  "new Pusher(#{arguments})"
end

.log(message) ⇒ Object



50
51
52
# File 'lib/pusher-fake.rb', line 50

def self.log(message)
  configuration.logger << "#{message}\n" if configuration.verbose
end