diff options
author | icebaker <icebaker@proton.me> | 2023-05-21 19:18:03 -0300 |
---|---|---|
committer | icebaker <icebaker@proton.me> | 2023-05-21 19:18:03 -0300 |
commit | a0ad2a136da85e9757f1a91f58e5e31e9d692929 (patch) | |
tree | c2d18485250935cbe7e1bc03ac39904a22c92368 /controllers/instance.rb | |
parent | 81071238b24faeb91d329c62957381bcf429c522 (diff) |
support built cartridges
Diffstat (limited to 'controllers/instance.rb')
-rw-r--r-- | controllers/instance.rb | 26 |
1 files changed, 15 insertions, 11 deletions
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)) |