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
@@ -1,161 +1,159 @@
1
- class Pry::Config::Default
2
- include Pry::Config::Behavior
1
+ class Pry
2
+ class Config < Pry::BasicObject
3
+ class Default
4
+ include Config::Behavior
5
+ include Config::Memoization
3
6
 
4
- default = {
5
- input: proc {
6
- lazy_readline
7
- },
8
- output: proc {
9
- $stdout
10
- },
11
- commands: proc {
12
- Pry::Commands
13
- },
14
- prompt_name: proc {
15
- Pry::DEFAULT_PROMPT_NAME
16
- },
17
- prompt: proc {
18
- Pry::DEFAULT_PROMPT
19
- },
20
- prompt_safe_objects: proc {
21
- Pry::DEFAULT_PROMPT_SAFE_OBJECTS
22
- },
23
- print: proc {
24
- Pry::DEFAULT_PRINT
25
- },
26
- quiet: proc {
27
- false
28
- },
29
- exception_handler: proc {
30
- Pry::DEFAULT_EXCEPTION_HANDLER
31
- },
32
- exception_whitelist: proc {
33
- Pry::DEFAULT_EXCEPTION_WHITELIST
34
- },
35
- hooks: proc {
36
- Pry::DEFAULT_HOOKS
37
- },
38
- pager: proc {
39
- true
40
- },
41
- system: proc {
42
- Pry::DEFAULT_SYSTEM
43
- },
44
- color: proc {
45
- Pry::Helpers::BaseHelpers.use_ansi_codes?
46
- },
47
- default_window_size: proc {
48
- 5
49
- },
50
- editor: proc {
51
- Pry.default_editor_for_platform
52
- }, # TODO: Pry::Platform.editor
53
- should_load_rc: proc {
54
- true
55
- },
56
- should_load_local_rc: proc {
57
- true
58
- },
59
- should_trap_interrupts: proc {
60
- Pry::Helpers::BaseHelpers.jruby?
61
- }, # TODO: Pry::Platform.jruby?
62
- disable_auto_reload: proc {
63
- false
64
- },
65
- command_prefix: proc {
66
- ""
67
- },
68
- auto_indent: proc {
69
- Pry::Helpers::BaseHelpers.use_ansi_codes?
70
- },
71
- correct_indent: proc {
72
- true
73
- },
74
- collision_warning: proc {
75
- false
76
- },
77
- output_prefix: proc {
78
- "=> "
79
- },
80
- requires: proc {
81
- []
82
- },
83
- should_load_requires: proc {
84
- true
85
- },
86
- should_load_plugins: proc {
87
- true
88
- },
89
- windows_console_warning: proc {
90
- true
91
- },
92
- control_d_handler: proc {
93
- Pry::DEFAULT_CONTROL_D_HANDLER
94
- },
95
- memory_size: proc {
96
- 100
97
- },
98
- extra_sticky_locals: proc {
99
- {}
100
- },
101
- command_completions: proc {
102
- proc { commands.keys }
103
- },
104
- file_completions: proc {
105
- proc { Dir["."] }
106
- },
107
- ls: proc {
108
- Pry::Config.from_hash(Pry::Command::Ls::DEFAULT_OPTIONS)
109
- },
110
- completer: proc {
111
- require "pry/input_completer"
112
- Pry::InputCompleter
113
- }
114
- }
7
+ def_memoized({
8
+ input: proc {
9
+ lazy_readline
10
+ },
11
+ output: proc {
12
+ $stdout.tap { |out| out.sync = true }
13
+ },
14
+ commands: proc {
15
+ Pry::Commands
16
+ },
17
+ prompt_name: proc {
18
+ Pry::Prompt::DEFAULT_NAME
19
+ },
20
+ prompt: proc {
21
+ Pry::Prompt[:default][:value]
22
+ },
23
+ prompt_safe_contexts: proc {
24
+ Pry::Prompt::SAFE_CONTEXTS
25
+ },
26
+ print: proc {
27
+ Pry::DEFAULT_PRINT
28
+ },
29
+ quiet: proc {
30
+ false
31
+ },
32
+ exception_handler: proc {
33
+ Pry::DEFAULT_EXCEPTION_HANDLER
34
+ },
35
+ exception_whitelist: proc {
36
+ Pry::DEFAULT_EXCEPTION_WHITELIST
37
+ },
38
+ hooks: proc {
39
+ Pry::DEFAULT_HOOKS
40
+ },
41
+ pager: proc {
42
+ true
43
+ },
44
+ system: proc {
45
+ Pry::DEFAULT_SYSTEM
46
+ },
47
+ color: proc {
48
+ Pry::Helpers::BaseHelpers.use_ansi_codes?
49
+ },
50
+ default_window_size: proc {
51
+ 5
52
+ },
53
+ editor: proc {
54
+ Pry.default_editor_for_platform
55
+ },
56
+ should_load_rc: proc {
57
+ true
58
+ },
59
+ should_load_local_rc: proc {
60
+ true
61
+ },
62
+ should_trap_interrupts: proc {
63
+ Pry::Helpers::Platform.jruby?
64
+ },
65
+ disable_auto_reload: proc {
66
+ false
67
+ },
68
+ command_prefix: proc {
69
+ ""
70
+ },
71
+ auto_indent: proc {
72
+ Pry::Helpers::BaseHelpers.use_ansi_codes?
73
+ },
74
+ correct_indent: proc {
75
+ true
76
+ },
77
+ collision_warning: proc {
78
+ false
79
+ },
80
+ output_prefix: proc {
81
+ "=> "
82
+ },
83
+ requires: proc {
84
+ []
85
+ },
86
+ should_load_requires: proc {
87
+ true
88
+ },
89
+ should_load_plugins: proc {
90
+ true
91
+ },
92
+ windows_console_warning: proc {
93
+ true
94
+ },
95
+ control_d_handler: proc {
96
+ Pry::DEFAULT_CONTROL_D_HANDLER
97
+ },
98
+ memory_size: proc {
99
+ 100
100
+ },
101
+ extra_sticky_locals: proc {
102
+ {}
103
+ },
104
+ command_completions: proc {
105
+ proc { commands.keys }
106
+ },
107
+ file_completions: proc {
108
+ proc { Dir["."] }
109
+ },
110
+ ls: proc {
111
+ Pry::Config.from_hash(Pry::Command::Ls::DEFAULT_OPTIONS)
112
+ },
113
+ completer: proc {
114
+ require "pry/input_completer"
115
+ Pry::InputCompleter
116
+ },
117
+ gist: proc {
118
+ Pry::Config.from_hash({inspecter: proc(&:pretty_inspect)}, nil)
119
+ },
120
+ history: proc {
121
+ Pry::Config.from_hash({should_save: true, should_load: true}, nil).tap do |history|
122
+ history_file =
123
+ if File.exist?(File.expand_path('~/.pry_history'))
124
+ '~/.pry_history'
125
+ elsif ENV.key?('XDG_DATA_HOME') && ENV['XDG_DATA_HOME'] != ''
126
+ # See XDG Base Directory Specification at
127
+ # https://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html
128
+ ENV['XDG_DATA_HOME'] + '/pry/pry_history'
129
+ else
130
+ '~/.local/share/pry/pry_history'
131
+ end
132
+ history.file = File.expand_path(history_file)
133
+ end
134
+ },
135
+ exec_string: proc {
136
+ ""
137
+ }
138
+ })
115
139
 
