pry 0.10.3 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +251 -16
  3. data/LICENSE +1 -1
  4. data/README.md +35 -51
  5. data/bin/pry +3 -11
  6. data/lib/pry/basic_object.rb +6 -0
  7. data/lib/pry/cli.rb +50 -52
  8. data/lib/pry/code/code_file.rb +13 -6
  9. data/lib/pry/code/code_range.rb +3 -3
  10. data/lib/pry/code/loc.rb +14 -8
  11. data/lib/pry/code.rb +12 -5
  12. data/lib/pry/code_object.rb +27 -4
  13. data/lib/pry/color_printer.rb +20 -10
  14. data/lib/pry/command.rb +76 -45
  15. data/lib/pry/command_set.rb +17 -45
  16. data/lib/pry/commands/amend_line.rb +3 -4
  17. data/lib/pry/commands/bang.rb +1 -1
  18. data/lib/pry/commands/cat/exception_formatter.rb +10 -8
  19. data/lib/pry/commands/cat/file_formatter.rb +7 -3
  20. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  21. data/lib/pry/commands/cat.rb +7 -6
  22. data/lib/pry/commands/change_prompt.rb +29 -9
  23. data/lib/pry/commands/clear_screen.rb +14 -0
  24. data/lib/pry/commands/code_collector.rb +25 -23
  25. data/lib/pry/commands/easter_eggs.rb +12 -12
  26. data/lib/pry/commands/edit/file_and_line_locator.rb +1 -1
  27. data/lib/pry/commands/edit.rb +15 -10
  28. data/lib/pry/commands/exit.rb +2 -1
  29. data/lib/pry/commands/find_method.rb +12 -14
  30. data/lib/pry/commands/gem_cd.rb +1 -1
  31. data/lib/pry/commands/gem_install.rb +2 -2
  32. data/lib/pry/commands/gem_list.rb +2 -2
  33. data/lib/pry/commands/gem_open.rb +2 -2
  34. data/lib/pry/commands/gem_readme.rb +25 -0
  35. data/lib/pry/commands/gem_search.rb +40 -0
  36. data/lib/pry/commands/gem_stats.rb +83 -0
  37. data/lib/pry/commands/gist.rb +7 -6
  38. data/lib/pry/commands/help.rb +3 -3
  39. data/lib/pry/commands/hist.rb +11 -10
  40. data/lib/pry/commands/import_set.rb +2 -1
  41. data/lib/pry/commands/install_command.rb +7 -6
  42. data/lib/pry/commands/jump_to.rb +7 -7
  43. data/lib/pry/commands/list_inspectors.rb +2 -2
  44. data/lib/pry/commands/ls/constants.rb +14 -3
  45. data/lib/pry/commands/ls/formatter.rb +4 -2
  46. data/lib/pry/commands/ls/globals.rb +0 -2
  47. data/lib/pry/commands/ls/grep.rb +0 -2
  48. data/lib/pry/commands/ls/instance_vars.rb +0 -1
  49. data/lib/pry/commands/ls/jruby_hacks.rb +2 -2
  50. data/lib/pry/commands/ls/local_names.rb +0 -2
  51. data/lib/pry/commands/ls/local_vars.rb +0 -2
  52. data/lib/pry/commands/ls/ls_entity.rb +0 -1
  53. data/lib/pry/commands/ls/methods.rb +0 -3
  54. data/lib/pry/commands/ls/methods_helper.rb +1 -1
  55. data/lib/pry/commands/ls/self_methods.rb +2 -1
  56. data/lib/pry/commands/ls.rb +30 -31
  57. data/lib/pry/commands/play.rb +3 -4
  58. data/lib/pry/commands/pry_backtrace.rb +1 -1
  59. data/lib/pry/commands/raise_up.rb +2 -1
  60. data/lib/pry/commands/reload_code.rb +2 -2
  61. data/lib/pry/commands/ri.rb +9 -4
  62. data/lib/pry/commands/shell_command.rb +36 -9
  63. data/lib/pry/commands/shell_mode.rb +6 -6
  64. data/lib/pry/commands/show_doc.rb +5 -7
  65. data/lib/pry/commands/show_info.rb +41 -20
  66. data/lib/pry/commands/show_source.rb +5 -2
  67. data/lib/pry/commands/stat.rb +1 -1
  68. data/lib/pry/commands/watch_expression/expression.rb +1 -1
  69. data/lib/pry/commands/watch_expression.rb +9 -7
  70. data/lib/pry/commands/whereami.rb +16 -9
  71. data/lib/pry/commands/wtf.rb +15 -2
  72. data/lib/pry/config/behavior.rb +230 -114
  73. data/lib/pry/config/convenience.rb +24 -21
  74. data/lib/pry/config/default.rb +151 -153
  75. data/lib/pry/config/memoization.rb +48 -0
  76. data/lib/pry/config.rb +30 -19
  77. data/lib/pry/core_extensions.rb +15 -4
  78. data/lib/pry/editor.rb +5 -12
  79. data/lib/pry/exceptions.rb +1 -3
  80. data/lib/pry/forwardable.rb +23 -0
  81. data/lib/pry/helpers/base_helpers.rb +197 -110
  82. data/lib/pry/helpers/command_helpers.rb +5 -4
  83. data/lib/pry/helpers/documentation_helpers.rb +3 -2
  84. data/lib/pry/helpers/options_helpers.rb +6 -6
  85. data/lib/pry/helpers/platform.rb +58 -0
  86. data/lib/pry/helpers/table.rb +20 -15
  87. data/lib/pry/helpers/text.rb +82 -74
  88. data/lib/pry/helpers.rb +1 -0
  89. data/lib/pry/history.rb +44 -10
  90. data/lib/pry/hooks.rb +50 -109
  91. data/lib/pry/indent.rb +21 -19
  92. data/lib/pry/input_completer.rb +146 -123
  93. data/lib/pry/input_lock.rb +0 -2
  94. data/lib/pry/last_exception.rb +2 -2
  95. data/lib/pry/method/disowned.rb +3 -1
  96. data/lib/pry/method/patcher.rb +2 -5
  97. data/lib/pry/method/weird_method_locator.rb +21 -11
  98. data/lib/pry/method.rb +44 -38
  99. data/lib/pry/object_path.rb +5 -4
  100. data/lib/pry/output.rb +37 -37
  101. data/lib/pry/pager.rb +195 -181
  102. data/lib/pry/platform.rb +91 -0
  103. data/lib/pry/plugins.rb +27 -8
  104. data/lib/pry/prompt.rb +144 -25
  105. data/lib/pry/pry_class.rb +83 -33
  106. data/lib/pry/pry_instance.rb +94 -59
  107. data/lib/pry/repl.rb +70 -11
  108. data/lib/pry/repl_file_loader.rb +2 -3
  109. data/lib/pry/ring.rb +84 -0
  110. data/lib/pry/rubygem.rb +9 -7
  111. data/lib/pry/slop/LICENSE +20 -0
  112. data/lib/pry/slop/commands.rb +195 -0
  113. data/lib/pry/slop/option.rb +206 -0
  114. data/lib/pry/slop.rb +661 -0
  115. data/lib/pry/terminal.rb +18 -6
  116. data/lib/pry/testable/evalable.rb +15 -0
  117. data/lib/pry/testable/mockable.rb +14 -0
  118. data/lib/pry/testable/pry_tester.rb +73 -0
  119. data/lib/pry/testable/utility.rb +26 -0
  120. data/lib/pry/testable/variables.rb +46 -0
  121. data/lib/pry/testable.rb +70 -0
  122. data/lib/pry/version.rb +1 -1
  123. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +9 -14
  124. data/lib/pry/wrapped_module.rb +22 -21
  125. data/lib/pry.rb +21 -50
  126. metadata +35 -46
  127. data/lib/pry/commands/list_prompts.rb +0 -35
  128. data/lib/pry/commands/simple_prompt.rb +0 -22
  129. data/lib/pry/history_array.rb +0 -121
  130. data/lib/pry/rbx_path.rb +0 -22
  131. data/lib/pry/test/helper.rb +0 -170
data/lib/pry/prompt.rb CHANGED
@@ -1,26 +1,145 @@
1
- class Pry::Prompt
2
- MAP = {
3
- "default" => {
4
- value: Pry::DEFAULT_PROMPT,
5
- description: "The default Pry prompt. Includes information about the\n" \
6
- "current expression number, evaluation context, and nesting\n" \
7
- "level, plus a reminder that you're using Pry."
8
- },
9
-
10
- "simple" => {
11
- value: Pry::SIMPLE_PROMPT,
12
- description: "A simple '>>'."
13
- },
14
-
15
- "nav" => {
16
- value: Pry::NAV_PROMPT,
17
- description: "A prompt that displays the binding stack as a path and\n" \
18
- "includes information about _in_ and _out_."
19
- },
20
-
21
- "none" => {
22
- value: Pry::NO_PROMPT,
23
- description: "Wave goodbye to the Pry prompt."
24
- }
25
- }
1
+ class Pry
2
+ # Prompt represents the Pry prompt, which can be used with Readline-like
3
+ # libraries. It defines a few default prompts (default prompt, simple prompt,
4
+ # etc) and also provides an API to add custom prompts.
5
+ #
6
+ # @example
7
+ # Pry::Prompt.add(
8
+ # :ipython,
9
+ # 'IPython-like prompt', [':', '...:']
10
+ # ) do |_context, _nesting, _pry_, sep|
11
+ # sep == ':' ? "In [#{_pry_.input_ring.count}]: " : ' ...: '
12
+ # end
13
+ #
14
+ # # Produces:
15
+ # # In [3]: def foo
16
+ # # ...: puts 'foo'
17
+ # # ...: end
18
+ # # => :foo
19
+ # # In [4]:
20
+ # @since v0.11.0
21
+ # @api public
22
+ module Prompt
23
+ # @return [String]
24
+ DEFAULT_NAME = 'pry'.freeze
25
+
26
+ # @return [Array<Object>] the list of objects that are known to have a
27
+ # 1-line #inspect output suitable for prompt
28
+ SAFE_CONTEXTS = [String, Numeric, Symbol, nil, true, false].freeze
29
+
30
+ # @deprecated Use {Pry::Prompt.add} instead.
31
+ MAP = {}
32
+ deprecate_constant(:MAP) if respond_to?(:deprecate_constant)
33
+
34
+ # A Hash that holds all prompts. The keys of the Hash are prompt
35
+ # names, the values are Hash instances of the format {:description, :value}.
36
+ @prompts = {}
37
+
38
+ class << self
39
+ # Retrieves a prompt.
40
+ #
41
+ # @example
42
+ # Prompt[:my_prompt][:value]
43
+ #
44
+ # @param [Symbol] prompt_name The name of the prompt you want to access
45
+ # @return [Hash{Symbol=>Object}]
46
+ # @since v0.12.0
47
+ def [](prompt_name)
48
+ @prompts[prompt_name.to_s]
49
+ end
50
+
51
+ # @return [Hash{Symbol=>Hash}] the duplicate of the internal prompts hash
52
+ # @note Use this for read-only operations
53
+ # @since v0.12.0
54
+ def all
55
+ @prompts.dup
56
+ end
57
+
58
+ # Adds a new prompt to the prompt hash.
59
+ #
60
+ # @param [Symbol] prompt_name
61
+ # @param [String] description
62
+ # @param [Array<String>] separators The separators to differentiate
63
+ # between prompt modes (default mode and class/method definition mode).
64
+ # The Array *must* have a size of 2.
65
+ # @yield [context, nesting, _pry_, sep]
66
+ # @yieldparam context [Object] the context where Pry is currently in
67
+ # @yieldparam nesting [Integer] whether the context is nested
68
+ # @yieldparam _pry_ [Pry] the Pry instance
69
+ # @yieldparam separator [String] separator string
70
+ # @return [nil]
71
+ # @raise [ArgumentError] if the size of `separators` is not 2
72
+ # @since v0.12.0
73
+ def add(prompt_name, description = '', separators = %w[> *])
74
+ unless separators.size == 2
75
+ raise ArgumentError, "separators size must be 2, given #{separators.size}"
76
+ end
77
+
78
+ @prompts[prompt_name.to_s] = {
79
+ description: description,
80
+ value: separators.map do |sep|
81
+ proc { |context, nesting, _pry_| yield(context, nesting, _pry_, sep) }
82
+ end
83
+ }
84
+
85
+ nil
86
+ end
87
+
88
+ private
89
+
90
+ def prompt_name(name)
91
+ return name unless name.is_a?(Pry::Config::Lazy)
92
+
93
+ name.call
94
+ end
95
+ end
96
+
97
+ add(:default, <<DESC) do |context, nesting, _pry_, sep|
98
+ The default Pry prompt. Includes information about the current expression
99
+ number, evaluation context, and nesting level, plus a reminder that you're
100
+ using Pry.
101
+ DESC
102
+ format(
103
+ "[%<in_count>s] %<name>s(%<context>s)%<nesting>s%<separator>s ",
104
+ in_count: _pry_.input_ring.count,
105
+ name: prompt_name(_pry_.config.prompt_name),
106
+ context: Pry.view_clip(context),
107
+ nesting: (nesting > 0 ? ":#{nesting}" : ''),
108
+ separator: sep
109
+ )
110
+ end
111
+
112
+ add(:simple, "A simple `>>`.\n", ['>> ', ' | ']) do |_, _, _, sep|
113
+ sep
114
+ end
115
+
116
+ add(:nav, <<DESC, %w[> *]) do |context, nesting, _pry_, sep|
117
+ A prompt that displays the binding stack as a path and includes information
118
+ about #{Helpers::Text.bold('_in_')} and #{Helpers::Text.bold('_out_')}.
119
+ DESC
120
+ tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval('self')) }
121
+ format(
122
+ "[%<in_count>s] (%<name>s) %<tree>s: %<stack_size>s%<separator>s ",
123
+ in_count: _pry_.input_ring.count,
124
+ name: prompt_name(_pry_.config.prompt_name),
125
+ tree: tree.join(' / '),
126
+ stack_size: _pry_.binding_stack.size - 1,
127
+ separator: sep
128
+ )
129
+ end
130
+
131
+ add(:shell, <<DESC, %w[$ *]) do |context, nesting, _pry_, sep|
132
+ A prompt that displays `$PWD` as you change it.
133
+ DESC
134
+ format(
135
+ "%<name>s %<context>s:%<pwd>s %<separator>s ",
136
+ name: prompt_name(_pry_.config.prompt_name),
137
+ context: Pry.view_clip(context),
138
+ pwd: Dir.pwd,
139
+ separator: sep
140
+ )
141
+ end
142
+
143
+ add(:none, 'Wave goodbye to the Pry prompt.', Array.new(2)) { '' }
144
+ end
26
145
  end
data/lib/pry/pry_class.rb CHANGED
@@ -1,11 +1,20 @@
1
- require 'pry/config'
2
1
  class Pry
3
-
4
- HOME_RC_FILE = ENV["PRYRC"] || "~/.pryrc"
2
+ HOME_RC_FILE =
3
+ if ENV.key?('PRYRC')
4
+ ENV['PRYRC']
5
+ elsif File.exist?(File.expand_path('~/.pryrc'))
6
+ '~/.pryrc'
7
+ elsif ENV.key?('XDG_CONFIG_HOME') && ENV['XDG_CONFIG_HOME'] != ''
8
+ # See XDG Base Directory Specification at
9
+ # https://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html
10
+ ENV['XDG_CONFIG_HOME'] + '/pry/pryrc'
11
+ else
12
+ '~/.config/pry/pryrc'
13
+ end
5
14
  LOCAL_RC_FILE = "./.pryrc"
6
15
 
7
16
  class << self
8
- extend Forwardable
17
+ extend Pry::Forwardable
9
18
  attr_accessor :custom_completions
10
19
  attr_accessor :current_line
11
20
  attr_accessor :line_buffer
@@ -32,6 +41,21 @@ class Pry
32
41
  def history
33
42
  @history ||= History.new
34
43
  end
44
+
45
+ #
46
+ # @example
47
+ # Pry.configure do |config|
48
+ # config.eager_load! # optional
49
+ # config.input = # ..
50
+ # config.foo = 2
51
+ # end
52
+ #
53
+ # @yield [config]
54
+ # Yields a block with {Pry.config} as its argument.
55
+ #
56
+ def configure
57
+ yield config
58
+ end
35
59
  end
