Sha256: d1af9f583e1e81c67d0200762eb5219338c584260061df589df8c60ca88ec8f7

Contents?: true

Size: 1.31 KB

Versions: 6817

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_relative "eval"

module Byebug
  module Helpers
    #
    # Utilities for variable subcommands
    #
    module VarHelper
      include EvalHelper

      def var_list(ary, binding = context.frame._binding)
        vars = ary.sort.map do |name|
          [name, safe_inspect(silent_eval(name.to_s, binding))]
        end

        puts prv(vars, "instance")
      end

      def var_global
        globals = global_variables.reject do |v|
          %i[$IGNORECASE $= $KCODE $-K $binding].include?(v)
        end

        var_list(globals)
      end

      def var_instance(str)
        obj = warning_eval(str || "self")

        var_list(obj.instance_variables, obj.instance_eval { binding })
      end

      def var_local
        locals = context.frame.locals
        cur_self = context.frame._self
        locals[:self] = cur_self unless cur_self.to_s == "main"
        puts prv(locals.keys.sort.map { |k| [k, locals[k]] }, "instance")
      end

      def var_args
        args = context.frame.args
        return if args == [[:rest]]

        all_locals = context.frame.locals
        arg_values = args.map { |arg| arg[1] }

        locals = all_locals.select { |k, _| arg_values.include?(k) }
        puts prv(locals.keys.sort.map { |k| [k, locals[k]] }, "instance")
      end
    end
  end
end

Version data entries

6,817 entries across 6,814 versions & 32 rubygems

Version Path
ory-client-0.0.1.alpha27 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-client-0.0.1.alpha24 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
primary_connect_proto-0.0.4 vendor/bundle/ruby/2.6.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
primary_connect_proto-0.0.3 vendor/bundle/ruby/2.6.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-client-0.0.1.alpha23 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-kratos-client-0.8.0.alpha2 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-client-0.0.1.alpha21 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-keto-client-0.7.0.alpha1 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-keto-client-0.7.0.alpha0 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-kratos-client-0.7.6.alpha7 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-kratos-client-0.7.6.alpha6 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-kratos-client-0.7.6.alpha5 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-kratos-client-0.7.6.alpha4 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-kratos-client-0.7.6.alpha3 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-kratos-client-0.7.6.alpha1 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
ory-kratos-client-0.7.5.alpha2 vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
mx-platform-ruby-0.4.0 vendor/bundle/ruby/2.6.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb
mx-platform-ruby-0.3.2 vendor/bundle/ruby/2.6.0/gems/byebug-11.1.3/lib/byebug/helpers/var.rb