116
- def initialize
117
- super(nil)
118
- configure_gist
119
- configure_history
120
- end
121
-
122
- default.each do |key, value|
123
- define_method(key) do
124
- if default[key].equal?(value)
125
- default[key] = instance_eval(&value)
140
+ def initialize
141
+ super(nil)
126
142
  end
127
- default[key]
128
- end
129
- end
130
143
 
131
- private
132
- # TODO:
133
- # all of this configure_* stuff is a relic of old code.
134
- # we should try move this code to being command-local.
135
- def configure_gist
136
- self["gist"] = Pry::Config.from_hash(inspecter: proc(&:pretty_inspect))
137
- end
144
+ private
138
145
 
139
- def configure_history
140
- self["history"] = Pry::Config.from_hash "should_save" => true,
141
- "should_load" => true
142
- history.file = File.expand_path("~/.pry_history") rescue nil
143
- if history.file.nil?
144
- self.should_load_rc = false
145
- history.should_save = false
146
- history.should_load = false
146
+ def lazy_readline
147
+ require 'readline'
148
+ Readline
149
+ rescue LoadError
150
+ warn "Sorry, you can't use Pry without Readline or a compatible library."
151
+ warn "Possible solutions:"
152
+ warn " * Rebuild Ruby with Readline support using `--with-readline`"
153
+ warn " * Use the rb-readline gem, which is a pure-Ruby port of Readline"
154
+ warn " * Use the pry-coolline gem, a pure-ruby alternative to Readline"
155
+ raise
156
+ end
147
157
  end
148
158
  end
149
-
150
- def lazy_readline
151
- require 'readline'
152
- Readline
153
- rescue LoadError
154
- warn "Sorry, you can't use Pry without Readline or a compatible library."
155
- warn "Possible solutions:"
156
- warn " * Rebuild Ruby with Readline support using `--with-readline`"
157
- warn " * Use the rb-readline gem, which is a pure-Ruby port of Readline"
158
- warn " * Use the pry-coolline gem, a pure-ruby alternative to Readline"
159
- raise
160
- end
161
159
  end