36
60
 
37
61
  #
@@ -78,10 +102,8 @@ class Pry
78
102
 
79
103
  # Expand a file to its canonical name (following symlinks as appropriate)
80
104
  def self.real_path_to(file)
81
- expanded = Pathname.new(File.expand_path(file)).realpath.to_s
82
- # For rbx 1.9 mode [see rubinius issue #2165]
83
- File.exist?(expanded) ? expanded : nil
84
- rescue Errno::ENOENT
105
+ Pathname.new(File.expand_path(file)).realpath.to_s
106
+ rescue Errno::ENOENT, Errno::EACCES
85
107
  nil
86
108
  end
87
109
 
@@ -95,7 +117,7 @@ class Pry
95
117
  # Trap interrupts on jruby, and make them behave like MRI so we can
96
118
  # catch them.
97
119
  def self.load_traps
98
- trap('INT'){ raise Interrupt }
120
+ trap('INT') { raise Interrupt }
99
121
  end
100
122
 
101
123
  def self.load_win32console
@@ -109,38 +131,47 @@ class Pry
109
131
  For a better Pry experience on Windows, please use ansicon:
110
132
  https://github.com/adoxa/ansicon
111
133
  If you use an alternative to ansicon and don't want to see this warning again,
112
- you can add "Pry.config.windows_console_warning = false" to your .pryrc.
134
+ you can add "Pry.config.windows_console_warning = false" to your pryrc.
113
135
  WARNING
