diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 94c4b1a0..3b21c6ad 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -88,17 +88,8 @@ module Jekyll end end - self.converters = Jekyll::Converter.subclasses.select do |c| - !self.safe || c.safe - end.map do |c| - c.new(self.config) - end - - self.generators = Jekyll::Generator.subclasses.select do |c| - !self.safe || c.safe - end.map do |c| - c.new(self.config) - end + self.converters = instantiate_subclasses(Jekyll::Converter) + self.generators = instantiate_subclasses(Jekyll::Generator) end # Internal: Setup the plugin search path @@ -388,6 +379,21 @@ module Jekyll end end + # Create array of instances of the subclasses of the class or module + # passed in as argument. + # + # klass - class or module containing the subclasses which should be + # instantiated + # + # Returns array of instances of subclasses of parameter + def instantiate_subclasses(klass) + klass.subclasses.select do |c| + !self.safe || c.safe + end.sort.map do |c| + c.new(self.config) + end + end + # Read the entries from a particular directory for processing # # dir - The String relative path of the directory to read diff --git a/test/source/_plugins/dummy.rb b/test/source/_plugins/dummy.rb new file mode 100644 index 00000000..bfd46e1c --- /dev/null +++ b/test/source/_plugins/dummy.rb @@ -0,0 +1,8 @@ +module Jekyll + class Dummy < Generator + priority :high + + def generate(site) + end + end +end diff --git a/test/test_site.rb b/test/test_site.rb index 00c2766e..07182727 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -139,6 +139,11 @@ class TestSite < Test::Unit::TestCase assert_equal mtime3, mtime4 # no modifications, so must be the same end + should "setup plugins in priority order" do + assert_equal @site.converters.sort_by(&:class).map{|c|c.class.priority}, @site.converters.map{|c|c.class.priority} + assert_equal @site.generators.sort_by(&:class).map{|g|g.class.priority}, @site.generators.map{|g|g.class.priority} + end + should "read layouts" do @site.read_layouts assert_equal ["default", "simple"].sort, @site.layouts.keys.sort