Class: Pry::Config

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/pry/config.rb

Instance Attribute Summary (collapse)

Instance Attribute Details

- (Boolean) auto_indent

Returns Whether or not code should be indented using Pry::Indent.

Returns:

  • (Boolean)

    Whether or not code should be indented using Pry::Indent.



212
213
214
# File 'lib/pry/config.rb', line 212

def auto_indent
  @auto_indent
end

- (Boolean) collision_warning

Returns Whether or not a warning will be displayed when a command name collides with a method/local in the current context.

Returns:

  • (Boolean)

    Whether or not a warning will be displayed when a command name collides with a method/local in the current context.



220
221
222
# File 'lib/pry/config.rb', line 220

def collision_warning
  @collision_warning
end

- (Boolean) color

Returns Toggle Pry color on and off.

Returns:

  • (Boolean)

    Toggle Pry color on and off.



147
148
149
# File 'lib/pry/config.rb', line 147

def color
  @color
end

- (String) command_prefix

A string that must precede all Pry commands (e.g., if command_prefix is set to "%", the "cd" command must be invoked as "%cd").

Returns:

  • (String)


144
145
146
# File 'lib/pry/config.rb', line 144

def command_prefix
  @command_prefix
end

- (Pry::CommandBase) commands

Get/Set the object to use for commands by default by all Pry instances.

Examples:

Pry.config.commands = Pry::CommandSet.new do
            import_from Pry::Commands, "ls"

              command "greet" do |name|
              output.puts "hello #{name}"
            end
          end

Returns:

  • (Pry::CommandBase)

    The object to use for commands by default by all Pry instances.



37
38
39
# File 'lib/pry/config.rb', line 37

def commands
  @commands
end

