Fix ENV_HASH not working correctly.

This commit is contained in:
2025-06-23 15:01:12 +03:00
parent 94d377c0c2
commit ac99cef842
4 changed files with 11 additions and 6 deletions

13
main.rb
View File

@@ -7,18 +7,20 @@ require "uri"
require "xxhash"
require "zlib"
load "logman.rb"
ALPHANUM = [*"0".."9", *"A".."Z", *"a".."z", "-", "_"].freeze
env_data = File.read(".env")
ENV_HASH = {}
env_data.each_line do |line|
if (match = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/))
_, key, val = match
ENV_HASH[key] = val
end
next unless (match = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/))
ENV_HASH[match[1]] = match[2]
end
Logman.log ENV_HASH.inspect
CODE_ENV = :dev
db_file = File.expand_path("infinsweeper.db")
@@ -26,7 +28,6 @@ DB = Sequel.connect("sqlite:///#{db_file}", single_threaded: false)
DB.run("PRAGMA foreign_keys = ON;")
$active_users = DB[:SignedInUsers].all.map { |x| [x[:code], x[:player]] }.to_h
load "logman.rb"
load "mailer.rb"
load "players.rb"
load "session.rb"
@@ -35,7 +36,7 @@ set :public_folder, "public"
get "/" do
session = Sessions.new request, response
Logman.log session["message"]
Logman.log session["message"].inspect
send_file "index.html"
end