Sha256: 067cfeb1e020ba22a437776a17b0036d3cd3a3d8683f034b43be610adda1cac0

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

module PowerStencil
  module Plugins

    module Require

      POST_BUILD_HOOK = :post_build_hook

      include PowerStencil::Utils::SecureRequire
      include PowerStencil::Utils::GemUtils

      private

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

      def require_entry_point
        if is_available_gem? name
          logger.debug "Plugin '#{name}' is actually a Ruby Gem."
          raise "Plugin (#{name}) provided as a Ruby gem is not yet supported !"
        else
          @entry_point_path = File.join project.project_plugin_path(name), 'lib', "#{name.underscore}.rb"
          logger.debug "Plugin '#{name}' is provided locally: '#{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
      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.5.1 lib/power_stencil/plugins/require.rb
power_stencil-0.5.0 lib/power_stencil/plugins/require.rb