Module Pry::DefaultCommands
In: lib/pry/default_commands/introspection.rb
lib/pry/default_commands/gems.rb
lib/pry/default_commands/misc.rb
lib/pry/default_commands/help.rb
lib/pry/default_commands/commands.rb
lib/pry/default_commands/navigating_pry.rb
lib/pry/default_commands/editing.rb
lib/pry/default_commands/ls.rb
lib/pry/default_commands/input_and_output.rb
lib/pry/default_commands/context.rb
lib/pry/default_commands/hist.rb
lib/pry/default_commands/find_method.rb
lib/pry/default_commands/whereami.rb
lib/pry/default_commands/gist.rb
lib/pry/default_commands/cd.rb
lib/pry/default_commands/easter_eggs.rb

Methods

Included Modules

Helpers::DocumentationHelpers Helpers::DocumentationHelpers

Classes and Modules

Module Pry::DefaultCommands::ModuleIntrospectionHelpers

Constants

Introspection = Pry::CommandSet.new do create_command "show-doc", "Show the documentation for a method or class. Aliases: \?", :shellwords => false do include ModuleIntrospectionHelpers
Gems = Pry::CommandSet.new do create_command "gem-install", "Install a gem and refresh the gem cache.", :argument_required => true do |gem| banner <<-BANNER Usage: gem-install GEM_NAME Installs the given gem and refreshes the gem cache so that you can immediately 'require GEM_FILE' BANNER
Misc = Pry::CommandSet.new do command "toggle-color", "Toggle syntax highlighting." do Pry.color = !Pry.color
Help = Pry::CommandSet.new do create_command "help" do |cmd| description "Show a list of commands. Type `help <foo>` for information about <foo>."
Commands = Pry::CommandSet.new do create_command "import-set", "Import a command set" do group "Commands"
NavigatingPry = Pry::CommandSet.new do command "switch-to", "Start a new sub-session on a binding in the current stack (numbered by nesting)." do |selection| selection = selection.to_i
Editing = Pry::CommandSet.new do import Hist
Ls = Pry::CommandSet.new do create_command "ls","Show the list of vars and methods in the current scope.", :shellwords => false, :interpolate => false do group "Context"
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)   ruby.runpaint.org/globals, and running "puts global_variables.inspect".
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)   $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.
InputAndOutput = Pry::CommandSet.new do import Gist
Context = Pry::CommandSet.new do import Ls
Hist = Pry::CommandSet.new do create_command "hist", "Show and replay Readline history. Aliases: history" do group "Editing"
FindMethod = Pry::CommandSet.new do create_command "find-method" do extend Helpers::BaseHelpers
Whereami = Pry::CommandSet.new do create_command "whereami" do description "Show code surrounding the current context."
Gist = Pry::CommandSet.new do create_command "gist", "Gist a method or expression history to GitHub.", :requires_gem => "jist" do include Pry::Helpers::DocumentationHelpers
Cd = Pry::CommandSet.new do create_command "cd" do group "Context"
EasterEggs = Pry::CommandSet.new do command "nyan-cat", "", :requires_gem => ["nyancat"] do run ".nyancat"

Attributes

content  [RW] 
filename  [RW] 

Public Instance methods

Get all the methods that we‘ll want to output

Get a lambda that can be used with .take_while to prevent over-eager traversal of the Object‘s ancestry graph.

Color output based on config.ls.*_color

Get a hash of available commands grouped by the "group" name.

Copy a string to the clipboard.

@param [String] content

@copyright Copyright (c) 2008 Chris Wanstrath (MIT) @see github.com/defunkt/gist/blob/master/lib/gist.rb#L178

Update the definition line so that it can be eval‘d directly on the Method‘s owner instead of from the original context.

In particular this takes `def self.foo` and turns it into `def foo` so that we don‘t end up creating the method on the singleton class of the singleton class by accident.

This is necessarily done by String manipulation because we can‘t find out what syntax is needed for the argument list by ruby-level introspection.

@param String The original definition line. e.g. def self.foo(bar, baz=1) @return String The new definition line. e.g. def foo(bar, baz=1)

Display help for an individual command.

@param [Pry::Command]

Display the index view, with headings and short descriptions per command.

@param Hash[String => Array[Commands]]

Display help for an individual command or group.

@param String The string to search for.

Format and colourise a list of methods.

Clean search terms to make it easier to search group names

@param String @return String

The original name of the method, if it‘s not present raise an error telling the user why we don‘t work.

Add a new section to the output. Outputs nothing if the section would be empty.

copy content to clipboard instead (only used with —clip flag)

When removing jruby aliases, we want to keep the alias that is "least rubbish" according to this metric.

Find a subset of a hash that matches the user‘s search term.

If there‘s an exact match a Hash of one element will be returned, otherwise a sub-Hash with every key that matches the search will be returned.

@param [String] the search term @param [Hash] the hash to search

JRuby creates lots of aliases for methods imported from java in an attempt to make life easier for ruby programmers. (e.g. getFooBar becomes get_foo_bar and foo_bar, and maybe foo_bar? if it returns a Boolean). The full transformations are in the assignAliases method of:

  https://github.com/jruby/jruby/blob/master/src/org/jruby/javasupport/JavaClass.java

This has the unfortunate side-effect of making the output of ls even more incredibly verbose than it normally would be for these objects; and so we filter out all but the nicest of these aliases here.

TODO: This is a little bit vague, better heuristics could be used.

      JRuby also has a lot of scala-specific logic, which we don't copy.

We only want to show commands that have descriptions, so that the easter eggs don‘t show up.

[Validate]