Sha256: f30b0874161c8891275bf8da3754cfb8b07e88f85cb264937fca07ea05b92876

Contents?: true

Size: 545 Bytes

Versions: 1

Compression:

Stored size: 545 Bytes

Contents

class Servel::CLI
  ALLOWED_PUMA_OPTIONS = [
    :Host,
    :Port,
    :binds
  ]

  def start
    Rack::Handler::Puma.run(Servel.build_app(path_map), **puma_options)
  end

  def path_map
    Servel.config.fetch(:listings).map do |listing|
      listing = { listing => nil } if listing.is_a?(String)

      root, url_root = listing.keys.first, listing.values.first || "/"
      [Pathname.new(root).realpath, url_root]
    end.to_h
  end

  def puma_options
    Servel.config.to_h.transform_keys(&:to_sym).slice(*ALLOWED_PUMA_OPTIONS)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
servel-0.32.0 lib/servel/cli.rb