public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
mephisto / lib / mephisto / directory_plugin.rb
100644 26 lines (22 sloc) 0.67 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Object model of a plugin in plugins/vendor. May or may not have an internal Mephisto::Plugins::Plugin (an AR).
module Mephisto
  class DirectoryPlugin
    @@filter = /^mephisto_(\w+)$/
    attr_accessor :plugin, :path
    
    def self.scan
      Dir.new("#{RAILS_ROOT}/vendor/plugins/").collect do |entry|
        # don't list "invisible" plugins nor directories/files hidden on the filesystem
        entry =~ @@filter ? new($1) : nil
      end.compact
    end
    
    def initialize(path)
      @path = path
    end
    
    def klass
      @klass ||= Mephisto::Plugin[@path] rescue :false
    end
    
    def configurable?
      klass != :false
    end
  end
end