Sha256: 5d747b8b48cc74bc06ebde71580836238feb7ca29213dbbc2f70cf2763e493e7

Contents?: true

Size: 796 Bytes

Versions: 33

Compression:

Stored size: 796 Bytes

Contents

module PowerStencil
  module Utils

    module SecureRequire

      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 => 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

    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
power_stencil-0.4.22 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.21 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.20 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.19 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.18 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.17 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.16 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.15 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.14 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.13 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.12 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.11 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.10 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.9 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.8 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.7 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.6 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.5 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.4 lib/power_stencil/utils/secure_require.rb
power_stencil-0.4.3 lib/power_stencil/utils/secure_require.rb