Sha256: d593b908eb3067341ce98e6d1fe1e9da50c180fddefc2cd90a8a6b27dd736818

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

module PowerStencil
  module Plugins

    module Capabilities

      include PowerStencil::Utils::FileHelper

      CAPABILITIES = %i(config command_line processors build dsl entity_definitions templates).freeze

      attr_reader :plugin_definition

      def plugin_capabilities_definition_file
        project.plugin_capabilities_definition_file self.name
      end

      def capabilities
        @capabilities ||= CAPABILITIES.dup.zip([false] * CAPABILITIES.size).to_h
      end

      private

      def load_capabilities
        yaml_file = plugin_capabilities_definition_file
        unless File.exists? yaml_file and File.file? yaml_file and File.readable? yaml_file
          raise PowerStencil::Error, "Plugin '#{self.name}' has no definition file !"
        end
        @plugin_definition = yaml_file_to_hash yaml_file
        %i(processors entity_definitions templates build dsl).each do |capability|
          unless plugin_definition[capability].nil? or plugin_definition[capability].empty?
            capabilities[capability] = true
          end
        end

      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/capabilities.rb
power_stencil-0.5.0 lib/power_stencil/plugins/capabilities.rb