public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
thin / lib / thin / plugins.rb
100644 26 lines (23 sloc) 0.672 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
module Thin
  # Very basic plugin mechanism.
  # Loads all Gems which name starts with <tt>thin-</tt> or <tt>thin_</tt>.
  # Just reopen classes or define all you want in your gem.
  # No need for more really!
  class Plugins
    extend Logging
    
    GEM_PREFIX = "thin(-|_)"
    
    def self.gems
      sdir = File.join(Gem.dir, "specifications")
      Gem::SourceIndex.from_installed_gems(sdir).inject([]) do |plugins, (path, gem)|
        plugins << gem.name if gem.name =~ /^#{GEM_PREFIX}/
        plugins
      end.uniq
    end
    
    def self.load
      gems.each do |gem|
        log ">> Loading #{gem} gem"
        require gem
      end
    end
  end
end