114
136
  end
115
137
  end
116
138
 
117
- # Do basic setup for initial session.
118
- # Including: loading .pryrc, loading plugins, loading requires, and
119
- # loading history.
139
+ # Do basic setup for initial session including: loading pryrc, plugins,
140
+ # requires, and history.
120
141
  def self.initial_session_setup
121
142
  return unless initial_session?
143
+
122
144
  @initial_session = false
123
145
 
124
146
  # note these have to be loaded here rather than in pry_instance as
125
147
  # we only want them loaded once per entire Pry lifetime.
126
148
  load_rc_files
149
+ end
150
+
151
+ def self.final_session_setup
152
+ return if @session_finalized
153
+
154
+ @session_finalized = true
127
155
  load_plugins if Pry.config.should_load_plugins
128
156
  load_requires if Pry.config.should_load_requires
129
157
  load_history if Pry.config.history.should_load
130
158
  load_traps if Pry.config.should_trap_interrupts
131
- load_win32console if Pry::Helpers::BaseHelpers.windows? && !Pry::Helpers::BaseHelpers.windows_ansi?
159
+ load_win32console if Helpers::Platform.windows? && !Helpers::Platform.windows_ansi?
132
160
  end
133
161
 
134
162
  # Start a Pry REPL.
135
- # This method also loads `~/.pryrc` and `./.pryrc` as necessary the
136
- # first time it is invoked.
163
+ # This method also loads `pryrc` as necessary the first time it is invoked.
137
164
  # @param [Object, Binding] target The receiver of the Pry session
138
165
  # @param [Hash] options
139
166
  # @option options (see Pry#initialize)
140
167
  # @example
141
168
  # Pry.start(Object.new, :input => MyInput.new)
142
- def self.start(target=nil, options={})
169
+ def self.start(target = nil, options = {})
143
170
  return if ENV['DISABLE_PRY']
171
+ if ENV['FAIL_PRY']
172
+ raise 'You have FAIL_PRY set to true, which results in Pry calls failing'
173
+ end
174
+
144
175
  options = options.to_hash
145
176
 
146
177
  if in_critical_section?
@@ -150,8 +181,8 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
150
181
  end
151
182
 
152
183
  options[:target] = Pry.binding_for(target || toplevel_binding)
153
- options[:hooks] = Pry::Hooks.from_hash options.delete(:hooks) if options.key?(:hooks)
154
184
  initial_session_setup
185
+ final_session_setup
155
186
 
156
187
  # Unless we were given a backtrace, save the current one
157
188
  if options[:backtrace].nil?
@@ -208,7 +239,7 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
208
239
  # fixed as of https://github.com/jruby/jruby/commit/d365ebd309cf9df3dde28f5eb36ea97056e0c039
209
240
  # we can drop in the future.
210
241
  obj.to_s
