servel 0.31.0 → 0.32.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9764905c7e72d90eecf301bf30c25c5542602d70df065803e18c03ab8353322
4
- data.tar.gz: cf989ead1073528b04fc5c2c86d2f57ce37beace6c110fe40955c802390e4d58
3
+ metadata.gz: 283ef8ff838b1a149aee4379a02233d006d5dfec7887de4791e20c2e61cbe86e
4
+ data.tar.gz: b6fa99503294d5bba7b338c86fd0eb9bb46b06944de3fe2b10b225a6120b6794
5
5
  SHA512:
6
- metadata.gz: ed18495a7e3c37f25fd22655f7eebd8e78e712782d3970f15a46b205cc9c5e92da2ddb884277cae0558043b66754dac9936fd8dfcbd9dd9333c324caed2931b3
7
- data.tar.gz: fadfa698ea51f4c95deee988c4ecfbd8edfff80776cf406fb780b5551f0d0207826110d8058ec150af763422d16901bb2a17431d2111cce855bd0346dd30933a
6
+ metadata.gz: d44b0fef9dac7e95483e13856f4b030813019c26ed7676a8154cdad88eef8b9db9b5075c4a463dc374353c0e73a09b9c408aa069b79f80da58c221451a227bc3
7
+ data.tar.gz: d7a4126762ab129714b328aaf1dd492a17d1354870f4f943f799e2816f490de1ef85af253f8f4fcb96bd1d879fff5a134a7043f48112f2fe00bce7eac4af237a
data/lib/servel.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rack'
2
2
  require 'rack/handler/puma'
3
+ require 'puma/configuration'
3
4
  require 'hamlit'
4
5
  require 'active_support/all'
5
6
  require 'lru_redux'
data/lib/servel/cli.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  class Servel::CLI
2
+ ALLOWED_PUMA_OPTIONS = [
3
+ :Host,
4
+ :Port,
5
+ :binds
6
+ ]
7
+
2
8
  def start
3
- Rack::Handler::Puma.run(Servel.build_app(path_map))
9
+ Rack::Handler::Puma.run(Servel.build_app(path_map), **puma_options)
4
10
  end
5
11
 
6
12
  def path_map
@@ -11,4 +17,8 @@ class Servel::CLI
11
17
  [Pathname.new(root).realpath, url_root]
12
18
  end.to_h
13
19
  end
20
+
21
+ def puma_options
22
+ Servel.config.to_h.transform_keys(&:to_sym).slice(*ALLOWED_PUMA_OPTIONS)
23
+ end
14
24
  end
@@ -12,6 +12,7 @@ class Servel::ConfigParser
12
12
  @config.read if @config.exist?
13
13
 
14
14
  @config.append(*parse_argv, to: :listings)
15
+ parse_binds
15
16
  end
16
17
 
17
18
  def parse_argv
@@ -20,4 +21,23 @@ class Servel::ConfigParser
20
21
  { root => url_root }
21
22
  end
22
23
  end
24
+
25
+ def parse_binds
26
+ return parse_ssl_bind if @config.fetch(:cert) && @config.fetch(:key)
27
+
28
+ host = @config.fetch(:host)
29
+ port = @config.fetch(:port)
30
+ @config.set(:Host, value: host) if host
31
+ @config.set(:Port, value: port) if port
32
+ end
33
+
34
+ def parse_ssl_bind
35
+ host = @config.fetch(:host, default: ::Puma::ConfigDefault::DefaultTCPHost)
36
+ port = @config.fetch(:port, default: ::Puma::ConfigDefault::DefaultTCPPort)
37
+ key = Pathname.new(@config.fetch(:key)).expand_path
38
+ cert = Pathname.new(@config.fetch(:cert)).expand_path
39
+
40
+ query = URI.encode_www_form(key: key, cert: cert)
41
+ @config.append("ssl://#{host}:#{port}?#{query}", to: :binds)
42
+ end
23
43
  end
@@ -1,3 +1,3 @@
1
1
  module Servel
2
- VERSION = "0.31.0"
2
+ VERSION = "0.32.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brenton "B-Train" Fletcher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-12 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler