Module: GitRunner::Text
Constant Summary collapse
- COLOR_START =
"\033["
- COLOR_END =
"m"
- COLOR_RESET =
"#{COLOR_START}0#{COLOR_END}"
- COLORS =
{ :black => 30, :red => 31, :green => 32, :yellow => 33, :blue => 34, :purple => 35, :cyan => 36, :white => 37 }
- STYLES =
{ :normal => 0, :bold => 1, :underline => 4 }
Instance Method Summary collapse
- #begin ⇒ Object
- #finish ⇒ Object
- #indent(spaces = 2) ⇒ Object
- #new_line ⇒ Object
- #out(str, style = nil) ⇒ Object
Instance Method Details
#begin ⇒ Object
27 28 29 30 |
# File 'lib/git-runner/text.rb', line 27 def begin STDOUT.sync = true print("\e[1G \e[1G") end |
#finish ⇒ Object
32 33 34 |
# File 'lib/git-runner/text.rb', line 32 def finish print("\n") end |
#indent(spaces = 2) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/git-runner/text.rb', line 47 def indent(spaces=2) @indentation ||= 0 @indentation += spaces yield @indentation -= spaces Text.new_line end |
#new_line ⇒ Object
43 44 45 |
# File 'lib/git-runner/text.rb', line 43 def new_line out('') end |
#out(str, style = nil) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/git-runner/text.rb', line 36 def out(str, style=nil) # Ensure that new lines overwrite the default 'remote: ' text str = str.gsub("\n", "\n\e[1G#{padding(nil)}") print "\n\e[1G#{padding(style).ljust(7 + (@indentation || 0))}#{str}" end |