-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Layman
committed
Mar 19, 2015
1 parent
97e3b20
commit a916646
Showing
6 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Copyright (c) 2015, Matt Layman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (c) 2015, Matt Layman | ||
|
||
|
||
class Extension(object): | ||
"""A base extension which hooks handler methods to handroll's signals.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) 2015, Matt Layman | ||
|
||
from handroll.extensions.base import Extension | ||
|
||
|
||
class BlogExtension(Extension): | ||
"""Track files marked as blog entries and generate a feed.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) 2015, Matt Layman | ||
|
||
from pkg_resources import iter_entry_points | ||
|
||
|
||
class ExtensionLoader(object): | ||
"""A loader for extensions from handroll's extension entry point.""" | ||
|
||
def __init__(self): | ||
self._available_extensions = {} | ||
|
||
def load(self): | ||
"""Load all available extensions from ``handroll.extensions``.""" | ||
for entry_point in iter_entry_points('handroll.extensions'): | ||
cls = entry_point.load() | ||
self._available_extensions[entry_point.name] = cls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) 2015, Matt Layman | ||
|
||
from handroll.extensions.blog import BlogExtension | ||
from handroll.extensions.loader import ExtensionLoader | ||
from handroll.tests import TestCase | ||
|
||
|
||
class TestExtensionLoader(TestCase): | ||
|
||
def test_loads_available_extensions(self): | ||
loader = ExtensionLoader() | ||
loader.load() | ||
self.assertEqual(BlogExtension, loader._available_extensions['blog']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters