Cache Tty.width, since it is used heavily because of ohai.
This commit is contained in:
parent
502b393d66
commit
13d9305fad
@ -6,10 +6,12 @@ module Tty
|
|||||||
end
|
end
|
||||||
|
|
||||||
def width
|
def width
|
||||||
width = `/bin/stty size 2>/dev/null`.split[1]
|
@width ||= begin
|
||||||
width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero?
|
width = `/bin/stty size 2>/dev/null`.split[1]
|
||||||
width ||= 80
|
width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero?
|
||||||
width.to_i
|
width ||= 80
|
||||||
|
width.to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def truncate(string)
|
def truncate(string)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user