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,
|
:high => 10,
|
||||||
:highest => 100 }
|
:highest => 100 }
|
||||||
|
|
||||||
# Install a hook so that subclasses are recorded. This method is only
|
# Fetch all the subclasses of this class and its subclasses' subclasses.
|
||||||
# ever called by Ruby itself.
|
|
||||||
#
|
#
|
||||||
# base - The Class subclass.
|
# Returns an array of descendant classes.
|
||||||
#
|
def self.descendants
|
||||||
# Returns nothing.
|
descendants = []
|
||||||
def self.inherited(base)
|
ObjectSpace.each_object(singleton_class) do |k|
|
||||||
subclasses << base
|
descendants.unshift k unless k == self
|
||||||
subclasses.sort!
|
|
||||||
end
|
end
|
||||||
|
descendants
|
||||||
# The list of Classes that have been subclassed.
|
|
||||||
#
|
|
||||||
# Returns an Array of Class objects.
|
|
||||||
def self.subclasses
|
|
||||||
@subclasses ||= []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get or set the priority of this plugin. When called without an
|
# 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
|
# Returns array of instances of subclasses of parameter
|
||||||
def instantiate_subclasses(klass)
|
def instantiate_subclasses(klass)
|
||||||
klass.subclasses.select do |c|
|
klass.descendants.select do |c|
|
||||||
!safe || c.safe
|
!safe || c.safe
|
||||||
end.sort.map do |c|
|
end.sort.map do |c|
|
||||||
c.new(config)
|
c.new(config)
|
||||||
|
|
|
@ -14,5 +14,13 @@ class TestSass < Test::Unit::TestCase
|
||||||
should "import SCSS partial" do
|
should "import SCSS partial" do
|
||||||
assert_equal ".half {\n width: 50%; }\n", File.read(@test_css_file)
|
assert_equal ".half {\n width: 50%; }\n", File.read(@test_css_file)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue