pry 0.11.3 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +157 -1
  3. data/LICENSE +1 -1
  4. data/README.md +13 -30
  5. data/bin/pry +0 -4
  6. data/lib/pry/cli.rb +17 -24
  7. data/lib/pry/code/code_file.rb +5 -4
  8. data/lib/pry/code/code_range.rb +3 -3
  9. data/lib/pry/code/loc.rb +14 -8
  10. data/lib/pry/code.rb +6 -6
  11. data/lib/pry/code_object.rb +4 -4
  12. data/lib/pry/color_printer.rb +1 -0
  13. data/lib/pry/command.rb +36 -29
  14. data/lib/pry/command_set.rb +17 -52
  15. data/lib/pry/commands/amend_line.rb +3 -4
  16. data/lib/pry/commands/bang.rb +1 -1
  17. data/lib/pry/commands/cat/exception_formatter.rb +9 -8
  18. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  19. data/lib/pry/commands/cat.rb +7 -6
  20. data/lib/pry/commands/change_prompt.rb +29 -9
  21. data/lib/pry/commands/clear_screen.rb +14 -0
  22. data/lib/pry/commands/code_collector.rb +9 -9
  23. data/lib/pry/commands/easter_eggs.rb +3 -3
  24. data/lib/pry/commands/edit.rb +8 -7
  25. data/lib/pry/commands/exit.rb +2 -1
  26. data/lib/pry/commands/find_method.rb +11 -13
  27. data/lib/pry/commands/gem_cd.rb +1 -1
  28. data/lib/pry/commands/gem_install.rb +2 -2
  29. data/lib/pry/commands/gem_list.rb +2 -2
  30. data/lib/pry/commands/gem_open.rb +1 -1
  31. data/lib/pry/commands/gem_search.rb +2 -2
  32. data/lib/pry/commands/gem_stats.rb +83 -0
  33. data/lib/pry/commands/gist.rb +7 -6
  34. data/lib/pry/commands/help.rb +3 -3
  35. data/lib/pry/commands/hist.rb +9 -8
  36. data/lib/pry/commands/import_set.rb +2 -1
  37. data/lib/pry/commands/install_command.rb +7 -6
  38. data/lib/pry/commands/list_inspectors.rb +2 -2
  39. data/lib/pry/commands/ls/constants.rb +4 -4
  40. data/lib/pry/commands/ls/formatter.rb +3 -2
  41. data/lib/pry/commands/ls/globals.rb +0 -2
  42. data/lib/pry/commands/ls/grep.rb +0 -2
  43. data/lib/pry/commands/ls/instance_vars.rb +0 -1
  44. data/lib/pry/commands/ls/local_names.rb +0 -2
  45. data/lib/pry/commands/ls/local_vars.rb +0 -2
  46. data/lib/pry/commands/ls/ls_entity.rb +0 -1
  47. data/lib/pry/commands/ls/methods.rb +0 -3
  48. data/lib/pry/commands/ls/methods_helper.rb +1 -1
  49. data/lib/pry/commands/ls/self_methods.rb +0 -1
  50. data/lib/pry/commands/ls.rb +27 -30
  51. data/lib/pry/commands/play.rb +1 -2
  52. data/lib/pry/commands/pry_backtrace.rb +1 -1
  53. data/lib/pry/commands/raise_up.rb +2 -1
  54. data/lib/pry/commands/ri.rb +5 -4
  55. data/lib/pry/commands/shell_command.rb +3 -2
  56. data/lib/pry/commands/shell_mode.rb +6 -6
  57. data/lib/pry/commands/show_doc.rb +5 -7
  58. data/lib/pry/commands/show_info.rb +25 -18
  59. data/lib/pry/commands/show_source.rb +5 -2
  60. data/lib/pry/commands/stat.rb +1 -1
  61. data/lib/pry/commands/watch_expression.rb +9 -7
  62. data/lib/pry/commands/whereami.rb +4 -4
  63. data/lib/pry/commands/wtf.rb +15 -2
  64. data/lib/pry/config/behavior.rb +229 -205
  65. data/lib/pry/config/convenience.rb +24 -21
  66. data/lib/pry/config/default.rb +153 -143
  67. data/lib/pry/config/memoization.rb +41 -37
  68. data/lib/pry/config.rb +33 -9
  69. data/lib/pry/core_extensions.rb +4 -3
  70. data/lib/pry/editor.rb +5 -12
  71. data/lib/pry/exceptions.rb +0 -2
  72. data/lib/pry/helpers/base_helpers.rb +133 -4
  73. data/lib/pry/helpers/command_helpers.rb +5 -4
  74. data/lib/pry/helpers/documentation_helpers.rb +2 -2
  75. data/lib/pry/helpers/options_helpers.rb +5 -5
  76. data/lib/pry/helpers/platform.rb +58 -0
  77. data/lib/pry/helpers/table.rb +20 -15
  78. data/lib/pry/helpers/text.rb +3 -4
  79. data/lib/pry/helpers.rb +1 -0
  80. data/lib/pry/history.rb +21 -8
  81. data/lib/pry/hooks.rb +3 -3
  82. data/lib/pry/indent.rb +15 -17
  83. data/lib/pry/input_completer.rb +12 -7
  84. data/lib/pry/input_lock.rb +0 -2
  85. data/lib/pry/last_exception.rb +1 -1
  86. data/lib/pry/method/disowned.rb +2 -1
  87. data/lib/pry/method/patcher.rb +2 -2
  88. data/lib/pry/method/weird_method_locator.rb +7 -8
  89. data/lib/pry/method.rb +37 -31
  90. data/lib/pry/object_path.rb +5 -4
  91. data/lib/pry/output.rb +3 -2
  92. data/lib/pry/pager.rb +194 -186
  93. data/lib/pry/platform.rb +79 -81
  94. data/lib/pry/plugins.rb +7 -3
  95. data/lib/pry/prompt.rb +144 -25
  96. data/lib/pry/pry_class.rb +53 -29
  97. data/lib/pry/pry_instance.rb +88 -55
  98. data/lib/pry/repl.rb +33 -4
  99. data/lib/pry/repl_file_loader.rb +1 -2
  100. data/lib/pry/ring.rb +84 -0
  101. data/lib/pry/rubygem.rb +6 -6
  102. data/lib/pry/slop/commands.rb +3 -4
  103. data/lib/pry/slop/option.rb +19 -21
  104. data/lib/pry/slop.rb +17 -17
  105. data/lib/pry/terminal.rb +2 -1
  106. data/lib/pry/testable/mockable.rb +2 -2
  107. data/lib/pry/testable/pry_tester.rb +1 -1
  108. data/lib/pry/testable/utility.rb +2 -2
  109. data/lib/pry/testable/variables.rb +1 -1
  110. data/lib/pry/version.rb +1 -1
  111. data/lib/pry/wrapped_module/candidate.rb +2 -2
  112. data/lib/pry/wrapped_module.rb +15 -15
  113. data/lib/pry.rb +17 -47
  114. metadata +8 -20
  115. data/lib/pry/commands/list_prompts.rb +0 -35
  116. data/lib/pry/commands/simple_prompt.rb +0 -22
  117. data/lib/pry/history_array.rb +0 -121
  118. data/lib/pry/rbx_path.rb +0 -22
