gems.rainbow-2.0.0.lib.rainbow.string_utils.rb Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sass-maven-plugin Show documentation
Show all versions of sass-maven-plugin Show documentation
A Maven Plugin that compiles Sass files.
module Rainbow
class StringUtils
def self.wrap_with_sgr(string, codes)
return string if codes.empty?
seq = "\e[" + codes.join(";") + "m"
match = string.match(/^(\e\[([\d;]+)m)*/)
if match
seq_pos = match.end(0)
string = string[0...seq_pos] + seq + string[seq_pos..-1]
else
string = seq + string
end
string = string + "\e[0m" unless string =~ /\e\[0m$/
string
end
end
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy