Sha256: 56e416e9269ee73ae4a86408af6c9bf42aed58a01d336260c608c1f3d2b4abde

Contents?: true

Size: 1.68 KB

Versions: 159

Compression:

Stored size: 1.68 KB

Contents

class Pry
  class Command::Ls < Pry::ClassCommand
    class Globals < Pry::Command::Ls::Formatter

      # Taken from "puts global_variables.inspect".
      BUILTIN_GLOBALS =
        %w($" $$ $* $, $-0 $-F $-I $-K $-W $-a $-d $-i $-l $-p $-v $-w $. $/ $\\
           $: $; $< $= $> $0 $ARGV $CONSOLE $DEBUG $DEFAULT_INPUT $DEFAULT_OUTPUT
           $FIELD_SEPARATOR $FILENAME $FS $IGNORECASE $INPUT_LINE_NUMBER
           $INPUT_RECORD_SEPARATOR $KCODE $LOADED_FEATURES $LOAD_PATH $NR $OFS
           $ORS $OUTPUT_FIELD_SEPARATOR $OUTPUT_RECORD_SEPARATOR $PID $PROCESS_ID
           $PROGRAM_NAME $RS $VERBOSE $deferr $defout $stderr $stdin $stdout)

      # `$SAFE` and `$?` are thread-local, the exception stuff only works in a
      # rescue clause, everything else is basically a local variable with a `$`
      # in its name.
      PSEUDO_GLOBALS =
        %w($! $' $& $` $@ $? $+ $_ $~ $1 $2 $3 $4 $5 $6 $7 $8 $9
           $CHILD_STATUS $SAFE $ERROR_INFO $ERROR_POSITION $LAST_MATCH_INFO
           $LAST_PAREN_MATCH $LAST_READ_LINE $MATCH $POSTMATCH $PREMATCH)

      def initialize(opts, _pry_)
        super(_pry_)
        @default_switch = opts[:globals]
      end

      def output_self
        variables = format(@target.eval('global_variables'))
        output_section('global variables', grep.regexp[variables])
      end

      private

      def format(globals)
        globals.map(&:to_s).sort_by(&:downcase).map do |name|
          if PSEUDO_GLOBALS.include?(name)
            color(:pseudo_global, name)
          elsif BUILTIN_GLOBALS.include?(name)
            color(:builtin_global, name)
          else
            color(:global_var, name)
          end
        end
      end

    end
  end
end

Version data entries

159 entries across 152 versions & 35 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/ls/globals.rb