123456789_123456789_123456789_123456789_123456789_

Module: Bundler::Thor::Shell::Terminal

Relationships & Source Files
Defined in: lib/bundler/vendor/thor/lib/thor/shell/terminal.rb

Constant Summary

Class Attribute Summary

Class Method Summary

Class Attribute Details

.unix?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/vendor/thor/lib/thor/shell/terminal.rb', line 20

def unix?
  RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i
end

Class Method Details

.dynamic_width (private)

Calculate the dynamic width of the terminal

[ GitHub ]

  
# File 'lib/bundler/vendor/thor/lib/thor/shell/terminal.rb', line 27

def dynamic_width
  @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
end

.dynamic_width_stty (private)

[ GitHub ]

  
# File 'lib/bundler/vendor/thor/lib/thor/shell/terminal.rb', line 31

def dynamic_width_stty
  `stty size 2>/dev/null`.split[1].to_i
end

.dynamic_width_tput (private)

[ GitHub ]

  
# File 'lib/bundler/vendor/thor/lib/thor/shell/terminal.rb', line 35

def dynamic_width_tput
  `tput cols 2>/dev/null`.to_i
end

.terminal_width

This code was copied from Rake, available under MIT-LICENSE Copyright © 2003, 2004 Jim Weirich

[ GitHub ]

  
# File 'lib/bundler/vendor/thor/lib/thor/shell/terminal.rb', line 9

def terminal_width
  result = if ENV["THOR_COLUMNS"]
    ENV["THOR_COLUMNS"].to_i
  else
    unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
  end
  result < 10 ? DEFAULT_TERMINAL_WIDTH : result
rescue
  DEFAULT_TERMINAL_WIDTH
end