autoload extensions

This commit is contained in:
Thomas Reynolds 2011-08-18 17:33:45 -07:00
parent e7580c8bf8
commit 38c46cc89a
2 changed files with 19 additions and 0 deletions

View file

@ -154,6 +154,23 @@ module Middleman
autoload :DirectoryIndexes, "middleman/features/directory_indexes" autoload :DirectoryIndexes, "middleman/features/directory_indexes"
end end
EXTENSION_FILE = "middleman_init.rb"
def self.load_extensions_in_path
# If newer Rubygems
extensions = if Gem::Specification.respond_to? :select
::Gem::Specification.select do |spec|
spec.contains_requirable_file?(EXTENSION_FILE)
end
else
::Gem::GemPathSearcher.new.find_all(EXTENSION_FILE)
end
extensions.each do |spec|
require spec.name
$stderr.puts "require: #{spec.name}"
end
end
def self.server(&block) def self.server(&block)
sandbox = Class.new(Sinatra::Base) sandbox = Class.new(Sinatra::Base)
sandbox.register Base sandbox.register Base
@ -178,3 +195,4 @@ module Middleman
end end
require "middleman/version" require "middleman/version"
Middleman.load_extensions_in_path

View file

@ -8,6 +8,7 @@ Gem::Specification.new do |s|
s.name = "middleman" s.name = "middleman"
s.version = Middleman::VERSION s.version = Middleman::VERSION
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.license = "MIT"
s.authors = ["Thomas Reynolds"] s.authors = ["Thomas Reynolds"]
s.email = ["me@tdreyno.com"] s.email = ["me@tdreyno.com"]
s.homepage = "http://middlemanapp.com" s.homepage = "http://middlemanapp.com"