Added `GitHub::Markup.can_render?` helper.
Chris Wanstrath chris@ozmm.org
Mon, 02 Nov 2009 17:28:40 -0800
2 files changed,
15 insertions(+),
1 deletions(-)
M
lib/github/markup.rb
→
lib/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.rb
→
test/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