Class: PusherFake::Configuration

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

Overview

Configuration class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Instantiated from PusherFake.configuration. Sets the defaults.


38
39
40
# File 'lib/pusher-fake/configuration.rb', line 38

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.)


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

def app_id
  @app_id
end

#disable_statsBoolean

Returns Disable the client statistics. (Defaults to true.).

Returns:

  • (Boolean)

    Disable the client statistics. (Defaults to true.)


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

def disable_stats
  @disable_stats
end

#keyString

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

Returns:

  • (String)

    The Pusher API key. (Defaults to PUSHER_API_KEY.)


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

def key
  @key
end

#loggerIO

Returns An IO instance for verbose logging.

Returns:

  • (IO)

    An IO instance for verbose logging.


16
17
18
# File 'lib/pusher-fake/configuration.rb', line 16

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.)


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

def secret
  @secret
end

#socket_optionsHash

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

Returns:

  • (Hash)

    Options for the socket server.


24
25
26
# File 'lib/pusher-fake/configuration.rb', line 24

def socket_options
  @socket_options
end

#verboseBoolean

Returns Enable verbose logging.

Returns:

  • (Boolean)

    Enable verbose logging.


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

def verbose
  @verbose
end

#web_optionsHash

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

Returns:

  • (Hash)

    Options for the web server.


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

def web_options
  @web_options
end

#webhooksArray

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

Returns:

  • (Array)

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


35
36
37
# File 'lib/pusher-fake/configuration.rb', line 35

def webhooks
  @webhooks
end

Instance Method Details

#reset!Object


49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/pusher-fake/configuration.rb', line 49

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.disable_stats  = true
  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.


65
66
67
68
69
70
71
72
73
# File 'lib/pusher-fake/configuration.rb', line 65

def to_options(options = {})
  options.merge(
    wsHost:       socket_options[:host],
    wsPort:       socket_options[:port],
    cluster:      "us-east-1",
    forceTLS:     false,
    disableStats: disable_stats
  )
end