Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Remove the duplication when creating Converters and Generators #841

Closed
wants to merge 2 commits into from

2 participants

@mattr-
Owner

I'm submitting this mostly for feedback. I removed the duplication when walking the subclass tree of both Jekyll::Generators and Jekyll::Converters but I'm not too happy with the name of the new method. Any other ideas are most welcome.

This is take 2.

mattr- added some commits
@mattr- mattr- Remove the duplication when creating Converters and Generators
Encapsulate it in a method and give the method the class to walk the
subclass tree for to create new objects.
7285305
@mattr- mattr- Remove the duplicated code.
This completes the refactoring.
42cd5fb
@parkr
Owner

Yeah, I'm definitely not a big fan of that function name... hm. Also, please rebase :)

@mattr-
Owner

Suggestions welcome! Will rebase in the meantime.

@parkr
Owner

Thanks, Matt. I'll keep thinking. Now sure how to describe what that method does succinctly...

@parkr
Owner

Merged in 10ee5c8

@parkr parkr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2013
  1. @mattr-

    Remove the duplication when creating Converters and Generators

    mattr- authored
    Encapsulate it in a method and give the method the class to walk the
    subclass tree for to create new objects.
Commits on Mar 9, 2013
  1. @mattr-

    Remove the duplicated code.

    mattr- authored
    This completes the refactoring.
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 11 deletions.
  1. +10 −11 lib/jekyll/site.rb
View
21 lib/jekyll/site.rb
@@ -88,17 +88,8 @@ def setup
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 = hydrate(Jekyll::Converter)
+ self.generators = hydrate(Jekyll::Generator)
end
# Internal: Setup the plugin search path
@@ -395,5 +386,13 @@ def getConverterImpl(klass)
raise "Converter implementation not found for #{klass}"
end
end
+
+ def hydrate(klass)
+ klass.subclasses.select do |c|
+ !self.safe || c.safe
+ end.map do |c|
+ c.new(self.config)
+ end
+ end
end
end
Something went wrong with that request. Please try again.