Class: Pry::Config Private

Inherits:
Object show all
Extended by:
Attributable
Defined in:
lib/pry/config.rb,
lib/pry/config/value.rb,
lib/pry/config/lazy_value.rb,
lib/pry/config/attributable.rb,
lib/pry/config/memoized_value.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Modules: Attributable Classes: LazyValue, MemoizedValue, Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributable

attribute

Constructor Details

#initializeConfig

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Config.



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/pry/config.rb', line 154

def initialize
  merge!(
    input: MemoizedValue.new { lazy_readline },
    output: $stdout.tap { |out| out.sync = true },
    commands: Pry::Commands,
    prompt_name: 'pry',
    prompt: Pry::Prompt[:default],
    prompt_safe_contexts: [String, Numeric, Symbol, nil, true, false],
    print: Pry::ColorPrinter.method(:default),
    quiet: false,
    exception_handler: Pry::ExceptionHandler.method(:handle_exception),

    unrescued_exceptions: [
      ::SystemExit, ::SignalException, Pry::TooSafeException
    ],

    exception_whitelist: MemoizedValue.new do
      output.puts(
        '[warning] Pry.config.exception_whitelist is deprecated, ' \
        'please use Pry.config.unrescued_exceptions instead.'
      )
      unrescued_exceptions
    end,

    hooks: Pry::Hooks.default,
    pager: true,
    system: Pry::SystemCommandHandler.method(:default),
    color: Pry::Helpers::BaseHelpers.use_ansi_codes?,
    default_window_size: 5,
    editor: Pry::Editor.default,
    rc_file: default_rc_file,
    should_load_rc: true,
    should_load_local_rc: true,
    should_trap_interrupts: Pry::Helpers::Platform.jruby?,
    disable_auto_reload: false,
    command_prefix: '',
    auto_indent: Pry::Helpers::BaseHelpers.use_ansi_codes?,
    correct_indent: true,
    collision_warning: false,
    output_prefix: '=> ',
    requires: [],
    should_load_requires: true,
    windows_console_warning: true,
    control_d_handler: Pry::ControlDHandler.method(:default),
    memory_size: 100,
    extra_sticky_locals: {},
    command_completions: proc { commands.keys },
    file_completions: proc { Dir['.'] },
    ls: OpenStruct.new(Pry::Command::Ls::DEFAULT_OPTIONS),
    completer: Pry::InputCompleter,
    history_save: true,
    history_load: true,
    history_file: Pry::History.default_file,
    history_ignorelist: [],
    history: MemoizedValue.new do
      if defined?(input::HISTORY)
        Pry::History.new(history: input::HISTORY)
      else
        Pry::History.new
      end
    end,
    exec_string: ''
  )

  @custom_attrs = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &_block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Style/MethodMissingSuper



239
240
241
242
243
244
245
246
247
# File 'lib/pry/config.rb', line 239

def method_missing(method_name, *args, &_block)
  name = method_name.to_s

  if name.end_with?('=')
    self[name[0..-2]] = args.first
  elsif @custom_attrs.key?(name)
    self[name]
  end
end

Instance Attribute Details

#control_d_handlerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



259
260
261
# File 'lib/pry/config.rb', line 259

def control_d_handler
  @control_d_handler
end

Instance Method Details

#[](attr) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



234
235
236
# File 'lib/pry/config.rb', line 234

def [](attr)
  @custom_attrs[attr.to_s].call
end

#[]=(attr, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



230
231
232
# File 'lib/pry/config.rb', line 230

def []=(attr, value)
  @custom_attrs[attr.to_s] = Config::Value.new(value)
end

#auto_indentBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


112
# File 'lib/pry/config.rb', line 112

attribute :auto_indent

#collision_warningBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether or not display a warning when a command name collides with a method/local in the current context.

Returns:

  • (Boolean)

    whether or not display a warning when a command name collides with a method/local in the current context.



119
# File 'lib/pry/config.rb', line 119

attribute :collision_warning

#colorBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


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

attribute :color

#command_completionsProc

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Proc)


135
# File 'lib/pry/config.rb', line 135

attribute :command_completions

#command_prefixString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A string that must precede all commands. For example, if is is set to “%”, the “cd” command must be invoked as “%cd”).

Returns:

  • (String)


62
# File 'lib/pry/config.rb', line 62

attribute :command_prefix

#commandsPry::CommandSet

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



18
# File 'lib/pry/config.rb', line 18

attribute :commands

#completer#build_completion_proc

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a completer to use.