data/lib/pry/pager.rb CHANGED
@@ -3,240 +3,248 @@ require 'pry/terminal'
3
3
  # A pager is an `IO`-like object that accepts text and either prints it
4
4
  # immediately, prints it one page at a time, or streams it to an external
5
5
  # program to print one page at a time.
6
- class Pry::Pager
7
- class StopPaging < StandardError
8
- end
9
-
10
- attr_reader :_pry_
11
-
12
- def initialize(_pry_)
13
- @_pry_ = _pry_
14
- end
15
-
16
- # Send the given text through the best available pager (if `Pry.config.pager` is
17
- # enabled). If you want to send text through in chunks as you generate it, use `open`
18
- # to get a writable object instead.
19
- #
20
- # @param [String] text
21
- # Text to run through a pager.
22
- #
23
- def page(text)
24
- open do |pager|
25
- pager << text
6
+ class Pry
7
+ class Pager
8
+ class StopPaging < StandardError
26
9
  end
27
- end
28
-
29
- # Yields a pager object (`NullPager`, `SimplePager`, or `SystemPager`). All
30
- # pagers accept output with `#puts`, `#print`, `#write`, and `#<<`.
31
- def open
32
- pager = best_available
33
- yield pager
34
- rescue StopPaging
35
- ensure
36
- pager.close if pager
37
- end
38
10
 
