Sha256: abc800534eb6f6f9605ac27b5804f8710353c4ab1dbe61527255f916ccba2348

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

#:nodoc:
module Zen
  #:nodoc:
  module Plugin
    ##
    # Base class used to store the data about plugins such as the name, plugin class, etc.
    #
    # @author Yorick Peterse
    # @since  0.2.5
    #
    class Base
      include ::Zen::Validation

      # The name of the plugin
      attr_accessor :name

      # The author of the plugin
      attr_accessor :author

      # A small description of the plugin
      attr_accessor :about

      # The URL to the plugin's website
      attr_accessor :url

      # The class of the plugin
      attr_accessor :plugin

      ##
      # Validates all the attributes.
      #
      # @author Yorick Peterse
      # @since  0.2.5
      #
      def validate
        validates_presence([:name, :author, :about, :plugin])
        validates_format(:name, /[a-z0-9_\-]+/)

        # Check if the theme doesn't exist
        if ::Zen::Plugin::Registered.key?(name.to_sym)
          raise(::Zen::ValidationError, "The plugin #{name} already exists.")
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zen-0.2.8 lib/zen/plugin/base.rb
zen-0.2.7 lib/zen/plugin/base.rb
zen-0.2.6.1 lib/zen/plugin/base.rb
zen-0.2.6 lib/zen/plugin/base.rb
zen-0.2.5 lib/zen/plugin/base.rb