lib/legion/extensions/core.rb in legionio-0.2.0 vs lib/legion/extensions/core.rb in legionio-0.3.0
- old
+ new
@@ -1,7 +1,5 @@
-# frozen_string_literal: true
-
require_relative 'builders/actors'
require_relative 'builders/helpers'
require_relative 'builders/runners'
require_relative 'helpers/core'
@@ -43,24 +41,24 @@
build_runners
build_actors
end
def build_transport
- if File.exist? extension_path + '/transport/autobuild.rb'
+ if File.exist? "#{extension_path}/transport/autobuild.rb"
require "#{extension_path}/transport/autobuild"
extension_class::Transport::AutoBuild.build
log.warn 'still using transport::autobuild, please upgrade'
- elsif File.exist? extension_path + '/transport.rb'
+ elsif File.exist? "#{extension_path}/transport.rb"
require "#{extension_path}/transport"
extension_class::Transport.build
else
auto_generate_transport
extension_class::Transport.build
end
end
- def build_settings
+ def build_settings # rubocop:disable Metrics/AbcSize
if Legion::Settings[:extensions].key?(lex_name.to_sym)
Legion::Settings[:default_extension_settings].each do |key, value|
Legion::Settings[:extensions][lex_name.to_sym][key.to_sym] = if Legion::Settings[:extensions][lex_name.to_sym].key?(key.to_sym)
value.merge(Legion::Settings[:extensions][lex_name.to_sym][key.to_sym])
else
@@ -68,9 +66,21 @@
end
end
else
Legion::Settings[:extensions][lex_name.to_sym] = Legion::Settings[:default_extension_settings]
end
+
+ default_settings.each do |key, value|
+ Legion::Settings[:extensions][lex_name.to_sym][key.to_sym] = if Legion::Settings[:extensions][lex_name.to_sym].key?(key.to_sym)
+ value.merge(Legion::Settings[:extensions][lex_name.to_sym][key.to_sym])
+ else
+ value
+ end
+ end
+ end
+
+ def default_settings
+ {}
end
def auto_generate_transport
require 'legion/extensions/transport'
log.debug 'running meta magic to generate a transport base class'