Sha256: 8e6055fd61abd62718b85c892e5c9376019b9cabc18bb20734412cbc47cb81ac

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

module PowerStencil
  module Plugins

    module Require

      POST_BUILD_HOOK = :post_build_hook

      include PowerStencil::Utils::SecureRequire

      private

      def module_short_name
        name.split(/[-_]+/).map(&:capitalize).join.to_sym
      end

      def require_entry_point
        @entry_point_path = File.join plugin_path, 'lib', "#{name.underscore}.rb"
        logger.debug "Plugin '#{name}' entry point: '#{entry_point_path}'"
        plugin_root_path = File.dirname(entry_point_path)
        begin
          $LOAD_PATH << plugin_root_path
          securely_require entry_point_path unless plugin_definition[:plugin_module].nil?
        rescue LoadError => e
          logger.warn "As plugin '#{name}' code is invalid, removing '#{plugin_root_path}' from LOAD_PATH"
          $LOAD_PATH.delete plugin_root_path
        end
      end

      def setup_version
        @version = PowerStencil::Utils::SemanticVersion.new plugin_module::VERSION
        capabilities[:version] = true
        logger.debug "Plugin '#{name}' is in version: #{version}"
      rescue
        logger.warn "No version specified for plugin '#{name}'."
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
power_stencil-0.6.1 lib/power_stencil/plugins/require.rb
power_stencil-0.6.0 lib/power_stencil/plugins/require.rb