Class: Middleman::LiveReload::Wss

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-livereload/wss.rb

Instance Method Summary collapse

Constructor Details

#initialize(certificate, private_key) ⇒ Wss

Returns a new instance of Wss.



4
5
6
7
8
# File 'lib/middleman-livereload/wss.rb', line 4

def initialize(certificate, private_key)
  @certificate = certificate
  @private_key = private_key
  validate!
end

Instance Method Details

#schemeObject



25
26
27
# File 'lib/middleman-livereload/wss.rb', line 25

def scheme
  valid? ? "wss" : "ws"
end

#to_optionsObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/middleman-livereload/wss.rb', line 14

def to_options
  return {} unless valid?
  {
    secure: true,
    tls_options: {
      private_key_file: @private_key,
      cert_chain_file: @certificate
    }
  }
end

#valid?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/middleman-livereload/wss.rb', line 10

def valid?
  @certificate && @private_key
end