-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from michaeljoseph/slide-models
Slide models
- Loading branch information
Showing
8 changed files
with
106 additions
and
16 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,2 @@ | ||
[run] | ||
omit = *virtualenv*, *pypy* |
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
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
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 |
---|---|---|
|
@@ -3,6 +3,3 @@ | |
__url__ = 'https://github.com/michaeljoseph/snide' | ||
__version__ = '0.0.1' | ||
|
||
|
||
def snide(): | ||
return 'Hello World!' |
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,43 @@ | ||
import markdown2 | ||
|
||
|
||
class Deck(object): | ||
|
||
def __init__(self, title, text): | ||
self.slides = [] | ||
self.title = title | ||
self.text = text | ||
print(text.split('---')) | ||
for slide in text.split('---'): | ||
self.slides.append(Slide(slide)) | ||
|
||
def to_json(self): | ||
return { | ||
'title': self.title, | ||
'slides': [slide.to_json() for slide in self.slides], | ||
} | ||
|
||
|
||
class Slide(object): | ||
|
||
def __init__(self, text): | ||
self.markdown = text | ||
self.config = self.parse_config(text) | ||
|
||
@property | ||
def html(self): | ||
return markdown2.markdown(self.markdown) | ||
|
||
def parse_config(self, slide): | ||
# re of lines: key:value, key=value | ||
return { | ||
|
||
} | ||
|
||
def to_json(self): | ||
return { | ||
'text': self.markdown, | ||
'html': self.html, | ||
'config': self.config, | ||
} | ||
|
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 |
---|---|---|
|
@@ -2,9 +2,5 @@ | |
|
||
|
||
class BaseTestCase(TestCase): | ||
pass | ||
|
||
def setUp(self): | ||
pass | ||
|
||
def tearDown(self): | ||
pass |
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 |
---|---|---|
@@ -1,12 +1,44 @@ | ||
from . import BaseTestCase | ||
|
||
from snide import snide | ||
from snide.models import Deck, Slide | ||
|
||
|
||
class TestSnide(BaseTestCase): | ||
class TestDeck(BaseTestCase): | ||
|
||
def test_something(self): | ||
def setUp(self): | ||
self.deck_text = ('# first slide' | ||
'---' | ||
'# second slide').strip() | ||
|
||
self.expected_deck = Deck('foo', self.deck_text) | ||
self.expected_deck.slides = [ | ||
Slide('# first slide'), | ||
Slide('# second slide') | ||
] | ||
|
||
def test_deck(self): | ||
self.assertEquals( | ||
'Hello World!', | ||
snide(), | ||
self.expected_deck.to_json(), | ||
Deck('foo', self.deck_text).to_json() | ||
) | ||
|
||
|
||
class TestSlide(BaseTestCase): | ||
|
||
def setUp(self): | ||
self.expected_slide = Slide('# first slide\n\n- and\n- then\n- this') | ||
|
||
def test_slide(self): | ||
|
||
slide_text = '# first slide\n\n- and\n- then\n- this' | ||
self.assertEquals( | ||
self.expected_slide.to_json(), | ||
Slide(slide_text).to_json() | ||
) | ||
|
||
pass | ||
|
||
def test_slide_render(self): | ||
pass | ||
|
||
|
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
PATTERNS = ( | ||
(r'.*\.py$', [pep8_all, pyflakes_all, nosetests_all]), | ||
) | ||
) |