avoid which(1)

This commit is contained in:
Ryan Tomayko 2010-04-02 15:59:52 -07:00
parent 957e5cf197
commit eed5d48981

View File

@ -52,7 +52,8 @@ require 'net/http'
# 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 @@ class Rocco
# `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