39
- private
40
-
41
- def enabled?; !!@enabled; end
42
-
43
- def output; @output; end
44
-
45
- # Return an instance of the "best" available pager class -- `SystemPager` if
46
- # possible, `SimplePager` if `SystemPager` isn't available, and `NullPager`
47
- # if the user has disabled paging. All pagers accept output with `#puts`,
48
- # `#print`, `#write`, and `#<<`. You must call `#close` when you're done
49
- # writing output to a pager, and you must rescue `Pry::Pager::StopPaging`.
50
- # These requirements can be avoided by using `.open` instead.
51
- def best_available
52
- if !_pry_.config.pager
53
- NullPager.new(_pry_.output)
54
- elsif !SystemPager.available? || Pry::Helpers::BaseHelpers.jruby?
55
- SimplePager.new(_pry_.output)
56
- else
57
- SystemPager.new(_pry_.output)
58
- end
59
- end
11
+ attr_reader :_pry_
60
12
 
61
- # `NullPager` is a "pager" that actually just prints all output as it comes
62
- # in. Used when `Pry.config.pager` is false.
63
- class NullPager
64
- def initialize(out)
65
- @out = out
13
+ def initialize(_pry_)
14
+ @_pry_ = _pry_
66
15
  end
67
16
 
68
- def puts(str)
69
- print "#{str.chomp}\n"
17
+ # Send the given text through the best available pager (if
18
+ # `Pry.config.pager` is enabled). If you want to send text through in
19
+ # chunks as you generate it, use `open` to get a writable object
20
+ # instead.
21
+ #
22
+ # @param [String] text
23
+ # Text to run through a pager.
24
+ #
25
+ def page(text)
26
+ open do |pager|
27
+ pager << text
28
+ end
70
29
  end
71
30
 
72
- def print(str)
73
- write str
31
+ # Yields a pager object (`NullPager`, `SimplePager`, or `SystemPager`).
32
+ # All pagers accept output with `#puts`, `#print`, `#write`, and `#<<`.
33
+ def open
34
+ pager = best_available
35
+ yield pager
36
+ rescue StopPaging
37
+ ensure
38
+ pager.close if pager
74
39
  end
75
- alias << print
76
40
 
77
- def write(str)
78
- @out.write str
79
- end
41
+ private
80
42
 
81
- def close
43
+ def enabled?; !!@enabled; end
44
+
45
+ def output; @output; end
46
+
47
+ # Return an instance of the "best" available pager class --
48
+ # `SystemPager` if possible, `SimplePager` if `SystemPager` isn't
49
+ # available, and `NullPager` if the user has disabled paging. All
50
+ # pagers accept output with `#puts`, `#print`, `#write`, and `#<<`. You
51
+ # must call `#close` when you're done writing output to a pager, and
52
+ # you must rescue `Pry::Pager::StopPaging`. These requirements can be
53
+ # avoided by using `.open` instead.
54
+ def best_available
55
+ if !_pry_.config.pager
56
+ NullPager.new(_pry_.output)
57
+ elsif !SystemPager.available? || Helpers::Platform.jruby?
58
+ SimplePager.new(_pry_.output)
59
+ else
60
+ SystemPager.new(_pry_.output)
61
+ end
82
62
  end
83
63
 
84
- private
64
+ # `NullPager` is a "pager" that actually just prints all output as it
65
+ # comes in. Used when `Pry.config.pager` is false.
66
+ class NullPager
67
+ def initialize(out)
68
+ @out = out
69
+ end
85
70
 
86
- def height
87
- @height ||= Pry::Terminal.height!
88
- end
71
+ def puts(str)
72
+ print "#{str.chomp}\n"
73
+ end
89
74
 
