lib/bagit/string.rb in bagit-0.3.2 vs lib/bagit/string.rb in bagit-0.3.4
- old
+ new
@@ -11,13 +11,25 @@
else
s
end
end
-
+
# Indent each line of a string by n spaces
def indent(n)
indent = ' ' * n
gsub '\n', "\n#{indent}"
end
+# Colorize logs
+ def color(color_code)
+ "\e[#{color_code}m#{self}\e[0m"
+ end
+
+ def red
+ color(31)
+ end
+
+ def green
+ color(32)
+ end
end