module PowerStencil::Utils::SecureRequire
Public Instance Methods
securely_require(ruby_source_file, fail_on_error: false) { || ... }
click to toggle source
# File lib/power_stencil/utils/secure_require.rb, line 6 def securely_require(ruby_source_file, fail_on_error: false) PowerStencil.logger.debug "Securely requiring Ruby source file '#{ruby_source_file}'..." require ruby_source_file yield if block_given? rescue StandardError, SyntaxError => e PowerStencil.logger.debug PowerStencil::Error.report_error(e) msg = "Could not require Ruby source file '#{ruby_source_file}' !" if fail_on_error msg << ' Aborting !' PowerStencil.logger.error msg raise PowerStencil::Error, "Invalid Ruby source file: '#{ruby_source_file}' !" else msg << " (#{e.message})" msg << ' Ignoring...' PowerStencil.logger.warn msg end end