@@ -0,0 +1,48 @@
1
+ class Pry
2
+ class Config < Pry::BasicObject
3
+ module Memoization
4
+ MEMOIZED_METHODS = Hash.new { |h,k| h[k] = [] }
5
+
6
+ module ClassMethods
7
+ #
8
+ # Defines one or more methods who return a constant value after being
9
+ # called once.
10
+ #
11
+ # @example
12
+ # class Foo
13
+ # include Pry::Config::Memoization
14
+ # def_memoized({
15
+ # foo: proc {1+10},
16
+ # bar: proc{"aaa"<<"a"}
17
+ # })
18
+ # end
19
+ #
20
+ # @param [{String => Proc}] method_table
21
+ #
22
+ # @return [void]
23
+ #
24
+ def def_memoized(method_table)
25
+ method_table.each do |method_name, method|
26
+ define_method(method_name) do
27
+ method_table[method_name] = instance_eval(&method) if method_table[method_name].equal? method
28
+ method_table[method_name]
29
+ end
30
+ end
31
+ MEMOIZED_METHODS[self] |= method_table.keys
32
+ end
33
+ end
34
+
35
+ def self.included(mod)
36
+ mod.extend(ClassMethods)
37
+ end
38
+
39
+ #
40
+ # @return [Array<Symbol>]
41
+ # Returns the names of methods that have been defined by {ClassMethods#def_memoized}.
42
+ #
43
+ def memoized_methods
44
+ MEMOIZED_METHODS[self.class]
45
+ end
46
+ end
47
+ end
48
+ end
data/lib/pry/config.rb CHANGED
@@ -1,24 +1,35 @@
1
- class Pry::Config
2
- require_relative 'config/behavior'
3
- require_relative 'config/default'
4
- require_relative 'config/convenience'
5
- include Pry::Config::Behavior
1
+ class Pry
2
+ # The Pry config.
3
+ # @api public
4
+ class Config < Pry::BasicObject
5
+ # Wraps a block so it can have a name.
6
+ #
7
+ # @example
8
+ # proc1 = proc {}
9
+ # proc2 = Pry::Config::Lazy.new(&proc {})
10
+ #
11
+ # proc1.is_a?(Pry::Config::Lazy)
12
+ # #=> false
13
+ # proc2.is_a?(Pry::Config::Lazy)
14
+ # #=> true
15
+ #
16
+ # @api private
17
+ # @since v0.12.0
18
+ class Lazy
19
+ def initialize(&block)
20
+ @block = block
21
+ end
6
22
 
7
- def self.shortcuts
8
- Convenience::SHORTCUTS
9
- end
23
+ # @return [Object]
24
+ def call
25
+ @block.call
26
+ end
27
+ end
28
+
29
+ include Behavior
10
30
 
11
- #
12
- # FIXME
13
- # @param [Pry::Hooks] hooks
14
- #
15
- def hooks=(hooks)
16
- if hooks.is_a?(Hash)
17
- warn "Hash-based hooks are now deprecated! Use a `Pry::Hooks` object " \
18
- "instead! http://rubydoc.info/github/pry/pry/master/Pry/Hooks"
19
- self["hooks"] = Pry::Hooks.from_hash(hooks)
20
- else
21
- self["hooks"] = hooks
31
+ def self.shortcuts
32
+ Convenience::SHORTCUTS
22
33
  end
23
34
  end
24
35
  end
@@ -38,7 +38,7 @@ class Object
38
38
  # end
39
39
  # my_method()
40
40
  # @see Pry.start
41
- def pry(object=nil, hash={})
41
+ def pry(object = nil, hash = {})
42
42
  if object.nil? || Hash === object
43
43
  Pry.start(self, object || {})
44
44
  else
@@ -68,15 +68,26 @@ class Object
68
68
  def __binding__
69
69
  # If you ever feel like changing this method, be careful about variables
70
70
  # that you use. They shouldn't be inserted into the binding that will
71
- # eventually be returning.
71
+ # eventually be returned.
72
72
 
73
73
  # When you're cd'd into a class, methods you define should be added to it.
74
74
  if is_a?(Module)
75
+ # A special case, for JRuby.
76
+ # Module.new.class_eval("binding") has different behaviour than CRuby,
77
+ # where this is not needed: class_eval("binding") vs class_eval{binding}.
78
+ # Using a block works around the difference of behaviour on JRuby.
79
+ # The scope is clear of local variabless. Don't add any.
80
+ #
81
+ # This fixes the following two spec failures, at https://travis-ci.org/pry/pry/jobs/274470002
82
+ # 1) ./spec/pry_spec.rb:360:in `block in (root)'
83
+ # 2) ./spec/pry_spec.rb:366:in `block in (root)'
84
+ return class_eval { binding } if Pry::Helpers::Platform.jruby? and self.name == nil
85
+
75
86
  # class_eval sets both self and the default definee to this class.
