Permalink
Browse files

reverted change to albino

  • Loading branch information...
1 parent 605ea9e commit 0e23c6f03191a10f2ad7539bb8a59e7d2f41e714 @lachie committed Jun 17, 2009
Showing with 18 additions and 34 deletions.
  1. +18 −34 lib/albino.rb
View
@@ -41,6 +41,7 @@
# Chris Wanstrath // chris@ozmm.org
# GitHub // http://github.com
#
+require 'rubygems'
require 'open4'
class Albino
@@ -62,34 +63,15 @@ def initialize(target, lexer = :text, format = :html)
@options = { :l => lexer, :f => format }
end
+
def execute(command)
- puts "command: #{command}"
pid, stdin, stdout, stderr = Open4.popen4(command)
-
- puts "reading stdin"
stdin.puts @target
stdin.close
- puts "done reading stdin"
-
-
- begin
- err = stderr.read_nonblock(0)
- rescue EAGAIN
- puts "nothing on err"
- err = nil
- end
- puts "done reading stderr"
-
- if err && !err.empty?
- err += stderr.read
- puts "failed to convert using command #{command}"
- puts err
- "failed to convert: (#{command})"
- else
- puts "reading stdout"
- stdout.read.strip
- end
+ stdout.read.strip
end
+
+
def colorize(options = {})
execute @@bin + convert_options(options)
@@ -163,28 +145,30 @@ def self.render_without_pygments(non_code)
if $0 == __FILE__
require 'rubygems'
require 'test/spec'
- require 'mocha'
+ # require 'mocha'
begin require 'redgreen'; rescue LoadError; end
context "Albino" do
setup do
@syntaxer = Albino.new(__FILE__, :ruby)
end
- specify "defaults to text" do
- syntaxer = Albino.new(__FILE__)
- syntaxer.expects(:execute).with('pygmentize -f html -l text').returns(true)
- syntaxer.colorize
- end
+ # specify "defaults to text" do
+ # syntaxer = Albino.new(__FILE__)
+ # syntaxer.expects(:execute).with('pygmentize -f html -l text').returns(true)
+ # syntaxer.colorize
+ # end
- specify "accepts options" do
- @syntaxer.expects(:execute).with('pygmentize -f html -l ruby').returns(true)
- @syntaxer.colorize
- end
+ # specify "accepts options" do
+ # @syntaxer.expects(:execute).with('pygmentize -f html -l ruby').returns(true)
+ # @syntaxer.colorize
+ # end
specify "works with strings" do
syntaxer = Albino.new('class New; end', :ruby)
- assert_match %r(highlight), syntaxer.colorize
+ c = syntaxer.colorize
+ puts c
+ assert_match %r(highlight), c
end
specify "aliases to_s" do

0 comments on commit 0e23c6f

Please sign in to comment.