From d3316d0b042ffa550ff56ed4e691c80003dd1414 Mon Sep 17 00:00:00 2001 From: mms Date: Fri, 27 Dec 2024 00:16:14 +0100 Subject: feat(new): server mode --- new/bin/server.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 new/bin/server.rb (limited to 'new/bin/server.rb') diff --git a/new/bin/server.rb b/new/bin/server.rb new file mode 100755 index 0000000..61f7c22 --- /dev/null +++ b/new/bin/server.rb @@ -0,0 +1,37 @@ +require_relative "../lib/crys" + +module Crys + class ServerRunner + SPLASH = [ + <<-HEREDOC + ▄████▄ ██▀███ ▓██ ██▓ ██████ ██████ ██▓▄▄▄█████▓▓█████ +▒██▀ ▀█ ▓██ ▒ ██▒ ▒██ ██▒▒██ ▒ ▒██ ▒ ▓██▒▓ ██▒ ▓▒▓█ ▀ +▒▓█ ▄ ▓██ ░▄█ ▒ ▒██ ██░░ ▓██▄ ░ ▓██▄ ▒██▒▒ ▓██░ ▒░▒███ +▒▓▓▄ ▄██▒▒██▀▀█▄ ░ ▐██▓░ ▒ ██▒ ▒ ██▒░██░░ ▓██▓ ░ ▒▓█ ▄ +▒ ▓███▀ ░░██▓ ▒██▒ ░ ██▒▓░▒██████▒▒▒██████▒▒░██░ ▒██▒ ░ ░▒████▒ +░ ░▒ ▒ ░░ ▒▓ ░▒▓░ ██▒▒▒ ▒ ▒▓▒ ▒ ░▒ ▒▓▒ ▒ ░░▓ ▒ ░░ ░░ ▒░ ░ + ░ ▒ ░▒ ░ ▒░ ▓██ ░▒░ ░ ░▒ ░ ░░ ░▒ ░ ░ ▒ ░ ░ ░ ░ ░ +░ ░░ ░ ▒ ▒ ░░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ +░ ░ ░ ░ ░ ░ ░ ░ ░ ░ +░ ░ ░ +HEREDOC + ] + + def initialize(server_class:, root: ) + @root = File.expand_path root + @server = server_class.new(root: root) + end + + def serve + puts "" + puts SPLASH.sample + puts "Serving from: " + root + puts "" + server.start + end + + private + + attr_reader :root, :server + end +end -- cgit v1.2.3