Permalink
Browse files

avoid which(1)

  • Loading branch information...
rtomayko committed Apr 2, 2010
1 parent 957e5cf commit eed5d48981fd5c53fdcdcb18f68a5ac7a594ad37
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/rocco.rb
View
@@ -52,7 +52,8 @@
# Code is run through [Pygments](http://pygments.org/) for syntax
# highlighting. If it's not installed, locally, use a webservice.
-if `which pygmentize`.blank?
+include FileTest
+if !ENV['PATH'].split(':').any? { |dir| executable?("#{dir}/pygmentize") }
warn "WARNING: Pygments not found. Using webservice."
end
@@ -166,10 +167,10 @@ def highlight(blocks)
# `pygmentize(1)` or <http://pygments.appspot.com>
code_stream = code_blocks.join("\n\n#{@options[:comment_chars]} DIVIDER\n\n")
- if `which pygmentize`.blank?
- code_html = highlight_webservice(code_stream)
- else
+ if ENV['PATH'].split(':').any? { |dir| executable?("#{dir}/pygmentize") }
code_html = highlight_pygmentize(code_stream)
+ else
+ code_html = highlight_webservice(code_stream)
end
# Do some post-processing on the pygments output to split things back

0 comments on commit eed5d48

Please sign in to comment.