90
- def width
91
- @width ||= Pry::Terminal.width!
92
- end
93
- end
75
+ def print(str)
76
+ write str
77
+ end
78
+ alias << print
94
79
 
95
- # `SimplePager` is a straightforward pure-Ruby pager. We use it on JRuby and
96
- # when we can't find a usable external pager.
97
- class SimplePager < NullPager
98
- def initialize(*)
99
- super
100
- @tracker = PageTracker.new(height - 3, width)
101
- end
80
+ def write(str)
81
+ @out.write str
82
+ end
102
83
 
103
- def write(str)
104
- str.lines.each do |line|
105
- @out.print line
106
- @tracker.record line
107
-
108
- if @tracker.page?
109
- @out.print "\n"
110
- @out.print "\e[0m"
111
- @out.print "<page break> --- Press enter to continue " \
112
- "( q<enter> to break ) --- <page break>\n"
113
- raise StopPaging if Readline.readline("").chomp == "q"
114
- @tracker.reset
115
- end
84
+ def close
116
85
  end
117
- end
118
- end
119
86
 
120
- # `SystemPager` buffers output until we're pretty sure it's at least a page
121
- # long, then invokes an external pager and starts streaming output to it. If
122
- # `#close` is called before then, it just prints out the buffered content.
123
- class SystemPager < NullPager
124
- def self.default_pager
125
- pager = ENV["PAGER"] || ""
87
+ private
126
88
 
127
- # Default to less, and make sure less is being passed the correct options
128
- if pager.strip.empty? or pager =~ /^less\b/
129
- pager = "less -R -F -X"
89
+ def height
90
+ @height ||= Pry::Terminal.height!
130
91
  end
131
92
 
132
- pager
93
+ def width
94
+ @width ||= Pry::Terminal.width!
95
+ end
133
96
  end
134
97
 
135
- @system_pager = nil
98
+ # `SimplePager` is a straightforward pure-Ruby pager. We use it on
99
+ # JRuby and when we can't find a usable external pager.
100
+ class SimplePager < NullPager
101
+ def initialize(*)
102
+ super
103
+ @tracker = PageTracker.new(height - 3, width)
104
+ end
136
105
 
137
- def self.available?
138
- if @system_pager.nil?
139
- @system_pager = begin
140
- pager_executable = default_pager.split(' ').first
141
- if Pry::Helpers::BaseHelpers.windows? || Pry::Helpers::BaseHelpers.windows_ansi?
142
- `where #{pager_executable}`
143
- else
144
- `which #{pager_executable}`
106
+ def write(str)
107
+ str.lines.each do |line|
108
+ @out.print line
109
+ @tracker.record line
110
+
111
+ if @tracker.page?
112
+ @out.print "\n"
113
+ @out.print "\e[0m"
114
+ @out.print "<page break> --- Press enter to continue " \
115
+ "( q<enter> to break ) --- <page break>\n"
116
+ raise StopPaging if Readline.readline("").chomp == "q"
117
+
118
+ @tracker.reset
145
119
  end
146
- $?.success?
147
- rescue
148
- false
149
120
  end
150
- else
151
- @system_pager
152
121
  end
153
122
  end
154
123
 
155
- def initialize(*)
156
- super
157
- @tracker = PageTracker.new(height, width)
158
- @buffer = ""
159
- @pager = nil
160
- end
124
+ # `SystemPager` buffers output until we're pretty sure it's at least a
125
+ # page long, then invokes an external pager and starts streaming output
126
+ # to it. If `#close` is called before then, it just prints out the
127
+ # buffered content.
128
+ class SystemPager < NullPager
129
+ def self.default_pager
130
+ pager = ENV["PAGER"] || ""
161
131
 
162
- def write(str)
163
- if invoked_pager?
164
- write_to_pager str
165
- else
166
- @tracker.record str
167
- @buffer << str
132
+ # Default to less, and make sure less is being passed the correct
133
+ # options
134
+ if pager.strip.empty? or pager =~ /^less\b/
135
+ pager = "less -R -F -X"
136
+ end
168
137
 
