pry 0.11.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +157 -1
- data/LICENSE +1 -1
- data/README.md +13 -30
- data/bin/pry +0 -4
- data/lib/pry/cli.rb +17 -24
- data/lib/pry/code/code_file.rb +5 -4
- data/lib/pry/code/code_range.rb +3 -3
- data/lib/pry/code/loc.rb +14 -8
- data/lib/pry/code.rb +6 -6
- data/lib/pry/code_object.rb +4 -4
- data/lib/pry/color_printer.rb +1 -0
- data/lib/pry/command.rb +36 -29
- data/lib/pry/command_set.rb +17 -52
- data/lib/pry/commands/amend_line.rb +3 -4
- data/lib/pry/commands/bang.rb +1 -1
- data/lib/pry/commands/cat/exception_formatter.rb +9 -8
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/cat.rb +7 -6
- data/lib/pry/commands/change_prompt.rb +29 -9
- data/lib/pry/commands/clear_screen.rb +14 -0
- data/lib/pry/commands/code_collector.rb +9 -9
- data/lib/pry/commands/easter_eggs.rb +3 -3
- data/lib/pry/commands/edit.rb +8 -7
- data/lib/pry/commands/exit.rb +2 -1
- data/lib/pry/commands/find_method.rb +11 -13
- data/lib/pry/commands/gem_cd.rb +1 -1
- data/lib/pry/commands/gem_install.rb +2 -2
- data/lib/pry/commands/gem_list.rb +2 -2
- data/lib/pry/commands/gem_open.rb +1 -1
- data/lib/pry/commands/gem_search.rb +2 -2
- data/lib/pry/commands/gem_stats.rb +83 -0
- data/lib/pry/commands/gist.rb +7 -6
- data/lib/pry/commands/help.rb +3 -3
- data/lib/pry/commands/hist.rb +9 -8
- data/lib/pry/commands/import_set.rb +2 -1
- data/lib/pry/commands/install_command.rb +7 -6
- data/lib/pry/commands/list_inspectors.rb +2 -2
- data/lib/pry/commands/ls/constants.rb +4 -4
- data/lib/pry/commands/ls/formatter.rb +3 -2
- data/lib/pry/commands/ls/globals.rb +0 -2
- data/lib/pry/commands/ls/grep.rb +0 -2
- data/lib/pry/commands/ls/instance_vars.rb +0 -1
- data/lib/pry/commands/ls/local_names.rb +0 -2
- data/lib/pry/commands/ls/local_vars.rb +0 -2
- data/lib/pry/commands/ls/ls_entity.rb +0 -1
- data/lib/pry/commands/ls/methods.rb +0 -3
- data/lib/pry/commands/ls/methods_helper.rb +1 -1
- data/lib/pry/commands/ls/self_methods.rb +0 -1
- data/lib/pry/commands/ls.rb +27 -30
- data/lib/pry/commands/play.rb +1 -2
- data/lib/pry/commands/pry_backtrace.rb +1 -1
- data/lib/pry/commands/raise_up.rb +2 -1
- data/lib/pry/commands/ri.rb +5 -4
- data/lib/pry/commands/shell_command.rb +3 -2
- data/lib/pry/commands/shell_mode.rb +6 -6
- data/lib/pry/commands/show_doc.rb +5 -7
- data/lib/pry/commands/show_info.rb +25 -18
- data/lib/pry/commands/show_source.rb +5 -2
- data/lib/pry/commands/stat.rb +1 -1
- data/lib/pry/commands/watch_expression.rb +9 -7
- data/lib/pry/commands/whereami.rb +4 -4
- data/lib/pry/commands/wtf.rb +15 -2
- data/lib/pry/config/behavior.rb +229 -205
- data/lib/pry/config/convenience.rb +24 -21
- data/lib/pry/config/default.rb +153 -143
- data/lib/pry/config/memoization.rb +41 -37
- data/lib/pry/config.rb +33 -9
- data/lib/pry/core_extensions.rb +4 -3
- data/lib/pry/editor.rb +5 -12
- data/lib/pry/exceptions.rb +0 -2
- data/lib/pry/helpers/base_helpers.rb +133 -4
- data/lib/pry/helpers/command_helpers.rb +5 -4
- data/lib/pry/helpers/documentation_helpers.rb +2 -2
- data/lib/pry/helpers/options_helpers.rb +5 -5
- data/lib/pry/helpers/platform.rb +58 -0
- data/lib/pry/helpers/table.rb +20 -15
- data/lib/pry/helpers/text.rb +3 -4
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/history.rb +21 -8
- data/lib/pry/hooks.rb +3 -3
- data/lib/pry/indent.rb +15 -17
- data/lib/pry/input_completer.rb +12 -7
- data/lib/pry/input_lock.rb +0 -2
- data/lib/pry/last_exception.rb +1 -1
- data/lib/pry/method/disowned.rb +2 -1
- data/lib/pry/method/patcher.rb +2 -2
- data/lib/pry/method/weird_method_locator.rb +7 -8
- data/lib/pry/method.rb +37 -31
- data/lib/pry/object_path.rb +5 -4
- data/lib/pry/output.rb +3 -2
- data/lib/pry/pager.rb +194 -186
- data/lib/pry/platform.rb +79 -81
- data/lib/pry/plugins.rb +7 -3
- data/lib/pry/prompt.rb +144 -25
- data/lib/pry/pry_class.rb +53 -29
- data/lib/pry/pry_instance.rb +88 -55
- data/lib/pry/repl.rb +33 -4
- data/lib/pry/repl_file_loader.rb +1 -2
- data/lib/pry/ring.rb +84 -0
- data/lib/pry/rubygem.rb +6 -6
- data/lib/pry/slop/commands.rb +3 -4
- data/lib/pry/slop/option.rb +19 -21
- data/lib/pry/slop.rb +17 -17
- data/lib/pry/terminal.rb +2 -1
- data/lib/pry/testable/mockable.rb +2 -2
- data/lib/pry/testable/pry_tester.rb +1 -1
- data/lib/pry/testable/utility.rb +2 -2
- data/lib/pry/testable/variables.rb +1 -1
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module/candidate.rb +2 -2
- data/lib/pry/wrapped_module.rb +15 -15
- data/lib/pry.rb +17 -47
- metadata +8 -20
- data/lib/pry/commands/list_prompts.rb +0 -35
- data/lib/pry/commands/simple_prompt.rb +0 -22
- data/lib/pry/history_array.rb +0 -121
- 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
|
7
|
-
class
|
8
|
-
|
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
|
-
|
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
|
-
|
62
|
-
|
63
|
-
class NullPager
|
64
|
-
def initialize(out)
|
65
|
-
@out = out
|
13
|
+
def initialize(_pry_)
|
14
|
+
@_pry_ = _pry_
|
66
15
|
end
|
67
16
|
|
68
|
-
|
69
|
-
|
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
|
-
|
73
|
-
|
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
|
-
|
78
|
-
@out.write str
|
79
|
-
end
|
41
|
+
private
|
80
42
|
|
81
|
-
def
|
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
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
71
|
+
def puts(str)
|
72
|
+
print "#{str.chomp}\n"
|
73
|
+
end
|
89
74
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
75
|
+
def print(str)
|
76
|
+
write str
|
77
|
+
end
|
78
|
+
alias << print
|
94
79
|
|
95
|
-
|
96
|
-
|
97
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
128
|
-
|
129
|
-
pager = "less -R -F -X"
|
89
|
+
def height
|
90
|
+
@height ||= Pry::Terminal.height!
|
130
91
|
end
|
131
92
|
|
132
|
-
|
93
|
+
def width
|
94
|
+
@width ||= Pry::Terminal.width!
|
95
|
+
end
|
133
96
|
end
|
134
97
|
|
135
|
-
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
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
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
-
|
170
|
-
|
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
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
@
|
161
|
+
def initialize(*)
|
162
|
+
super
|
163
|
+
@tracker = PageTracker.new(height, width)
|
164
|
+
@buffer = ""
|
165
|
+
@pager = nil
|
182
166
|
end
|
183
|
-
end
|
184
167
|
|
185
|
-
|
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
|
-
|
188
|
-
|
189
|
-
|
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
|
-
|
192
|
-
|
193
|
-
|
183
|
+
def close
|
184
|
+
if invoked_pager?
|
185
|
+
pager.close
|
186
|
+
else
|
187
|
+
@out.puts @buffer
|
188
|
+
end
|
189
|
+
end
|
194
190
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
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
|
-
|
201
|
-
|
202
|
-
|
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
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
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
|
-
|
226
|
-
|
227
|
-
|
232
|
+
def page?
|
233
|
+
@row >= @rows
|
234
|
+
end
|
228
235
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
236
|
+
def reset
|
237
|
+
@row = 0
|
238
|
+
@col = 0
|
239
|
+
end
|
233
240
|
|
234
|
-
|
241
|
+
private
|
235
242
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
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
|
-
|
2
|
-
|
1
|
+
class Pry
|
2
|
+
module Platform
|
3
|
+
extend self
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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(*
|
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
|
-
|
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
|