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
 | 
			
		||||
 | 
			
		||||
  def width
 | 
			
		||||
    width = `/bin/stty size 2>/dev/null`.split[1]
 | 
			
		||||
    width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero?
 | 
			
		||||
    width ||= 80
 | 
			
		||||
    width.to_i
 | 
			
		||||
    @width ||= begin
 | 
			
		||||
      width = `/bin/stty size 2>/dev/null`.split[1]
 | 
			
		||||
      width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero?
 | 
			
		||||
      width ||= 80
 | 
			
		||||
      width.to_i
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def truncate(string)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user