169
- if @tracker.page?
170
- write_to_pager @buffer
138
+ pager
139
+ end
140
+
141
+ @system_pager = nil
142
+
143
+ def self.available?
144
+ if @system_pager.nil?
145
+ @system_pager = begin
146
+ pager_executable = default_pager.split(' ').first
147
+ if Helpers::Platform.windows? || Helpers::Platform.windows_ansi?
148
+ `where /Q #{pager_executable}`
149
+ else
150
+ `which #{pager_executable}`
151
+ end
152
+ $?.success?
153
+ rescue
154
+ false
155
+ end
156
+ else
157
+ @system_pager
171
158
  end
172
159
  end
173
- rescue Errno::EPIPE
174
- raise StopPaging
175
- end
176
160
 
177
- def close
178
- if invoked_pager?
179
- pager.close
180
- else
181
- @out.puts @buffer
161
+ def initialize(*)
162
+ super
163
+ @tracker = PageTracker.new(height, width)
164
+ @buffer = ""
165
+ @pager = nil
182
166
  end
183
- end
184
167
 
185
- private
168
+ def write(str)
169
+ if invoked_pager?
170
+ write_to_pager str
171
+ else
172
+ @tracker.record str
173
+ @buffer << str
186
174
 
187
- def write_to_pager(text)
188
- pager.write @out.decolorize_maybe(text)
189
- end
175
+ if @tracker.page?
176
+ write_to_pager @buffer
177
+ end
178
+ end
179
+ rescue Errno::EPIPE
180
+ raise StopPaging
181
+ end
190
182
 
191
- def invoked_pager?
192
- @pager
193
- end
183
+ def close
184
+ if invoked_pager?
185
+ pager.close
186
+ else
187
+ @out.puts @buffer
188
+ end
189
+ end
194
190
 
195
- def pager
196
- @pager ||= IO.popen(self.class.default_pager, 'w')
197
- end
198
- end
191
+ private
192
+
193
+ def write_to_pager(text)
194
+ pager.write @out.decolorize_maybe(text)
195
+ end
196
+
197
+ def invoked_pager?
198
+ @pager
199
+ end
199
200
 
200
- # `PageTracker` tracks output to determine whether it's likely to take up a
201
- # whole page. This doesn't need to be super precise, but we can use it for
202
- # `SimplePager` and to avoid invoking the system pager unnecessarily.
203
- #
204
- # One simplifying assumption is that we don't need `#page?` to return `true`
205
- # on the basis of an incomplete line. Long lines should be counted as
206
- # multiple lines, but we don't have to transition from `false` to `true`
207
- # until we see a newline.
208
- class PageTracker
209
- def initialize(rows, cols)
210
- @rows, @cols = rows, cols
211
- reset
201
+ def pager
202
+ @pager ||= IO.popen(self.class.default_pager, 'w')
203
+ end
212
204
  end
213
205
 
214
- def record(str)
215
- str.lines.each do |line|
216
- if line.end_with? "\n"
217
- @row += ((@col + line_length(line) - 1) / @cols) + 1
218
- @col = 0
219
- else
220
- @col += line_length(line)
206
+ # `PageTracker` tracks output to determine whether it's likely to take
207
+ # up a whole page. This doesn't need to be super precise, but we can
208
+ # use it for `SimplePager` and to avoid invoking the system pager
209
+ # unnecessarily.
210
+ #
211
+ # One simplifying assumption is that we don't need `#page?` to return
212
+ # `true` on the basis of an incomplete line. Long lines should be
213
+ # counted as multiple lines, but we don't have to transition from
214
+ # `false` to `true` until we see a newline.
215
+ class PageTracker
216
+ def initialize(rows, cols)
217
+ @rows, @cols = rows, cols
218
+ reset
219
+ end
220
+
221
+ def record(str)
222
+ str.lines.each do |line|
223
+ if line.end_with? "\n"
224
+ @row += ((@col + line_length(line) - 1) / @cols) + 1
225
+ @col = 0
226
+ else
227
+ @col += line_length(line)
228
+ end
221
229
  end
222
230
  end
223
- end
224
231
 
225
- def page?
226
- @row >= @rows
227
- end
232
+ def page?
233
+ @row >= @rows
234
+ end
228
235
 
