Missing commands return the input (instead of nothing)
Chris Wanstrath chris@ozmm.org
Tue, 17 Nov 2009 11:13:43 -0800
3 files changed,
15 insertions(+),
0 deletions(-)
M
HISTORY.md
→
HISTORY.md
@@ -1,3 +1,7 @@
+## 0.1.4 (2009-11-17) + +* Bugfix: Missing commands return the input (instead of nothing) + ## 0.1.3 (2009-11-02) * Strip the INDEX comments from POD
M
lib/github/markup.rb
→
lib/github/markup.rb
@@ -26,6 +26,7 @@ end
def command(command, regexp, &block) command = command.to_s + if !File.exists?(command) && !command.include?('/') command = File.dirname(__FILE__) + '/commands/' + command.to_s end@@ -54,6 +55,8 @@ 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.rb
→
test/markup_test.rb
@@ -26,4 +26,12 @@ assert_equal false, GitHub::Markup.can_render?('README.html')
assert_equal true, GitHub::Markup.can_render?('README.markdown') assert_equal false, GitHub::Markup.can_render?('README.cmd') end + + 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') + actual = GitHub::Markup.render('README.mde', text) + assert_equal text, actual + end end