lib/legion/extensions.rb in legionio-0.4.3 vs lib/legion/extensions.rb in legionio-1.2.0

- old
+ new

@@ -57,20 +57,30 @@ sleep(0.1) end Legion::Logging.info "#{@extensions.count} extensions loaded with subscription:#{@subscription_tasks.count},every:#{@timer_tasks.count},poll:#{@poll_tasks.count},once:#{@once_tasks.count},loop:#{@loop_tasks.count}" end - def load_extension(extension, values) + def load_extension(extension, values) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize return unless gem_load(values[:gem_name], extension) extension = Kernel.const_get(values[:extension_class]) + extension.extend Legion::Extensions::Core unless extension.singleton_class.included_modules.include? Legion::Extensions::Core + + min_version = Legion::Settings[:extensions][values[:extension_name]][:min_version] || nil + Legion::Logging.fatal values if min_version.is_a?(String) && Gem::Version.new(values[:version]) >= Gem::Version.new(min_version) + if extension.data_required? && Legion::Settings[:data][:connected] == false Legion::Logging.warn "#{values[:extension_name]} requires Legion::Data but isn't enabled, skipping" return false end if extension.cache_required? && Legion::Settings[:cache][:connected] == false Legion::Logging.warn "#{values[:extension_name]} requires Legion::Cache but isn't enabled, skipping" + return false + end + + if extension.crypt_required? && Legion::Settings[:crypt][:cs].nil? + Legion::Logging.warn "#{values[:extension_name]} requires Legion::Crypt but isn't ready, skipping" return false end if extension.vault_required? && Legion::Settings[:crypt][:vault][:connected] == false Legion::Logging.warn "#{values[:extension_name]} requires Legion::Crypt::Vault but isn't enabled, skipping"