okay this is how we'll deal with broken commands
Chris Wanstrath chris@ozmm.org
Tue, 17 Nov 2009 18:36:06 -0800
2 files changed,
5 insertions(+),
4 deletions(-)
M
lib/github/markup.rb
→
lib/github/markup.rb
@@ -31,10 +31,9 @@ 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) + rendered = rendered.to_s.empty? ? content : rendered block ? block.call(rendered) : rendered end end@@ -64,6 +63,8 @@ stdin.close
out = stdout.read end out.gsub("\r", '') + rescue Errno::EPIPE + "" end # Define markups
M
test/markup_test.rb
→
test/markup_test.rb
@@ -30,7 +30,7 @@
def test_fails_gracefully_on_missing_commands GitHub::Markup.command(:i_made_it_up, /mde/) text = 'hi there' - assert_equal false, GitHub::Markup.can_render?('README.mde') + assert GitHub::Markup.can_render?('README.mde') actual = GitHub::Markup.render('README.mde', text) assert_equal text, actual end@@ -38,7 +38,7 @@
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') + assert GitHub::Markup.can_render?('README.tf') actual = GitHub::Markup.render('README.tf', text) assert_equal text, actual end