76
- return class_eval "binding"
87
+ return class_eval("binding")
77
88
  end
78
89
 
79
- unless respond_to?(:__pry__)
90
+ unless self.class.method_defined?(:__pry__)
80
91
  # The easiest way to check whether an object has a working singleton class
81
92
  # is to try and define a method on it. (just checking for the presence of
82
93
  # the singleton class gives false positives for `true` and `false`).
data/lib/pry/editor.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  class Pry
2
2
  class Editor
3
- include Pry::Helpers::BaseHelpers
4
3
  include Pry::Helpers::CommandHelpers
5
4
 
6
5
  attr_reader :_pry_
@@ -9,7 +8,7 @@ class Pry
9
8
  @_pry_ = _pry_
10
9
  end
11
10
 
12
- def edit_tempfile_with_content(initial_content, line=1)
11
+ def edit_tempfile_with_content(initial_content, line = 1)
13
12
  temp_file do |f|
14
13
  f.puts(initial_content)
15
14
  f.flush
@@ -19,13 +18,13 @@ class Pry
19
18
  end
20
19
  end
21
20
 
22
- def invoke_editor(file, line, blocking=true)
21
+ def invoke_editor(file, line, blocking = true)
23
22
  raise CommandError, "Please set Pry.config.editor or export $VISUAL or $EDITOR" unless _pry_.config.editor
24
23
 
25
24
  editor_invocation = build_editor_invocation_string(file, line, blocking)
26
25
  return nil unless editor_invocation
27
26
 
28
- if jruby?
27
+ if Helpers::Platform.jruby?
29
28
  open_editor_on_jruby(editor_invocation)
30
29
  else
31
30
  open_editor(editor_invocation)
@@ -43,12 +42,7 @@ class Pry
43
42
  args = [file, line, blocking][0...(_pry_.config.editor.arity)]
44
43
  _pry_.config.editor.call(*args)
45
44
  else
46
- sanitized_file = if windows?
47
- file.gsub(/\//, '\\')
48
- else
49
- Shellwords.escape(file)
50
- end
51
-
45
+ sanitized_file = Helpers::Platform.windows? ? file : Shellwords.escape(file)
52
46
  "#{_pry_.config.editor} #{blocking_flag_for_editor(blocking)} #{start_line_syntax_for_editor(sanitized_file, line)}"
53
47
  end
54
48
  end
@@ -109,7 +103,7 @@ class Pry
109
103
  when /^redcar/
110
104
  "-l#{line_number} #{file_name}"
111
105
  else
112
- if windows?
106
+ if Helpers::Platform.windows?
113
107
  "#{file_name}"
114
108
  else
115
109
  "+#{line_number} #{file_name}"
@@ -130,6 +124,5 @@ class Pry
130
124
  def editor_name
131
125
  File.basename(_pry_.config.editor).split(" ").first
132
126
  end
133
-
134
127
  end
135
128
  end
@@ -1,5 +1,4 @@
1
1
  class Pry
2
-
3
2
  # As a REPL, we often want to catch any unexpected exceptions that may have
4
3
  # been raised; however we don't want to go overboard and prevent the user
5
4
  # from exiting Pry when they want to.
@@ -52,7 +51,7 @@ class Pry
52
51
  def self.===(exception)
53
52
  ["can't modify frozen class/module",
54
53
  "can't modify frozen Class",
55
- "can't modify frozen object"
54
+ "can't modify frozen object",
56
55
  ].include?(exception.message)
57
56
  end
58
57
  end
@@ -74,5 +73,4 @@ class Pry
74
73
  # IRB = Pry thing.
75
74
  module ExtendCommandBundle
76
75
  end
77
-
78
76
  end
@@ -0,0 +1,23 @@
1
+ class Pry
2
+ module Forwardable
3
+ require 'forwardable'
4
+ include ::Forwardable
5
+
6
+ #
7
+ # Since Ruby 2.4, Forwardable will print a warning when
8
+ # calling a method that is private on a delegate, and
9
+ # in the future it could be an error: https://bugs.ruby-lang.org/issues/12782#note-3
10
+ #
11
+ # That's why we revert to a custom implementation for delegating one
12
+ # private method to another.
13
+ #
14
+ def def_private_delegators(target, *private_delegates)
15
+ private_delegates.each do |private_delegate|
16
+ define_method(private_delegate) do |*a, &b|
17
+ instance_variable_get(target).__send__(private_delegate, *a, &b)
18
+ end
19
+ end
20
+ class_eval { private(*private_delegates) }
21
+ end
22
+ end
23
+ end