all repos — markup @ 298ff57e57572bfb265cd74dc5be1571aef60a94

The code we use to render README.your_favorite_markup

Added `GitHub::Markup.can_render?` helper.
Chris Wanstrath chris@ozmm.org
Mon, 02 Nov 2009 17:28:40 -0800
commit

298ff57e57572bfb265cd74dc5be1571aef60a94

parent

122b433bb1ad4cf50896186944ed0820e8041303

2 files changed, 15 insertions(+), 1 deletions(-)

jump to
M lib/github/markup.rblib/github/markup.rb

@@ -10,7 +10,11 @@ extend self

@@markups = {} def render(filename, content) - renderer(filename)[content] || content + if proc = renderer(filename) + proc[content] + else + content + end end def markup(file, pattern, &block)

@@ -36,12 +40,17 @@ def add_markup(regexp, &block)

@@markups[regexp] = block end + def can_render?(filename) + !!renderer(filename) + end + def renderer(filename) @@markups.each do |key, value| if Regexp.compile("(#{key})$") =~ filename return value end end + nil end def execute(command, target)
M test/markup_test.rbtest/markup_test.rb

@@ -20,4 +20,9 @@ #{actual}

message end end + + def test_knows_what_it_can_and_cannot_render + assert_equal false, GitHub::Markup.can_render?('README.html') + assert_equal true, GitHub::Markup.can_render?('README.markdown') + end end