Sha256: 524b5de3c5ba8b74199df7951a110b44894b4a8308849ad75b30ed304e9c33ad

Contents?: true

Size: 866 Bytes

Versions: 12

Compression:

Stored size: 866 Bytes

Contents

module Imagine
  module Engines; end;

  class Plugin

    attr_accessor :name, :version, :pathname, :directory
    attr_reader   :description

    def self.register(&block)
      yield(plugin = self.new)

      raise "A plugin MUST have a name!: #{plugin.inspect}" if plugin.name.blank?

      # add the new plugin to the collection of registered plugins
      ::Imagine::Plugins.registered << plugin
    end

    def pathname=(value)
      value = Pathname.new(value) if value.is_a? String
      @pathname = value
    end

  # Make this protected, so that only Plugin.register can use it.
  protected
    def initialize
      # provide a default pathname to where this plugin is using its lib directory.
      depth = RUBY_VERSION >= "1.9.2" ? 4 : 3
      self.pathname ||= Pathname.new(caller(depth).first.match("(.*)#{File::SEPARATOR}lib")[1])
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
imagine-0.3.0 lib/imagine/plugin.rb
imagine-0.2.3 lib/imagine/plugin.rb
imagine-0.2.2 lib/imagine/plugin.rb
imagine-0.2.1 lib/imagine/plugin.rb
imagine-0.2.0 lib/imagine/plugin.rb
imagine-0.1.7 lib/imagine/plugin.rb
imagine-0.1.6 lib/imagine/plugin.rb
imagine-0.1.5 lib/imagine/plugin.rb
imagine-0.1.4 lib/imagine/plugin.rb
imagine-0.1.3 lib/imagine/plugin.rb
imagine-0.1.2 lib/imagine/plugin.rb
imagine-0.1.1 lib/imagine/plugin.rb