Returns:

  • (#build_completion_proc)

    a completer to use



125
# File 'lib/pry/config.rb', line 125

attribute :completer

#correct_indentBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


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

attribute :correct_indent

#default_window_sizeInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Returns:

  • (Integer)

    The number of lines of context to show before and after exceptions



35
# File 'lib/pry/config.rb', line 35

attribute :default_window_size

#disable_auto_reloadBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether to disable edit-method’s auto-reloading behavior.

Returns:

  • (Boolean)

    whether to disable edit-method’s auto-reloading behavior



80
# File 'lib/pry/config.rb', line 80

attribute :disable_auto_reload

#editorString, #call

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

If it is a String, then that String is used as the shell command to invoke the editor.

If it responds to #call is callable then ‘file`, `line`, and `reloading` are passed to it. `reloading` indicates whether Pry will be reloading code after the shell command returns. All parameters are optional.

Returns:

  • (String, #call)


57
# File 'lib/pry/config.rb', line 57

attribute :editor

#exception_handlerProc

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the printer for exceptions.

Returns:

  • (Proc)

    the printer for exceptions



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

attribute :exception_handler

#exception_whitelistArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.

Returns Exception that Pry shouldn’t rescue.

Returns:

  • (Array)

    Exception that Pry shouldn’t rescue



31
# File 'lib/pry/config.rb', line 31

attribute :exception_whitelist

#exec_stringString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a line of code to execute in context before the session starts.

Returns:

  • (String)

    a line of code to execute in context before the session starts



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

attribute :exec_string

#extra_sticky_localsHash{Symbol=>Proc}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash{Symbol=>Proc})


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

attribute :extra_sticky_locals

#file_completionsProc

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Proc)


138
# File 'lib/pry/config.rb', line 138

attribute :file_completions

#historyPry::History

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



88
# File 'lib/pry/config.rb', line 88

attribute :history

#history_fileString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


97
# File 'lib/pry/config.rb', line 97

attribute :history_file

#history_ignorelistArray<String,Regexp>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array<String,Regexp>)


100
# File 'lib/pry/config.rb', line 100

attribute :history_ignorelist

#history_loadBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


94
# File 'lib/pry/config.rb', line 94

attribute :history_load

#history_saveBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


91
# File 'lib/pry/config.rb', line 91

attribute :history_save

#hooksPry::Hooks

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



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

attribute :hooks

#initialize_dup(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



254
255
256
257
# File 'lib/pry/config.rb', line 254

def initialize_dup(other)
  super
  @custom_attrs = @custom_attrs.dup
end

#inputIO, #readline

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns he object from which Pry retrieves its lines of input.

Returns:

  • (IO, #readline)

    he object from which Pry retrieves its lines of input



12
# File 'lib/pry/config.rb', line 12

attribute :input

#lsHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash)


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

attribute :ls

#memory_sizeInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns how many input/output lines to keep in memory.

Returns:

  • (Integer)

    how many input/output lines to keep in memory



106
# File 'lib/pry/config.rb', line 106

attribute :memory_size

#merge(config_hash) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



226
227
228
# File 'lib/pry/config.rb', line 226

def merge(config_hash)
  dup.merge!(config_hash)
end

#merge!(config_hash) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def merge!(config_hash)
  config_hash.each_pair { |attr, value| __send__("#{attr}=", value) }
  self
end

#outputIO, #puts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns where Pry should output results provided by #input.

Returns:

  • (IO, #puts)

    where Pry should output results provided by #input



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

attribute :output

#output_prefixString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


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

attribute :output_prefix

#pagerBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


68
# File 'lib/pry/config.rb', line 68

attribute :pager

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the printer for Ruby expressions (not commands).

Returns:

  • (Proc)

    the printer for Ruby expressions (not commands)



21
# File 'lib/pry/config.rb', line 21

attribute :print

#promptPry::Prompt

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



41
# File 'lib/pry/config.rb', line 41

attribute :prompt

#prompt_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The display name that is part of the prompt.

Returns:

  • (String)

    The display name that is part of the prompt



44
# File 'lib/pry/config.rb', line 44

attribute :prompt_name

#prompt_safe_contextsArray<Object>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the list of objects that are known to have a 1-line #inspect output suitable for prompt.

Returns:

  • (Array<Object>)

    the list of objects that are known to have a 1-line #inspect output suitable for prompt



48
# File 'lib/pry/config.rb', line 48

attribute :prompt_safe_contexts

#quietBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns suppresses whereami output on ‘binding.pry`.

Returns:

  • (Boolean)

    suppresses whereami output on ‘binding.pry`



128
# File 'lib/pry/config.rb', line 128

attribute :quiet

#rc_fileString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)

Since:

  • v0.13.0



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

attribute :rc_file

#requiresArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Ruby files to be required.

Returns:

  • (Array<String>)

    Ruby files to be required



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

attribute :requires

#respond_to_missing?(method_name, include_all = false) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:enable Style/MethodMissingSuper

Returns:

  • (Boolean)


250
251
252
# File 'lib/pry/config.rb', line 250

def respond_to_missing?(method_name, include_all = false)
  @custom_attrs.key?(method_name.to_s.tr('=', '')) || super
end

#should_load_local_rcBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether the local ./.pryrc should be loaded.

Returns:

  • (Boolean)

    whether the local ./.pryrc should be loaded



74
# File 'lib/pry/config.rb', line 74

attribute :should_load_local_rc

#should_load_rcBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether the global ~/.pryrc should be loaded.

Returns:

  • (Boolean)

    whether the global ~/.pryrc should be loaded



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

attribute :should_load_rc

#should_load_requiresBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Returns:

  • (Boolean)

    whether to load files specified with the -r flag



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

attribute :should_load_requires

#should_trap_interruptsBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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)


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

attribute :should_trap_interrupts

#systemProc

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The proc that runs system commands.

Returns:

  • (Proc)

    The proc that runs system commands



109
# File 'lib/pry/config.rb', line 109

attribute :system

#unrescued_exceptionsArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Exception that Pry shouldn’t rescue.

Returns:

  • (Array)

    Exception that Pry shouldn’t rescue



27
# File 'lib/pry/config.rb', line 27

attribute :unrescued_exceptions

#windows_console_warningBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns displays a warning about experience improvement on Windows.

Returns:

  • (Boolean)

    displays a warning about experience improvement on Windows



132
# File 'lib/pry/config.rb', line 132

attribute :windows_console_warning