229
- def reset
230
- @row = 0
231
- @col = 0
232
- end
236
+ def reset
237
+ @row = 0
238
+ @col = 0
239
+ end
233
240
 
234
- private
241
+ private
235
242
 
236
- # Approximation of the printable length of a given line, without the
237
- # newline and without ANSI color codes.
238
- def line_length(line)
239
- line.chomp.gsub(/\e\[[\d;]*m/, '').length
243
+ # Approximation of the printable length of a given line, without the
244
+ # newline and without ANSI color codes.
245
+ def line_length(line)
246
+ line.chomp.gsub(/\e\[[\d;]*m/, '').length
247
+ end
240
248
  end
241
249
  end
242
250
  end
data/lib/pry/platform.rb CHANGED
@@ -1,93 +1,91 @@
1
- module Pry::Platform
2
- extend self
1
+ class Pry
2
+ module Platform
3
+ extend self
3
4
 
4
- #
5
- # @return [Boolean]
6
- # Returns true if Pry is running on Mac OSX.
7
- #
8
- # @note
9
- # Queries RbConfig::CONFIG['host_os'] with a best guess.
10
- #
11
- def mac_osx?
12
- !!(RbConfig::CONFIG['host_os'] =~ /\Adarwin/i)
13
- end
5
+ #
6
+ # @return [Boolean]
7
+ # Returns true if Pry is running on Mac OSX.
8
+ #
9
+ # @note
10
+ # Queries RbConfig::CONFIG['host_os'] with a best guess.
11
+ #
12
+ def mac_osx?
13
+ !!(RbConfig::CONFIG['host_os'] =~ /\Adarwin/i)
14
+ end
14
15
 
15
- #
16
- # @return [Boolean]
17
- # Returns true if Pry is running on Linux.
18
- #
19
- # @note
20
- # Queries RbConfig::CONFIG['host_os'] with a best guess.
21
- #
22
- def linux?
23
- !!(RbConfig::CONFIG['host_os'] =~ /linux/i)
24
- end
16
+ #
17
+ # @return [Boolean]
18
+ # Returns true if Pry is running on Linux.
19
+ #
20
+ # @note
21
+ # Queries RbConfig::CONFIG['host_os'] with a best guess.
22
+ #
23
+ def linux?
24
+ !!(RbConfig::CONFIG['host_os'] =~ /linux/i)
25
+ end
25
26
 
26
- #
27
- # @return [Boolean]
28
- # Returns true if Pry is running on Windows.
29
- #
30
- # @note
31
- # Queries RbConfig::CONFIG['host_os'] with a best guess.
32
- #
33
- def windows?
34
- !!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/)
35
- end
27
+ #
28
+ # @return [Boolean]
29
+ # Returns true if Pry is running on Windows.
30
+ #
31
+ # @note
32
+ # Queries RbConfig::CONFIG['host_os'] with a best guess.
33
+ #
34
+ def windows?
35
+ !!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/)
36
+ end
36
37
 
37
- #
38
- # @return [Boolean]
39
- # Returns true when Pry is running on Windows with ANSI support.
40
- #
41
- def windows_ansi?
42
- return false if not windows?
43
- !!(defined?(Win32::Console) or ENV['ANSICON'] or mri_2?)
44
- end
38
+ #
39
+ # @return [Boolean]
40
+ # Returns true when Pry is running on Windows with ANSI support.
41
+ #
42
+ def windows_ansi?
43
+ return false if not windows?
45
44
 
46
- #
47
- # @return [Boolean]
48
- # Returns true when Pry is being run from JRuby.
49
- #
50
- def jruby?
51
- RbConfig::CONFIG['ruby_install_name'] == 'jruby'
52
- end
45
+ !!(defined?(Win32::Console) or ENV['ANSICON'] or mri_2?)
46
+ end
53
47
 
54
- #
55
- # @return [Boolean]
56
- # Returns true when Pry is being run from JRuby in 1.9 mode.
57
- #
58
- def jruby_19?
59
- jruby? and RbConfig::CONFIG['ruby_version'] == '1.9'
60
- end
48
+ #
49
+ # @return [Boolean]
50
+ # Returns true when Pry is being run from JRuby.
51
+ #
52
+ def jruby?
53
+ RbConfig::CONFIG['ruby_install_name'] == 'jruby'
54
+ end
61
55
 
