Skip to content

Instantly share code, notes, and snippets.

@cypok
Forked from NIA/truecolor.rb
Last active December 25, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cypok/6963467 to your computer and use it in GitHub Desktop.
Save cypok/6963467 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Usage example: sml hw1test.sml | truecolor.rb
require 'colorize'
true_pat = /\btrue\b/
false_pat = /\bfalse\b/
true_count = 0
false_count = 0
while line = gets
puts line.gsub(true_pat) { true_count += 1; 'true'.green }
.gsub(false_pat) { false_count += 1; 'false'.red }
end
puts true_count.to_s.green + ' passed' +
if false_count > 0
', ' + false_count.to_s.red + ' failed'
else
''
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment