Sha256: e87da3766cf50d1aa47f7c10009d9101f55e308847af7c35ee2824c10689078e

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

require 'power_stencil/plugins/type'
require 'power_stencil/plugins/config'
require 'power_stencil/plugins/command_line'
require 'power_stencil/plugins/entity_definitions'
require 'power_stencil/plugins/templates'
require 'power_stencil/plugins/require'
require 'power_stencil/plugins/capabilities'
require 'power_stencil/plugins/gem'
require 'power_stencil/plugins/build'
require 'power_stencil/plugins/dsl'

module PowerStencil

  module Plugins

    class Base

      extend PowerStencil::Plugins::Gem

      include Climatic::Proxy
      include PowerStencil::Plugins::Type
      include PowerStencil::Plugins::Config
      include PowerStencil::Plugins::CommandLine
      include PowerStencil::Plugins::Require
      include PowerStencil::Plugins::Capabilities
      include PowerStencil::Plugins::EntityDefinitions
      include PowerStencil::Plugins::Templates
      include PowerStencil::Plugins::Build
      include PowerStencil::Plugins::Dsl

      attr_reader :name, :version, :entry_point_path

      def initialize(name, project, type = :local)
        @name = name
        @project = project
        @version = PowerStencil::Utils::SemanticVersion.new '0.0.0-not-specified'
        raise PowerStencil::Error, "Invalid plugin type (#{type}) for plugin '#{name}'" unless PLUGIN_TYPES.include? type
        @type = type
        logger.debug "Loading plugin '#{name}'..."
        setup_plugin
        logger.info "Plugin '#{name}' successfully available"
        logger.debug "Plugin '#{name}' has following capabilities: #{capabilities.inspect}"
      end

      def path
        case type
        when :local
          project.project_plugin_path(name)
        end
      end

      def plugin_module
        Object.const_get plugin_definition[:plugin_module]
      end

      private

      attr_reader :project

      def setup_plugin
        load_capabilities
        load_plugin_specific_config
        load_yaml_command_definition
        require_entry_point
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
power_stencil-0.5.1 lib/power_stencil/plugins/base.rb