62
- #
63
- # @return [Boolean]
64
- # Returns true when Pry is being run from Rubinius.
65
- #
66
- def rbx?
67
- RbConfig::CONFIG['ruby_install_name'] == 'rbx'
68
- end
56
+ #
57
+ # @return [Boolean]
58
+ # Returns true when Pry is being run from JRuby in 1.9 mode.
59
+ #
60
+ def jruby_19?
61
+ jruby? and RbConfig::CONFIG['ruby_version'] == '1.9'
62
+ end
69
63
 
70
- #
71
- # @return [Boolean]
72
- # Returns true when Pry is being run from MRI (CRuby).
73
- #
74
- def mri?
75
- RbConfig::CONFIG['ruby_install_name'] == 'ruby'
76
- end
64
+ #
65
+ # @return [Boolean]
66
+ # Returns true when Pry is being run from MRI (CRuby).
67
+ #
68
+ def mri?
69
+ RbConfig::CONFIG['ruby_install_name'] == 'ruby'
70
+ end
77
71
 
78
- #
79
- # @return [Boolean]
80
- # Returns true when Pry is being run from MRI v1.9+ (CRuby).
81
- #
82
- def mri_19?
83
- !!(mri? and RUBY_VERSION =~ /\A1\.9/)
84
- end
72
+ #
73
+ # @return [Boolean]
74
+ # Returns true when Pry is being run from MRI v1.9+ (CRuby).
75
+ #
76
+ def mri_19?
77
+ !!(mri? and RUBY_VERSION =~ /\A1\.9/)
78
+ end
85
79
 
86
- #
87
- # @return [Boolean]
88
- # Returns true when Pry is being run from MRI v2+ (CRuby).
89
- #
90
- def mri_2?
91
- !!(mri? and RUBY_VERSION =~ /\A2/)
80
+ #
81
+ # @return [Boolean]
82
+ # Returns true when Pry is being run from MRI v2+ (CRuby).
83
+ #
84
+ def mri_2?
85
+ !!(mri? and RUBY_VERSION =~ /\A2/)
86
+ end
92
87
  end
88
+
89
+ # Not supported on MRI 2.2 and lower.
90
+ deprecate_constant(:Platform) if respond_to?(:deprecate_constant)
93
91
  end
data/lib/pry/plugins.rb CHANGED
@@ -8,7 +8,7 @@ class Pry
8
8
  @name = name
9
9
  end
10
10
 
11
- def method_missing(*args)
11
+ def method_missing(*_args)
12
12
  warn "Warning: The plugin '#{@name}' was not found! (no gem found)"
13
13
  end
14
14
  end
@@ -35,8 +35,12 @@ class Pry
35
35
  # Load the Command line options defined by this plugin (if they exist)
36
36
  def load_cli_options
37
37
  cli_options_file = File.join(spec.full_gem_path, "lib/#{spec.name}/cli.rb")
38
- require cli_options_file if File.exist?(cli_options_file)
38
+ return unless File.exist?(cli_options_file)
39
+
40
+ cli_options_file = File.realpath(cli_options_file) if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.4.4")
41
+ require cli_options_file
39
42
  end
43
+
40
44
  # Activate the plugin (require the gem - enables/loads the
41
45
  # plugin immediately at point of call, even if plugin is
42
46
  # disabled)
@@ -80,6 +84,7 @@ class Pry
80
84
  def locate_plugins
81
85
  gem_list.each do |gem|
82
86
  next if gem.name !~ PRY_PLUGIN_PREFIX
87
+
83
88
  plugin_name = gem.name.split('-', 2).last
84
89
  plugin = Plugin.new(plugin_name, gem.name, gem, false)
85
90
  @plugins << plugin.tap(&:enable!) if plugin.supported? && !plugin_located?(plugin)
@@ -114,5 +119,4 @@ class Pry
114
119
  Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.find_name('')
115
120
  end
116
121
  end
117
-
118
122
  end