211
- elsif Pry.config.prompt_safe_objects.any? { |v| v === obj } && obj.inspect.length <= max
242
+ elsif Pry.config.prompt_safe_contexts.any? { |v| v === obj } && obj.inspect.length <= max
212
243
  obj.inspect
213
244
  else
214
245
  id == true ? "#<#{obj.class}:0x%x>" % (obj.object_id << 1) : "#<#{obj.class}>"
@@ -233,7 +264,7 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
233
264
  # @param [String] command_string The Pry command (including arguments,
234
265
  # if any).
235
266
  # @param [Hash] options Optional named parameters.
236
- # @return [Object] The return value of the Pry command.
267
+ # @return [nil]
237
268
  # @option options [Object, Binding] :target The object to run the
238
269
  # command under. Defaults to `TOPLEVEL_BINDING` (main).
239
270
  # @option options [Boolean] :show_output Whether to show command
@@ -244,31 +275,30 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
244
275
  # Pry.run_command "ls -m", :target => Pry
245
276
  # @example Display command output.
246
277
  # Pry.run_command "ls -av", :show_output => true
247
- def self.run_command(command_string, options={})
278
+ def self.run_command(command_string, options = {})
248
279
  options = {
249
- :target => TOPLEVEL_BINDING,
250
- :show_output => true,
251
- :output => Pry.config.output,
252
- :commands => Pry.config.commands
280
+ target: TOPLEVEL_BINDING,
281
+ show_output: true,
282
+ output: Pry.config.output,
283
+ commands: Pry.config.commands
253
284
  }.merge!(options)
254
285
 
255
286
  # :context for compatibility with <= 0.9.11.4
256
287
  target = options[:context] || options[:target]
257
288
  output = options[:show_output] ? options[:output] : StringIO.new
258
289
 
259
- pry = Pry.new(:output => output, :target => target, :commands => options[:commands])
290
+ pry = Pry.new(output: output, target: target, commands: options[:commands])
260
291
  pry.eval command_string
292
+ nil
261
293
  end
262
294
 
263
295
  def self.default_editor_for_platform
264
296
  return ENV['VISUAL'] if ENV['VISUAL'] and not ENV['VISUAL'].empty?
265
297
  return ENV['EDITOR'] if ENV['EDITOR'] and not ENV['EDITOR'].empty?
266
- if Helpers::BaseHelpers.windows?
267
- 'notepad'
268
- else
269
- %w(editor nano vi).detect do |editor|
270
- system("which #{editor} > /dev/null 2>&1")
271
- end
298
+ return 'notepad' if Helpers::Platform.windows?
299
+
300
+ %w(editor nano vi).detect do |editor|
301
+ system("which #{editor} > /dev/null 2>&1")
272
302
  end
273
303
  end
274
304
 
@@ -306,6 +336,8 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
306
336
  # Set all the configurable options back to their default values
307
337
  def self.reset_defaults
308
338
  @initial_session = true
339
+ @session_finalized = nil
340
+
309
341
  self.config = Pry::Config.new Pry::Config::Default.new
310
342
  self.cli = false
311
343
  self.current_line = 1
@@ -363,13 +395,31 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
363
395
  Thread.current[:pry_critical_section] > 0
364
396
  end
365
397
 
366
- def self.critical_section(&block)
398
+ def self.critical_section
367
399
  Thread.current[:pry_critical_section] ||= 0
368
400
  Thread.current[:pry_critical_section] += 1
369
401
  yield
370
402
  ensure
371
403
  Thread.current[:pry_critical_section] -= 1
372
404
  end
405
+
406
+ # Wraps a block in a named block called `Pry::Config::Lazy`. This is used for
407
+ # dynamic config values, which are calculated every time
408
+ # {Pry::Config::Lazy#call} is called.
409
+ #
410
+ # @example
411
+ # # pryrc
412
+ # Pry.config.prompt_name = Pry.lazy { rand(100) }
413
+ #
414
+ # # Session
415
+ # [1] 96(main)>
416
+ # [2] 19(main)>
417
+ # [3] 80(main)>
418
+ #
419
+ # @return [#call]
420
+ def self.lazy(&block)
421
+ Pry::Config::Lazy.new(&block)
422
+ end
373
423
  end
374
424
 
375
425
  Pry.init