Skip to content

Instantly share code, notes, and snippets.

@cypok
Forked from NIA/truecolor.rb
Last active Dec 25, 2015
Embed
What would you like to do?
#!/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