skeksis/lib/skeksis.rb
2023-08-04 21:49:40 -04:00

34 lines
774 B
Ruby

# frozen_string_literal: true
require "yaml"
require_relative "skeksis/version"
require_relative "skeksis/parser"
require_relative "skeksis/htmlize"
module Skeksis
#class Error < StandardError; end
class GemBridge
def initialize
@gemini_uri = YAML.load(File.read("config.yml"))['skeksis_config']['gemini_uri']
end
def query(path, env)
if Dir.exist?(path)
return Dir.each_child(path).map {|i| "#{i}\n"}
elsif File.exist?(path)
file = File.open(path, 'r')
data = file.readlines
[htmlize(data, env)]
else # path is invalid
return nil
end
end
def htmlize(data, env)
Skeksis::Parser.parse(data, strip_blanks=true).htmlize(env['REQUEST_URI'], @gemini_uri)
end
end
end