lib/servel/cli.rb in servel-0.32.0 vs lib/servel/cli.rb in servel-0.33.0
- old
+ new
@@ -3,22 +3,14 @@
:Host,
:Port,
:binds
]
- def start
- Rack::Handler::Puma.run(Servel.build_app(path_map), **puma_options)
+ def initialize
+ @config = Servel::ConfigParser.new.config
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)
+ def start
+ app = Servel.build_app(**@config.slice(:listings, :username, :password))
+ Rack::Handler::Puma.run(app, **@config.slice(*ALLOWED_PUMA_OPTIONS))
end
end