Sha256: da9117d76400653da0772823705f094a02e0c08c3f7abc3a571ee43655c89f0f

Contents?: true

Size: 899 Bytes

Versions: 2

Compression:

Stored size: 899 Bytes

Contents

require 'English'
require 'pp'
require 'byebug/command'
require 'byebug/helpers/eval'

module Byebug
  #
  # Evaluation, pretty printing, columnizing and sorting from byebug's prompt
  #
  class PsCommand < Command
    include Helpers::EvalHelper
    include Columnize

    self.allow_in_control = true

    def regexp
      /^\s* ps \s+/x
    end

    def execute
      out = StringIO.new
      run_with_binding do |b|
        res = eval_with_setting(b, @match.post_match, Setting[:stack_on_error])

        if res.is_a?(Array)
          puts "#{columnize(res.map(&:to_s).sort!, Setting[:width])}"
        else
          PP.pp(res, out)
          puts out.string
        end
      end
    rescue
      out.puts $ERROR_INFO.message
    end

    def description
      <<-EOD
        ps <expression>

        Evaluates <expression>, an array, sort and columnize its value.
      EOD
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/byebug-5.0.0/lib/byebug/commands/ps.rb
byebug-5.0.0 lib/byebug/commands/ps.rb