Skip to content

Instantly share code, notes, and snippets.

@adam12
Created February 8, 2024 15:41
Show Gist options
  • Save adam12/9d3ca08a22d357821feea8b815fae2bb to your computer and use it in GitHub Desktop.
Save adam12/9d3ca08a22d357821feea8b815fae2bb to your computer and use it in GitHub Desktop.
require_relative "../framework/plugins/loader"
require_relative "../framework/plugins/variant"
plugin Framework::Plugins::Variant
plugin Framework::Plugins::Loader, log: false do |loader|
root = Pathname(__dir__).parent.parent
loader.inflector.inflect "db" => "DB"
loader.inflector.inflect "eid" => "EID"
loader.push_dir(root + "apps")
loader.push_dir(root + "lib")
loader.ignore(root + "lib/core_ext")
loader.ignore(root + "lib/roda")
loader.ignore(root + "lib/sequel/plugins")
if variant.development?
begin
Framework::Logger.debug(self) { "Attempting to enable reloading" }
require "listen"
loader.enable_reloading
Listen.to(root) do
Framework::Logger.info(self) { "Performing reload" }
RELOAD_RW_LOCK.with_write_lock do
loader.reload
end
end.start
rescue LoadError => ex
raise unless ex.path == "listen"
Framework::Logger.debug(self) { "Unable to to load 'listen'. Reloading disabled" }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment