Sha256: c901110f73f2978592545fb576f5ef4a926c223fd85db86261c954e07ad2eba4

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

module PowerStencil
  module Plugins

    module CommandLine

      attr_reader :plugin_command_line_modifier

      def plugin_commands_line_definition_file
        project.plugin_commands_line_definition_file self.name
      end

      def register_processors
        plugin_definition[:processors].each do |processors_name, processor|
          clm = PowerStencil.command_line_manager
          processor_class = Object.const_get processor
          clm.register_processor clm.command_by_alias(processors_name), processor_class.new
        end
      end

      private

      def load_yaml_command_definition
        yaml_file = plugin_commands_line_definition_file
        if File.exists? yaml_file and File.file? yaml_file and File.readable? yaml_file
          logger.info "Adding extra command line definition for '#{name}' plugin..."
          @plugin_command_line_modifier = project.yaml_file_to_hash yaml_file
          command_line_manager.contribute_to_definition @plugin_command_line_modifier, layer_name: "Plugin: #{name}"
          capabilities[:command_line] = true
        else
          logger.debug "There is no extra command line definition provided by plugin '#{name}'."
        end
      rescue => e
        logger.debug PowerStencil::Error.report_error(e)
        logger.warn "Could not load yaml file '#{yaml_file}' because '#{e.message}'"
      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/command_line.rb
power_stencil-0.5.0 lib/power_stencil/plugins/command_line.rb