From a0ad2a136da85e9757f1a91f58e5e31e9d692929 Mon Sep 17 00:00:00 2001 From: icebaker Date: Sun, 21 May 2023 19:18:03 -0300 Subject: support built cartridges --- controllers/instance.rb | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'controllers/instance.rb') diff --git a/controllers/instance.rb b/controllers/instance.rb index e0729e6..fbe2348 100644 --- a/controllers/instance.rb +++ b/controllers/instance.rb @@ -53,18 +53,22 @@ module NanoBot private def load_cartridge!(path) - elected_path = if path.strip == '-' - File.expand_path('../static/cartridges/baseline.yml', __dir__) - else - Components::Storage.cartridge_path(path) - end - - if elected_path.nil? - @stream.write("Cartridge file not found: \"#{path}\"\n") - raise StandardError, "Cartridge file not found: \"#{path}\"" - end + if !path.is_a?(String) && !path.is_a?(Symbol) + @cartridge = path + else + elected_path = if path.strip == '-' + File.expand_path('../static/cartridges/baseline.yml', __dir__) + else + Components::Storage.cartridge_path(path) + end + + if elected_path.nil? + @stream.write("Cartridge file not found: \"#{path}\"\n") + raise StandardError, "Cartridge file not found: \"#{path}\"" + end - @cartridge = YAML.safe_load(File.read(elected_path), permitted_classes: [Symbol]) + @cartridge = YAML.safe_load(File.read(elected_path), permitted_classes: [Symbol]) + end @safe_cartridge = Marshal.load(Marshal.dump(@cartridge)) -- cgit v1.2.3