Sha256: ad9e69efe4d958871623d90b417bcacb7fa1bffffda44092758457b5eec78882

Contents?: true

Size: 1.02 KB

Versions: 58

Compression:

Stored size: 1.02 KB

Contents

class Bundler::Thor
  module Shell
    module Terminal
      DEFAULT_TERMINAL_WIDTH = 80

      class << self
        # This code was copied from Rake, available under MIT-LICENSE
        # Copyright (c) 2003, 2004 Jim Weirich
        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

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

      private

        # Calculate the dynamic width of the terminal
        def dynamic_width
          @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
        end

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

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

      end
    end
  end
end

Version data entries

58 entries across 58 versions & 4 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/bundler-2.5.21/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
rubygems-update-3.6.3 bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
bundler-2.6.3 lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/bundler-2.5.5/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
rubygems-update-3.6.2 bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
bundler-2.6.2 lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
rubygems-update-3.6.1 bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
bundler-2.6.1 lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
rubygems-update-3.6.0 bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
bundler-2.6.0 lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
rubygems-update-3.5.23 bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
bundler-2.5.23 lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
rubygems-update-3.5.22 bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
bundler-2.5.22 lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
rubygems-update-3.5.21 bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
bundler-2.5.21 lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
rubygems-update-3.5.20 bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
bundler-2.5.20 lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
rubygems-update-3.5.19 bundler/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
bundler-2.5.19 lib/bundler/vendor/thor/lib/thor/shell/terminal.rb