all repos — markup @ 6829e906790921de6398c5a80a137dbcd059ee53

The code we use to render README.your_favorite_markup

Actually, if we can't render a thing then don't. Not once, not never.
Chris Wanstrath chris@ozmm.org
Tue, 17 Nov 2009 11:39:46 -0800
commit

6829e906790921de6398c5a80a137dbcd059ee53

parent

7945437b91eae7ac8dacae84d897a587b357b9be

3 files changed, 17 insertions(+), 5 deletions(-)

jump to
M HISTORY.mdHISTORY.md

@@ -1,3 +1,7 @@

+## 0.1.5 (2009-11-17) + +* Actually, if we can't render a thing then don't. Not once, not never. + ## 0.1.4 (2009-11-17) * Bugfix: Missing commands return the input (instead of nothing)
M lib/github/markup.rblib/github/markup.rb

@@ -27,9 +27,11 @@

def command(command, regexp, &block) command = command.to_s - if !File.exists?(command) && !command.include?('/') - command = File.dirname(__FILE__) + '/commands/' + command.to_s + if File.exists?(file = File.dirname(__FILE__) + "/commands/#{command}") + command = file end + + return if !system("which #{command} > /dev/null") add_markup(regexp) do |content| rendered = execute(command, content)

@@ -55,8 +57,6 @@ nil

end def execute(command, target) - return target if !system("which #{command} > /dev/null") - out = '' Open3.popen3(command) do |stdin, stdout, _| stdin.puts target
M test/markup_test.rbtest/markup_test.rb

@@ -30,8 +30,16 @@

def test_fails_gracefully_on_missing_commands GitHub::Markup.command(:i_made_it_up, /mde/) text = 'hi there' - assert_equal true, GitHub::Markup.can_render?('README.mde') + assert_equal false, GitHub::Markup.can_render?('README.mde') actual = GitHub::Markup.render('README.mde', text) + assert_equal text, actual + end + + def test_fails_gracefully_on_missing_env_commands + GitHub::Markup.command('/usr/bin/env totally_fake', /tf/) + text = 'hey mang' + assert_equal false, GitHub::Markup.can_render?('README.tf') + actual = GitHub::Markup.render('README.tf', text) assert_equal text, actual end end