Register subclasses of subclasses of Jekyll::Plugin
The Sass and SCSS converters are practically the same – only different in the input syntax and file extension. As such, we've created `Jekyll::Converters::Scss` which is a subclass of `Jekyll::Converter`, and `Jekyll::Converters::Sass` which is a subclass of `Jekyll::Converters::Scss`. When `Site#instantiate_classes` is called on `Jekyll::Converter`, it only instantiates the `Scss` converter, not the `Sass` converter. This change fixes that. Fixes #2334.
This commit is contained in:
parent
0022e5a67e
commit
f2f2ebfa4f
|
@ -6,22 +6,15 @@ module Jekyll
|
|||
:high => 10,
|
||||
:highest => 100 }
|
||||
|
||||
# Install a hook so that subclasses are recorded. This method is only
|
||||
# ever called by Ruby itself.
|
||||
# Fetch all the subclasses of this class and its subclasses' subclasses.
|
||||
#
|
||||
# base - The Class subclass.
|
||||
#
|
||||
# Returns nothing.
|
||||
def self.inherited(base)
|
||||
subclasses << base
|
||||
subclasses.sort!
|
||||
end
|
||||
|
||||
# The list of Classes that have been subclassed.
|
||||
#
|
||||
# Returns an Array of Class objects.
|
||||
def self.subclasses
|
||||
@subclasses ||= []
|
||||
# Returns an array of descendant classes.
|
||||
def self.descendants
|
||||
descendants = []
|
||||
ObjectSpace.each_object(singleton_class) do |k|
|
||||
descendants.unshift k unless k == self
|
||||
end
|
||||
descendants
|
||||
end
|
||||
|
||||
# Get or set the priority of this plugin. When called without an
|
||||
|
|
|
@ -365,7 +365,7 @@ module Jekyll
|
|||
#
|
||||
# Returns array of instances of subclasses of parameter
|
||||
def instantiate_subclasses(klass)
|
||||
klass.subclasses.select do |c|
|
||||
klass.descendants.select do |c|
|
||||
!safe || c.safe
|
||||
end.sort.map do |c|
|
||||
c.new(config)
|
||||
|
|
|
@ -14,5 +14,13 @@ class TestSass < Test::Unit::TestCase
|
|||
should "import SCSS partial" do
|
||||
assert_equal ".half {\n width: 50%; }\n", File.read(@test_css_file)
|
||||
end
|
||||
|
||||
should "register the SCSS converter" do
|
||||
assert !!@site.getConverterImpl(Jekyll::Converters::Scss), "SCSS converter implementation should exist."
|
||||
end
|
||||
|
||||
should "register the Sass converter" do
|
||||
assert !!@site.getConverterImpl(Jekyll::Converters::Sass), "Sass converter implementation should exist."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue