pry 0.12.1 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/pry.rb +3 -2
- data/lib/pry/cli.rb +2 -2
- data/lib/pry/command.rb +16 -11
- data/lib/pry/commands/change_prompt.rb +1 -1
- data/lib/pry/commands/ls/jruby_hacks.rb +1 -1
- data/lib/pry/commands/ls/local_vars.rb +1 -1
- data/lib/pry/commands/show_info.rb +1 -1
- data/lib/pry/commands/wtf.rb +1 -1
- data/lib/pry/config/behavior.rb +2 -2
- data/lib/pry/helpers/base_helpers.rb +128 -0
- data/lib/pry/hooks.rb +4 -4
- data/lib/pry/indent.rb +1 -1
- data/lib/pry/method.rb +9 -0
- data/lib/pry/platform.rb +91 -0
- data/lib/pry/prompt.rb +18 -25
- data/lib/pry/pry_instance.rb +30 -0
- data/lib/pry/repl_file_loader.rb +1 -1
- data/lib/pry/slop.rb +1 -1
- data/lib/pry/slop/option.rb +1 -1
- data/lib/pry/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6320662aa62bb2b7410cb900e5e0d75e075413da
|
4
|
+
data.tar.gz: d72635ecb0613ee87e6bf7fbc37c71573f1137ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 396ab2db71196633ab518104409ae367d67c9c9e64a318bdecbef0e40010364cc207211f808f2e616d9909ec93b256b5bc0f58a458f7ac97d195eee8ee6d7e71
|
7
|
+
data.tar.gz: f74d3c223f09b7d06af0a30500176a6caa10474646ce59fb787d6a5936ab420828a399679d55f7fa0a106ab2f5f45d622748cb13804af85032621151c1147a94
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
### HEAD
|
2
2
|
|
3
|
+
### [v0.12.2][v0.12.2] (November 12, 2018)
|
4
|
+
|
5
|
+
#### Bug fixes
|
6
|
+
|
7
|
+
* Restore removed deprecations, which were removed by accident due to a bad
|
8
|
+
rebase.
|
9
|
+
|
3
10
|
### [v0.12.1][v0.12.1] (November 12, 2018)
|
4
11
|
|
5
12
|
#### Bug fixes
|
@@ -943,3 +950,4 @@ complete CHANGELOG:
|
|
943
950
|
|
944
951
|
[v0.12.0]: https://github.com/pry/pry/releases/tag/v0.12.0
|
945
952
|
[v0.12.1]: https://github.com/pry/pry/releases/tag/v0.12.1
|
953
|
+
[v0.12.2]: https://github.com/pry/pry/releases/tag/v0.12.2
|
data/lib/pry.rb
CHANGED
@@ -2,19 +2,20 @@ require 'pp'
|
|
2
2
|
require 'pry/forwardable'
|
3
3
|
require 'pry/input_lock'
|
4
4
|
require 'pry/exceptions'
|
5
|
+
require 'pry/platform'
|
5
6
|
require 'pry/helpers/base_helpers'
|
6
7
|
require 'pry/hooks'
|
7
8
|
|
8
9
|
class Pry
|
9
10
|
# The default hooks - display messages when beginning and ending Pry sessions.
|
10
|
-
DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |
|
11
|
+
DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |out, target, _pry_|
|
11
12
|
next if _pry_.quiet?
|
12
13
|
|
13
14
|
_pry_.run_command("whereami --quiet")
|
14
15
|
end
|
15
16
|
|
16
17
|
# The default print
|
17
|
-
DEFAULT_PRINT = proc do |
|
18
|
+
DEFAULT_PRINT = proc do |output, value, _pry_|
|
18
19
|
_pry_.pager.open do |pager|
|
19
20
|
pager.print _pry_.config.output_prefix
|
20
21
|
Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1)
|
data/lib/pry/cli.rb
CHANGED
@@ -191,7 +191,7 @@ Pry::CLI.add_options do
|
|
191
191
|
Pry.config.requires << file
|
192
192
|
end
|
193
193
|
|
194
|
-
on
|
194
|
+
on :I=, "Add a path to the $LOAD_PATH", as: Array, delimiter: ":" do |load_path|
|
195
195
|
load_path.map! do |path|
|
196
196
|
/\A\.\// =~ path ? path : File.expand_path(path)
|
197
197
|
end
|
@@ -199,7 +199,7 @@ Pry::CLI.add_options do
|
|
199
199
|
$LOAD_PATH.unshift(*load_path)
|
200
200
|
end
|
201
201
|
|
202
|
-
on "gem", "Shorthand for -I./lib -rgemname" do |
|
202
|
+
on "gem", "Shorthand for -I./lib -rgemname" do |load_path|
|
203
203
|
$LOAD_PATH.unshift("./lib")
|
204
204
|
Dir["./lib/*.rb"].each do |file|
|
205
205
|
Pry.config.requires << file
|
data/lib/pry/command.rb
CHANGED
@@ -252,6 +252,18 @@ class Pry
|
|
252
252
|
command_set.to_hash
|
253
253
|
end
|
254
254
|
|
255
|
+
#
|
256
|
+
# @deprecated
|
257
|
+
# Please use black(), white(), etc directly instead (as you would with helper
|
258
|
+
# functions from BaseHelpers and CommandHelpers)
|
259
|
+
#
|
260
|
+
# @return [Module]
|
261
|
+
# Returns Pry::Helpers::Text
|
262
|
+
#
|
263
|
+
def text
|
264
|
+
Pry::Helpers::Text
|
265
|
+
end
|
266
|
+
|
255
267
|
def void
|
256
268
|
VOID_VALUE
|
257
269
|
end
|
@@ -307,10 +319,7 @@ class Pry
|
|
307
319
|
collision_type ||= 'local-variable' if arg_string.match(%r{\A\s*[-+*/%&|^]*=})
|
308
320
|
|
309
321
|
if collision_type
|
310
|
-
output.puts(
|
311
|
-
"#{Helpers::Text.bold('WARNING:')} Calling Pry command '#{command_match}', " \
|
312
|
-
"which conflicts with a #{collision_type}.\n\n"
|
313
|
-
)
|
322
|
+
output.puts "#{text.bold('WARNING:')} Calling Pry command '#{command_match}', which conflicts with a #{collision_type}.\n\n"
|
314
323
|
end
|
315
324
|
rescue Pry::RescuableException
|
316
325
|
end
|
@@ -416,13 +425,9 @@ class Pry
|
|
416
425
|
unless dependencies_met?
|
417
426
|
gems_needed = Array(command_options[:requires_gem])
|
418
427
|
gems_not_installed = gems_needed.select { |g| !Rubygem.installed?(g) }
|
419
|
-
output.puts(
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
Type #{Helpers::Text.bold('install-command ' + command_name)} to install the required gems
|
424
|
-
and activate this command.
|
425
|
-
WARN
|
428
|
+
output.puts "\nThe command '#{command_name}' is #{text.bold("unavailable")} because it requires the following gems to be installed: #{(gems_not_installed.join(", "))}"
|
429
|
+
output.puts "-"
|
430
|
+
output.puts "Type `install-command #{command_name}` to install the required gems and activate this command."
|
426
431
|
return void
|
427
432
|
end
|
428
433
|
|
@@ -28,7 +28,7 @@ class Pry::Command::ChangePrompt < Pry::ClassCommand
|
|
28
28
|
"#{bold(name)}#{red(' (selected)') if _pry_.prompt == prompt[:value]}\n" +
|
29
29
|
prompt[:description]
|
30
30
|
end
|
31
|
-
output.puts(prompts.join("\n"
|
31
|
+
output.puts(prompts.join("\n"))
|
32
32
|
end
|
33
33
|
|
34
34
|
def change_prompt(prompt)
|
@@ -155,7 +155,7 @@ class Pry
|
|
155
155
|
owner: "\n#{bold("Owner:")} #{code_object.owner || "N/A"}\n",
|
156
156
|
visibility: "#{bold("Visibility:")} #{code_object.visibility}",
|
157
157
|
signature: "\n#{bold("Signature:")} #{code_object.signature}"
|
158
|
-
}.merge(header_options) { |
|
158
|
+
}.merge(header_options) { |key, old, new| (new && old).to_s }
|
159
159
|
end
|
160
160
|
|
161
161
|
def header_options
|
data/lib/pry/commands/wtf.rb
CHANGED
@@ -36,7 +36,7 @@ class Pry
|
|
36
36
|
if exception.respond_to? :cause
|
37
37
|
cause = exception.cause
|
38
38
|
while cause
|
39
|
-
output.puts "#{bold('Caused by:')} #{cause.class}: #{cause}\n--"
|
39
|
+
output.puts "#{text.bold('Caused by:')} #{cause.class}: #{cause}\n--"
|
40
40
|
if opts.verbose?
|
41
41
|
output.puts with_line_numbers(cause.backtrace)
|
42
42
|
else
|
data/lib/pry/config/behavior.rb
CHANGED
@@ -163,8 +163,8 @@ class Pry
|
|
163
163
|
|
164
164
|
def eager_load!
|
165
165
|
default = @default
|
166
|
-
while default
|
167
|
-
default.memoized_methods.each { self[key] = default.public_send(key) }
|
166
|
+
while default
|
167
|
+
default.memoized_methods.each { |method| self[key] = default.public_send(key) } if default.respond_to?(:memoized_methods)
|
168
168
|
default = @default.default
|
169
169
|
end
|
170
170
|
end
|
@@ -1,8 +1,135 @@
|
|
1
1
|
module Pry::Helpers; end
|
2
2
|
|
3
|
+
# rubocop:disable Metrics/ModuleLength
|
3
4
|
module Pry::Helpers::BaseHelpers
|
4
5
|
extend self
|
5
6
|
|
7
|
+
@mac_osx_warn = false
|
8
|
+
# @deprecated Use {Pry::Helpers::Platform.mac_osx?} instead.
|
9
|
+
def mac_osx?
|
10
|
+
unless @mac_osx_warn
|
11
|
+
loc = caller_locations(1..1).first
|
12
|
+
warn(
|
13
|
+
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
14
|
+
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
15
|
+
)
|
16
|
+
@mac_osx_warn = true
|
17
|
+
end
|
18
|
+
Pry::Helpers::Platform.mac_osx?
|
19
|
+
end
|
20
|
+
|
21
|
+
@linux_warn = false
|
22
|
+
# @deprecated Use {Pry::Helpers::Platform.mac_osx?} instead.
|
23
|
+
def linux?
|
24
|
+
unless @linux_warn
|
25
|
+
loc = caller_locations(1..1).first
|
26
|
+
warn(
|
27
|
+
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
28
|
+
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
29
|
+
)
|
30
|
+
@linux_warn = true
|
31
|
+
end
|
32
|
+
Pry::Helpers::Platform.linux?
|
33
|
+
end
|
34
|
+
|
35
|
+
@windows_warn = false
|
36
|
+
# @deprecated Use {Pry::Helpers::Platform.windows?} instead.
|
37
|
+
def windows?
|
38
|
+
unless @windows_warn
|
39
|
+
loc = caller_locations(1..1).first
|
40
|
+
warn(
|
41
|
+
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
42
|
+
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
43
|
+
)
|
44
|
+
@windows_warn = true
|
45
|
+
end
|
46
|
+
Pry::Helpers::Platform.windows?
|
47
|
+
end
|
48
|
+
|
49
|
+
@windows_ansi_warn = false
|
50
|
+
# @deprecated Use {Pry::Helpers::Platform.windows_ansi?} instead.
|
51
|
+
def windows_ansi?
|
52
|
+
unless @windows_ansi_warn
|
53
|
+
loc = caller_locations(1..1).first
|
54
|
+
warn(
|
55
|
+
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
56
|
+
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
57
|
+
)
|
58
|
+
@windows_ansi_warn = true
|
59
|
+
end
|
60
|
+
Pry::Helpers::Platform.windows_ansi?
|
61
|
+
end
|
62
|
+
|
63
|
+
@jruby_warn = false
|
64
|
+
# @deprecated Use {Pry::Helpers::Platform.jruby?} instead.
|
65
|
+
def jruby?
|
66
|
+
unless @jruby_warn
|
67
|
+
loc = caller_locations(1..1).first
|
68
|
+
warn(
|
69
|
+
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
70
|
+
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
71
|
+
)
|
72
|
+
@jruby_warn = true
|
73
|
+
end
|
74
|
+
Pry::Helpers::Platform.jruby?
|
75
|
+
end
|
76
|
+
|
77
|
+
@jruby19_warn = false
|
78
|
+
# @deprecated Use {Pry::Helpers::Platform.jruby_19?} instead.
|
79
|
+
def jruby_19?
|
80
|
+
unless @jruby19_warn
|
81
|
+
loc = caller_locations(1..1).first
|
82
|
+
warn(
|
83
|
+
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
84
|
+
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
85
|
+
)
|
86
|
+
@jruby19_warn = true
|
87
|
+
end
|
88
|
+
Pry::Helpers::Platform.jruby_19?
|
89
|
+
end
|
90
|
+
|
91
|
+
@mri_warn = false
|
92
|
+
# @deprecated Use {Pry::Helpers::Platform.mri?} instead.
|
93
|
+
def mri?
|
94
|
+
unless @mri_warn
|
95
|
+
loc = caller_locations(1..1).first
|
96
|
+
warn(
|
97
|
+
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
98
|
+
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
99
|
+
)
|
100
|
+
@mri_warn = true
|
101
|
+
end
|
102
|
+
Pry::Helpers::Platform.mri?
|
103
|
+
end
|
104
|
+
|
105
|
+
@mri19_warn = false
|
106
|
+
# @deprecated Use {Pry::Helpers::Platform.mri_19?} instead.
|
107
|
+
def mri_19?
|
108
|
+
unless @mri19_warn
|
109
|
+
loc = caller_locations(1..1).first
|
110
|
+
warn(
|
111
|
+
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
112
|
+
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
113
|
+
)
|
114
|
+
@mri19_warn = true
|
115
|
+
end
|
116
|
+
Pry::Helpers::Platform.mri_19?
|
117
|
+
end
|
118
|
+
|
119
|
+
@mri2_warn = false
|
120
|
+
# @deprecated Use {Pry::Helpers::Platform.mri_2?} instead.
|
121
|
+
def mri_2?
|
122
|
+
unless @mri2_warn
|
123
|
+
loc = caller_locations(1..1).first
|
124
|
+
warn(
|
125
|
+
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
126
|
+
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
127
|
+
)
|
128
|
+
@mri2_warn = true
|
129
|
+
end
|
130
|
+
Pry::Helpers::Platform.mri_2?
|
131
|
+
end
|
132
|
+
|
6
133
|
def silence_warnings
|
7
134
|
old_verbose = $VERBOSE
|
8
135
|
$VERBOSE = nil
|
@@ -70,3 +197,4 @@ module Pry::Helpers::BaseHelpers
|
|
70
197
|
end
|
71
198
|
end
|
72
199
|
end
|
200
|
+
# rubocop:enable Metrics/ModuleLength
|
data/lib/pry/hooks.rb
CHANGED
@@ -34,7 +34,7 @@ class Pry
|
|
34
34
|
# @return [Pry:Hooks] The receiver.
|
35
35
|
# @see #merge
|
36
36
|
def merge!(other)
|
37
|
-
@hooks.merge!(other.dup.hooks) do |
|
37
|
+
@hooks.merge!(other.dup.hooks) do |key, array, other_array|
|
38
38
|
temp_hash, output = {}, []
|
39
39
|
|
40
40
|
(array + other_array).reverse_each do |pair|
|
@@ -79,7 +79,7 @@ class Pry
|
|
79
79
|
end
|
80
80
|
|
81
81
|
# ensure we only have one anonymous hook
|
82
|
-
@hooks[event_name].delete_if { |h,
|
82
|
+
@hooks[event_name].delete_if { |h, k| h.nil? } if hook_name.nil?
|
83
83
|
|
84
84
|
if block
|
85
85
|
@hooks[event_name] << [hook_name, block]
|
@@ -95,7 +95,7 @@ class Pry
|
|
95
95
|
# @param [Array] args The arguments to pass to each hook function.
|
96
96
|
# @return [Object] The return value of the last executed hook.
|
97
97
|
def exec_hook(event_name, *args, &block)
|
98
|
-
@hooks[event_name.to_s].map do |
|
98
|
+
@hooks[event_name.to_s].map do |hook_name, callable|
|
99
99
|
begin
|
100
100
|
callable.call(*args, &block)
|
101
101
|
rescue RescuableException => e
|
@@ -115,7 +115,7 @@ class Pry
|
|
115
115
|
# @param [Symbol] hook_name The name of the hook
|
116
116
|
# @return [#call] a specific hook for a given event.
|
117
117
|
def get_hook(event_name, hook_name)
|
118
|
-
hook = @hooks[event_name.to_s].find do |current_hook_name,
|
118
|
+
hook = @hooks[event_name.to_s].find do |current_hook_name, callable|
|
119
119
|
current_hook_name == hook_name
|
120
120
|
end
|
121
121
|
hook.last if hook
|
data/lib/pry/indent.rb
CHANGED
@@ -145,7 +145,7 @@ class Pry
|
|
145
145
|
input.lines.each do |line|
|
146
146
|
if in_string?
|
147
147
|
tokens = tokenize("#{open_delimiters_line}\n#{line}")
|
148
|
-
tokens = tokens.drop_while { |token,
|
148
|
+
tokens = tokens.drop_while { |token, type| !(String === token && token.include?("\n")) }
|
149
149
|
previously_in_string = true
|
150
150
|
else
|
151
151
|
tokens = tokenize(line)
|
data/lib/pry/method.rb
CHANGED
@@ -161,6 +161,15 @@ class Pry
|
|
161
161
|
all_from_class(singleton_class_of(obj), include_super)
|
162
162
|
end
|
163
163
|
|
164
|
+
#
|
165
|
+
# @deprecated
|
166
|
+
# please use {all_from_obj} instead.
|
167
|
+
# the `method_type` argument is ignored.
|
168
|
+
#
|
169
|
+
def all_from_common(obj, _method_type = nil, include_super = true)
|
170
|
+
all_from_obj(obj, include_super)
|
171
|
+
end
|
172
|
+
|
164
173
|
# Get every `Class` and `Module`, in order, that will be checked when looking
|
165
174
|
# for an instance method to call on this object.
|
166
175
|
# @param [Object] obj
|
data/lib/pry/platform.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
class Pry
|
2
|
+
module Platform
|
3
|
+
extend self
|
4
|
+
|
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
|
15
|
+
|
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
|
26
|
+
|
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
|
37
|
+
|
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?
|
44
|
+
|
45
|
+
!!(defined?(Win32::Console) or ENV['ANSICON'] or mri_2?)
|
46
|
+
end
|
47
|
+
|
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
|
55
|
+
|
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
|
63
|
+
|
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
|
71
|
+
|
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
|
79
|
+
|
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
|
87
|
+
end
|
88
|
+
|
89
|
+
# Not supported on MRI 2.2 and lower.
|
90
|
+
deprecate_constant(:Platform) if respond_to?(:deprecate_constant)
|
91
|
+
end
|
data/lib/pry/prompt.rb
CHANGED
@@ -27,6 +27,10 @@ class Pry
|
|
27
27
|
# 1-line #inspect output suitable for prompt
|
28
28
|
SAFE_CONTEXTS = [String, Numeric, Symbol, nil, true, false].freeze
|
29
29
|
|
30
|
+
# @deprecated Use {Pry::Prompt.add} instead.
|
31
|
+
MAP = {}
|
32
|
+
deprecate_constant(:MAP) if respond_to?(:deprecate_constant)
|
33
|
+
|
30
34
|
# A Hash that holds all prompts. The keys of the Hash are prompt
|
31
35
|
# names, the values are Hash instances of the format {:description, :value}.
|
32
36
|
@prompts = {}
|
@@ -90,10 +94,11 @@ class Pry
|
|
90
94
|
end
|
91
95
|
end
|
92
96
|
|
93
|
-
add
|
94
|
-
|
95
|
-
|
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
|
97
102
|
format(
|
98
103
|
"[%<in_count>s] %<name>s(%<context>s)%<nesting>s%<separator>s ",
|
99
104
|
in_count: _pry_.input_ring.count,
|
@@ -104,20 +109,14 @@ class Pry
|
|
104
109
|
)
|
105
110
|
end
|
106
111
|
|
107
|
-
add(
|
108
|
-
'simple',
|
109
|
-
"A simple `>>`.",
|
110
|
-
['>> ', ' | ']
|
111
|
-
) do |_, _, _, sep|
|
112
|
+
add(:simple, "A simple `>>`.\n", ['>> ', ' | ']) do |_, _, _, sep|
|
112
113
|
sep
|
113
114
|
end
|
114
115
|
|
115
|
-
add(
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
%w[> *]
|
120
|
-
) do |_context, _nesting, _pry_, sep|
|
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
|
121
120
|
tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval('self')) }
|
122
121
|
format(
|
123
122
|
"[%<in_count>s] (%<name>s) %<tree>s: %<stack_size>s%<separator>s ",
|
@@ -129,11 +128,9 @@ class Pry
|
|
129
128
|
)
|
130
129
|
end
|
131
130
|
|
132
|
-
add(
|
133
|
-
|
134
|
-
|
135
|
-
%w[$ *]
|
136
|
-
) do |context, _nesting, _pry_, sep|
|
131
|
+
add(:shell, <<DESC, %w[$ *]) do |context, nesting, _pry_, sep|
|
132
|
+
A prompt that displays `$PWD` as you change it.
|
133
|
+
DESC
|
137
134
|
format(
|
138
135
|
"%<name>s %<context>s:%<pwd>s %<separator>s ",
|
139
136
|
name: prompt_name(_pry_.config.prompt_name),
|
@@ -143,10 +140,6 @@ class Pry
|
|
143
140
|
)
|
144
141
|
end
|
145
142
|
|
146
|
-
add(
|
147
|
-
'none',
|
148
|
-
'Wave goodbye to the Pry prompt.',
|
149
|
-
Array.new(2)
|
150
|
-
) { '' }
|
143
|
+
add(:none, 'Wave goodbye to the Pry prompt.', Array.new(2)) { '' }
|
151
144
|
end
|
152
145
|
end
|
data/lib/pry/pry_instance.rb
CHANGED
@@ -87,6 +87,36 @@ class Pry
|
|
87
87
|
exec_hook(:when_started, target, options, self)
|
88
88
|
end
|
89
89
|
|
90
|
+
@input_array_warn = false
|
91
|
+
# @deprecated Use {#input_ring} instead.
|
92
|
+
def input_array
|
93
|
+
unless @input_array_warn
|
94
|
+
loc = caller_locations(1..1).first
|
95
|
+
warn(
|
96
|
+
"#{loc.path}:#{loc.lineno}: warning: method #{self.class}##{__method__} " \
|
97
|
+
"is deprecated. Use #{self.class}#input_ring instead"
|
98
|
+
)
|
99
|
+
@input_array_warn = true
|
100
|
+
end
|
101
|
+
|
102
|
+
@input_ring
|
103
|
+
end
|
104
|
+
|
105
|
+
@output_array_warn = false
|
106
|
+
# @deprecated Use {#output_ring} instead.
|
107
|
+
def output_array
|
108
|
+
unless @output_array_warn
|
109
|
+
loc = caller_locations(1..1).first
|
110
|
+
warn(
|
111
|
+
"#{loc.path}:#{loc.lineno}: warning: method #{self.class}##{__method__} " \
|
112
|
+
"is deprecated. Use #{self.class}#output_ring instead"
|
113
|
+
)
|
114
|
+
@output_array_warn = true
|
115
|
+
end
|
116
|
+
|
117
|
+
@output_ring
|
118
|
+
end
|
119
|
+
|
90
120
|
# This is the prompt at the top of the prompt stack.
|
91
121
|
# @return [Array<Proc>] the current prompt
|
92
122
|
def prompt
|
data/lib/pry/repl_file_loader.rb
CHANGED
@@ -34,7 +34,7 @@ class Pry
|
|
34
34
|
# @param [Pry] _pry_ the Pry instance to make non-interactive.
|
35
35
|
def non_interactive_mode(_pry_, content)
|
36
36
|
_pry_.print = proc {}
|
37
|
-
_pry_.exception_handler = proc do |o,
|
37
|
+
_pry_.exception_handler = proc do |o, e, _p_|
|
38
38
|
_p_.run_command "cat --ex"
|
39
39
|
o.puts "...exception encountered, going interactive!"
|
40
40
|
interactive_mode(_pry_)
|
data/lib/pry/slop.rb
CHANGED
@@ -224,7 +224,7 @@ class Pry::Slop
|
|
224
224
|
autocreate(items, index) if config[:autocreate]
|
225
225
|
process_item(items, index, &block) unless @trash.include?(index)
|
226
226
|
end
|
227
|
-
items.reject!.with_index { |
|
227
|
+
items.reject!.with_index { |item, index| @trash.include?(index) }
|
228
228
|
|
229
229
|
missing_options = options.select { |opt| opt.required? && opt.count < 1 }
|
230
230
|
if missing_options.any?
|
data/lib/pry/slop/option.rb
CHANGED
@@ -45,7 +45,7 @@ class Pry::Slop
|
|
45
45
|
integer: proc { |v| value_to_integer(v) },
|
46
46
|
float: proc { |v| value_to_float(v) },
|
47
47
|
range: proc { |v| value_to_range(v) },
|
48
|
-
count: proc { @count }
|
48
|
+
count: proc { |v| @count }
|
49
49
|
}
|
50
50
|
|
51
51
|
if long && long.size > @slop.config[:longest_flag]
|
data/lib/pry/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mair (banisterfiend)
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- lib/pry/object_path.rb
|
174
174
|
- lib/pry/output.rb
|
175
175
|
- lib/pry/pager.rb
|
176
|
+
- lib/pry/platform.rb
|
176
177
|
- lib/pry/plugins.rb
|
177
178
|
- lib/pry/prompt.rb
|
178
179
|
- lib/pry/pry_class.rb
|