- (#build_completion_proc) completer

Returns A completer to use.

Returns:

  • (#build_completion_proc)

    A completer to use.



241
242
243
# File 'lib/pry/config.rb', line 241

def completer
  @completer
end

- (Proc) control_d_handler

Returns The proc that manages ^D presses in the REPL. The proc is passed the current eval_string and the current pry instance.

Returns:

  • (Proc)

    The proc that manages ^D presses in the REPL. The proc is passed the current eval_string and the current pry instance.



203
204
205
# File 'lib/pry/config.rb', line 203

def control_d_handler
  @control_d_handler
end

- (Boolean) correct_indent

Returns Whether or not indentation should be corrected after hitting enter. This feature is not supported by all terminals.

Returns:

  • (Boolean)

    Whether or not indentation should be corrected after hitting enter. This feature is not supported by all terminals.



216
217
218
# File 'lib/pry/config.rb', line 216

def correct_indent
  @correct_indent
end

- (Fixnum) default_window_size

Returns The number of lines of context to show before and after exceptions, etc.

Examples:

Pry.config.default_window_size = 10

Returns:

  • (Fixnum)

    The number of lines of context to show before and after exceptions, etc.



75
76
77
# File 'lib/pry/config.rb', line 75

def default_window_size
  @default_window_size
end

- (Boolean) disable_auto_reload

Determines whether to disable edit-method's auto-reloading behavior.

Returns:

  • (Boolean)


170
171
172
# File 'lib/pry/config.rb', line 170

def disable_auto_reload
  @disable_auto_reload
end

- (String, #call) editor

The default editor to use. Defaults to $VISUAL, $EDITOR, or a sensible fallback for the platform. If editor is a String then that string is used as the shell command to invoke the editor. If editor is callable (e.g a Proc) then file, line, and reloading are passed in as parameters and the return value of that callable invocation is used as the exact shell command to invoke the editor. reloading indicates whether Pry will be reloading code after the shell command returns. Any or all of these parameters can be omitted from the callable's signature.

Examples:

String

Pry.config.editor = "emacsclient"

Callable

Pry.config.editor = proc { |file, line| "emacsclient #{file} +#{line}" }

Callable waiting only if reloading

Pry.config.editor = proc { |file, line, reloading| "subl #{'--wait' if reloading} #{file}:#{line}" }

Returns:

  • (String, #call)


139
140
141
# File 'lib/pry/config.rb', line 139

def editor
  @editor
end

- (Proc) exception_handler

Pry.config.exception_handler is an option determining the exception handler object - the Proc responsible for dealing with exceptions raised by user input to the REPL. Three parameters are passed to the exception handler Proc: these are (1) the output object for the current session, (2) the exception object that was raised inside the Pry session, and (3) a reference to the associated Pry instance.

Examples:

Pry.config.exception_handler = proc do |output, exception, _|
  output.puts "#{exception.class}: #{exception.message}"
  output.puts "from #{exception.backtrace.first}"
end

Returns:

  • (Proc)

    The Proc to use for printing exceptions by default by all Pry instances.



64
65
66
# File 'lib/pry/config.rb', line 64

def exception_handler
  @exception_handler
end

- (Array) exception_whitelist

Returns The classes of exception that will not be caught by Pry.

Examples:

Pry.config.exception_whitelist = [SystemExit, SignalException]

Returns:

  • (Array)

    The classes of exception that will not be caught by Pry.



69
70
71
# File 'lib/pry/config.rb', line 69

def exception_whitelist
  @exception_whitelist
end

- (Hash) extra_sticky_locals

Returns Additional sticky locals (to the standard ones) to use in Pry sessions.

Examples:

Inject random_number sticky local into Pry session

Pry.config.extra_sticky_locals = { :random_number => proc {
rand(10) } }

Returns:

  • (Hash)

    Additional sticky locals (to the standard ones) to use in Pry sessions.



238
239
240
# File 'lib/pry/config.rb', line 238

def extra_sticky_locals
  @extra_sticky_locals
end

- (OpenStruct) gist

Config option for gist. sub-options include gist.inspecter, gist.inspecter is a callable that defines how the expression output will be displayed when using the gist -i command.

Examples:

Pretty inspect output

Pry.config.gist.inspecter = proc { |v| v.pretty_inspect }

Regular inspect

Pry.config.gist.inspecter = proc &:inspect

Returns:

  • (OpenStruct)


232
233
234
# File 'lib/pry/config.rb', line 232

def gist
  @gist
end

- (OpenStruct) history

Config option for history. sub-options include history.file, history.load, and history.save history.file is the file to save/load history to, e.g Pry.config.history.file = "~/.pry_history". history.should_load is a boolean that determines whether history will be loaded from history.file at session start. history.should_save is a boolean that determines whether history will be saved to history.file at session end.

Returns:

  • (OpenStruct)


187
188
189
# File 'lib/pry/config.rb', line 187

def history
  @history
end

- (Pry::Hooks) hooks

Get/Set the Pry::Hooks instance that defines Pry hooks used by default by all Pry instances.

Examples:

Pry.config.hooks = Pry::Hooks.new.add_hook(:before_session,
:default) {  |output, target, _pry_| output.puts "Good morning!" }

Returns:

  • (Pry::Hooks)

    The hooks used by default by all Pry instances.



83
84
85
# File 'lib/pry/config.rb', line 83

def hooks
  @hooks
end

- (#readline) input

Get/Set the object to use for input by default by all Pry instances. Pry.config.input is an option determining the input object - the object from which Pry retrieves its lines of input. Pry accepts any object that implements the readline method. This includes IO objects, StringIO, Readline, File and custom objects.

Examples:

Pry.config.input = StringIO.new("@x = 10\nexit")

Returns:

  • (#readline)

    The object to use for input by default by all Pry instances.



14
15
16
# File 'lib/pry/config.rb', line 14

def input
  @input
end

- (Array) input_stack

Get/Set the stack of input objects that a Pry instance switches to when its current input object encounters EOF.

Examples:

Pry.config.input_stack = [StringIO.new("puts 'hello world'\nexit")]

Returns:

  • (Array)

    The array of input objects.



102
103
104
# File 'lib/pry/config.rb', line 102

def input_stack
  @input_stack
end

- (Integer) memory_size

Returns Amount of results that will be stored into out

Returns:

  • (Integer)

    Amount of results that will be stored into out



199
200
201
# File 'lib/pry/config.rb', line 199

def memory_size
  @memory_size
end

- (#puts) output

Get/Set the object to use for output by default by all Pry instances. Pry.config.output is an option determining the output object - the object to which Pry writes its output. Pry accepts any object that implements the puts method. This includes IO objects, StringIO, File and custom objects.

Examples:

Pry.config.output = StringIO.new

Returns:

  • (#puts)

    The object to use for output by default by all Pry instances.



24
25
26
# File 'lib/pry/config.rb', line 24

def output
  @output
end

- (Boolean) pager

Returns Toggle paging on and off.

Returns:

  • (Boolean)

    Toggle paging on and off.



150
151
152
# File 'lib/pry/config.rb', line 150

def pager
  @pager
end

- (OpenStruct) plugins

Config option for plugins: sub-options include: plugins.strict_loading (Boolean) which toggles whether referring to a non-existent plugin should raise an exception (defaults to false)

Returns:

  • (OpenStruct)


193
194
195
# File 'lib/pry/config.rb', line 193

def plugins
  @plugins
end

Get/Set the Proc to use for printing by default by all Pry instances. Two parameters are passed to the print Proc: these are (1) the output object for the current session and (2) the expression value to print. It is important that you write to the output object instead of just stdout so that all Pry output can be redirected if necessary. This is the 'print' component of the REPL.

Examples:

Pry.config.print = proc { |output, value| output.puts "=> #{value.inspect}" }

Returns:

  • (Proc)

    The Proc to use for printing by default by all Pry instances.



49
50
51
# File 'lib/pry/config.rb', line 49

def print
  @print
end

- (Array<Proc>, Proc) prompt

Get the array of Procs (or single Proc) to be used for the prompts by default by all Pry instances. Three parameters are passed into the prompt procs, (1) the object that is the target of the session, (2) the current nesting level, and (3) a reference to the associated Pry instance. These objects can be used in the prompt, if desired.

Examples:

Pry.config.prompt = proc { |obj, nest_level, _pry_| "#{obj}:#{nest_level}> " }

Returns:

  • (Array<Proc>, Proc)

    The array of Procs to be used for the prompts by default by all Pry instances.



113
114
115
# File 'lib/pry/config.rb', line 113

def prompt
  @prompt
end

- (String) prompt_name

The display name that is part of the prompt. Default is 'pry'. You can set your own name so you can identify which project your current pry session is using. This is useful if you have a local pryrc file in a Rails project for example.

Examples:

Pry.config.prompt_name = 'my_rails_project'

Returns:

  • (String)


121
122
123
# File 'lib/pry/config.rb', line 121

def prompt_name
  @prompt_name
end

- (Array<String>) requires

Returns Ruby files to be required after loading any plugins.

Returns:

  • (Array<String>)

    Ruby files to be required after loading any plugins.



196
197
198
# File 'lib/pry/config.rb', line 196

def requires
  @requires
end

- (Boolean) should_load_local_rc

Determines whether the local rc file (./.pryrc) should be loaded.

Returns:

  • (Boolean)


158
159
160
# File 'lib/pry/config.rb', line 158

def should_load_local_rc
  @should_load_local_rc
end

- (Boolean) should_load_plugins

Determines whether plugins should be loaded.

Returns:

  • (Boolean)


162
163
164
# File 'lib/pry/config.rb', line 162

def should_load_plugins
  @should_load_plugins
end

- (Boolean) should_load_rc

Determines whether the rc file (~/.pryrc) should be loaded.

Returns:

  • (Boolean)


154
155
156
# File 'lib/pry/config.rb', line 154

def should_load_rc
  @should_load_rc
end

- (Boolean) should_load_requires

Determines whether to load files specified with the -r flag.

Returns:

  • (Boolean)


166
167
168
# File 'lib/pry/config.rb', line 166

def should_load_requires
  @should_load_requires
end

- (Boolean) should_trap_interrupts

Determines whether Pry should trap SIGINT and cause it to raise an Interrupt exception. This is only useful on jruby, MRI does this for us.

Returns:

  • (Boolean)


176
177
178
# File 'lib/pry/config.rb', line 176

def should_trap_interrupts
  @should_trap_interrupts
end

- (Proc) system

Returns The proc that runs system commands The proc is passed the pry output object, the command string to eval, and a reference to the pry instance

Returns:

  • (Proc)

    The proc that runs system commands The proc is passed the pry output object, the command string to eval, and a reference to the pry instance



208
209
210
# File 'lib/pry/config.rb', line 208

def system
  @system
end