summaryrefslogtreecommitdiff
path: root/logic/cartridge
diff options
context:
space:
mode:
authoricebaker <icebaker@proton.me>2024-01-10 21:31:42 -0300
committericebaker <icebaker@proton.me>2024-01-10 21:31:42 -0300
commitaabf3d9b711f66fe4195a8c850856826c7ad5580 (patch)
tree866218debc763547818de0099098bc5fe2ae29c7 /logic/cartridge
parent552c9c7321895d41f81e460b94182b7a00d2cb88 (diff)
improving merging approach
Diffstat (limited to 'logic/cartridge')
-rw-r--r--logic/cartridge/parser.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/logic/cartridge/parser.rb b/logic/cartridge/parser.rb
index f82b968..50b3dc5 100644
--- a/logic/cartridge/parser.rb
+++ b/logic/cartridge/parser.rb
@@ -44,9 +44,9 @@ module NanoBot
parsed.delete(:tools)
unless parsed.empty?
- yaml_source << YAML.dump(Logic::Helpers::Hash.stringify_keys(
- parsed
- )).gsub(/^---/, '') # TODO: Is this safe enough?
+ yaml_source << YAML.dump(
+ Logic::Helpers::Hash.stringify_keys(parsed)
+ ).gsub(/^---/, '') # TODO: Is this safe enough?
end
else
yaml_source << block[:source]
@@ -60,12 +60,18 @@ module NanoBot
end
unless tools.empty?
- yaml_source << YAML.dump(Logic::Helpers::Hash.stringify_keys(
- { tools: }
- )).gsub(/^---/, '') # TODO: Is this safe enough?
+ yaml_source << YAML.dump(
+ Logic::Helpers::Hash.stringify_keys({ tools: })
+ ).gsub(/^---/, '') # TODO: Is this safe enough?
end
- yaml(yaml_source.join("\n"))
+ cartridge = {}
+
+ yaml_source.each do |source|
+ cartridge = Logic::Helpers::Hash.deep_merge(cartridge, yaml(source))
+ end
+
+ cartridge
end
def self.yaml(raw)