Class: PusherFake::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/pusher-fake/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Instantiated from PusherFake.configuration. Sets the defaults.



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

def initialize
  reset!
end

Instance Attribute Details

#app_idString

Returns The Pusher Applicaiton ID. (Defaults to PUSHER_APP_ID.).

Returns:

  • (String)

    The Pusher Applicaiton ID. (Defaults to PUSHER_APP_ID.)



4
5
6
# File 'lib/pusher-fake/configuration.rb', line 4

def app_id
  @app_id
end

#keyString

Returns The Pusher API key. (Defaults to PUSHER_API_KEY.).

Returns:

  • (String)

    The Pusher API key. (Defaults to PUSHER_API_KEY.)



7
8
9
# File 'lib/pusher-fake/configuration.rb', line 7

def key
  @key
end

#loggerIO

Returns An IO instance for verbose logging.

Returns:

  • (IO)

    An IO instance for verbose logging.



10
11
12
# File 'lib/pusher-fake/configuration.rb', line 10

def logger
  @logger
end

#secretString

Returns The Pusher API token. (Defaults to PUSHER_API_SECRET.).

Returns:

  • (String)

    The Pusher API token. (Defaults to PUSHER_API_SECRET.)



13
14
15
# File 'lib/pusher-fake/configuration.rb', line 13

def secret
  @secret
end

#socket_optionsHash

Options for the socket server. See EventMachine::WebSocket.start for options.

Returns:

  • (Hash)

    Options for the socket server.



18
19
20
# File 'lib/pusher-fake/configuration.rb', line 18

def socket_options
  @socket_options
end

#verboseBoolean

Returns Enable verbose logging.

Returns:

  • (Boolean)

    Enable verbose logging.



21
22
23
# File 'lib/pusher-fake/configuration.rb', line 21

def verbose
  @verbose
end

#web_optionsHash

Options for the web server. See Thin::Server for options.

Returns:

  • (Hash)

    Options for the web server.



26
27
28
# File 'lib/pusher-fake/configuration.rb', line 26

def web_options
  @web_options
end

#webhooksArray

Returns An array of webhook URLs. (Defaults to [].).

Returns:

  • (Array)

    An array of webhook URLs. (Defaults to [].)



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

def webhooks
  @webhooks
end

Instance Method Details

#reset!Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pusher-fake/configuration.rb', line 36

def reset!
  self.app_id   = "PUSHER_APP_ID"
  self.key      = "PUSHER_API_KEY"
  self.logger   = STDOUT.to_io
  self.secret   = "PUSHER_API_SECRET"
  self.verbose  = false
  self.webhooks = []

  self.socket_options = { host: "127.0.0.1", port: available_port }
  self.web_options    = { host: "127.0.0.1", port: available_port }
end

#to_options(options = {}) ⇒ Object

Convert the configuration to a hash sutiable for Pusher JS options.

Parameters:

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

    Custom options for Pusher client.



51
52
53
54
55
56
# File 'lib/pusher-fake/configuration.rb', line 51

def to_options(options = {})
  options.merge(
    wsHost: socket_options[:host],
    wsPort: socket_options[:port]
  )
end