module XCPretty::ANSI
Constants
- COLORS
- EFFECT
- FORMATTED_MATCHER
Attributes
colorize[RW]
Public Instance Methods
ansi_parse(text, color, effect=nil)
click to toggle source
# File lib/xcpretty/ansi.rb, line 64 def ansi_parse(text, color, effect=nil) return text unless colorize? colors_code = COLORS[color] || '' effect_code = EFFECT[effect] ? ';' + EFFECT[effect] : '' "\e[#{colors_code}#{effect_code}m#{text}\e[#{EFFECT[:reset]}m" end
applied_effects(text)
click to toggle source
# File lib/xcpretty/ansi.rb, line 49 def applied_effects(text) effects = [] if text =~ FORMATTED_MATCHER colors = COLORS.invert[$1] effect = EFFECT.invert[$2] effects << colors if colors effects << effect if effect end effects end
colorize?()
click to toggle source
# File lib/xcpretty/ansi.rb, line 25 def colorize? !!@colorize end
cyan(text)
click to toggle source
# File lib/xcpretty/ansi.rb, line 41 def cyan(text) ansi_parse(text, :cyan) end
green(text)
click to toggle source
# File lib/xcpretty/ansi.rb, line 37 def green(text) ansi_parse(text, :green, :bold) end
red(text)
click to toggle source
# File lib/xcpretty/ansi.rb, line 33 def red(text) ansi_parse(text, :red) end
strip(text)
click to toggle source
# File lib/xcpretty/ansi.rb, line 60 def strip(text) text =~ FORMATTED_MATCHER ? $3 : text end
white(text)
click to toggle source
# File lib/xcpretty/ansi.rb, line 29 def white(text) ansi_parse(text, :plain, :bold) end
yellow(text)
click to toggle source
# File lib/xcpretty/ansi.rb, line 45 def yellow(text) ansi_parse(text, :yellow) end