pry 0.9.12.6-i386-mswin32 → 0.10.0-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +702 -0
- data/LICENSE +2 -2
- data/{README.markdown → README.md} +37 -31
- data/lib/pry.rb +38 -151
- data/lib/pry/cli.rb +35 -17
- data/lib/pry/code.rb +19 -63
- data/lib/pry/code/code_file.rb +103 -0
- data/lib/pry/code/code_range.rb +2 -1
- data/lib/pry/code/loc.rb +2 -2
- data/lib/pry/code_object.rb +40 -21
- data/lib/pry/color_printer.rb +55 -0
- data/lib/pry/command.rb +12 -9
- data/lib/pry/command_set.rb +81 -38
- data/lib/pry/commands.rb +1 -1
- data/lib/pry/commands/amend_line.rb +2 -2
- data/lib/pry/commands/bang.rb +1 -1
- data/lib/pry/commands/cat.rb +11 -2
- data/lib/pry/commands/cat/exception_formatter.rb +6 -7
- data/lib/pry/commands/cat/file_formatter.rb +15 -32
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/cd.rb +14 -3
- data/lib/pry/commands/change_inspector.rb +27 -0
- data/lib/pry/commands/change_prompt.rb +26 -0
- data/lib/pry/commands/code_collector.rb +4 -4
- data/lib/pry/commands/easter_eggs.rb +3 -3
- data/lib/pry/commands/edit.rb +10 -22
- data/lib/pry/commands/edit/exception_patcher.rb +2 -2
- data/lib/pry/commands/edit/file_and_line_locator.rb +0 -2
- data/lib/pry/commands/exit_program.rb +0 -1
- data/lib/pry/commands/find_method.rb +16 -22
- data/lib/pry/commands/gem_install.rb +5 -2
- data/lib/pry/commands/gem_open.rb +1 -1
- data/lib/pry/commands/gist.rb +10 -11
- data/lib/pry/commands/help.rb +14 -14
- data/lib/pry/commands/hist.rb +27 -8
- data/lib/pry/commands/install_command.rb +14 -12
- data/lib/pry/commands/list_inspectors.rb +35 -0
- data/lib/pry/commands/list_prompts.rb +35 -0
- data/lib/pry/commands/ls.rb +72 -296
- data/lib/pry/commands/ls/constants.rb +47 -0
- data/lib/pry/commands/ls/formatter.rb +49 -0
- data/lib/pry/commands/ls/globals.rb +48 -0
- data/lib/pry/commands/ls/grep.rb +21 -0
- data/lib/pry/commands/ls/instance_vars.rb +39 -0
- data/lib/pry/commands/ls/interrogatable.rb +18 -0
- data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
- data/lib/pry/commands/ls/local_names.rb +35 -0
- data/lib/pry/commands/ls/local_vars.rb +39 -0
- data/lib/pry/commands/ls/ls_entity.rb +70 -0
- data/lib/pry/commands/ls/methods.rb +57 -0
- data/lib/pry/commands/ls/methods_helper.rb +46 -0
- data/lib/pry/commands/ls/self_methods.rb +32 -0
- data/lib/pry/commands/play.rb +44 -10
- data/lib/pry/commands/pry_backtrace.rb +1 -2
- data/lib/pry/commands/raise_up.rb +2 -2
- data/lib/pry/commands/reload_code.rb +16 -19
- data/lib/pry/commands/ri.rb +7 -3
- data/lib/pry/commands/shell_command.rb +18 -13
- data/lib/pry/commands/shell_mode.rb +2 -4
- data/lib/pry/commands/show_doc.rb +5 -0
- data/lib/pry/commands/show_info.rb +8 -13
- data/lib/pry/commands/show_source.rb +15 -3
- data/lib/pry/commands/simple_prompt.rb +1 -1
- data/lib/pry/commands/toggle_color.rb +8 -4
- data/lib/pry/commands/watch_expression.rb +105 -0
- data/lib/pry/commands/watch_expression/expression.rb +38 -0
- data/lib/pry/commands/whereami.rb +18 -10
- data/lib/pry/commands/wtf.rb +3 -3
- data/lib/pry/config.rb +20 -254
- data/lib/pry/config/behavior.rb +139 -0
- data/lib/pry/config/convenience.rb +26 -0
- data/lib/pry/config/default.rb +165 -0
- data/lib/pry/core_extensions.rb +31 -21
- data/lib/pry/editor.rb +107 -103
- data/lib/pry/exceptions.rb +77 -0
- data/lib/pry/helpers/base_helpers.rb +22 -109
- data/lib/pry/helpers/command_helpers.rb +10 -8
- data/lib/pry/helpers/documentation_helpers.rb +1 -2
- data/lib/pry/helpers/text.rb +4 -5
- data/lib/pry/history.rb +46 -45
- data/lib/pry/history_array.rb +6 -1
- data/lib/pry/hooks.rb +9 -29
- data/lib/pry/indent.rb +6 -6
- data/lib/pry/input_completer.rb +242 -0
- data/lib/pry/input_lock.rb +132 -0
- data/lib/pry/inspector.rb +27 -0
- data/lib/pry/last_exception.rb +61 -0
- data/lib/pry/method.rb +82 -87
- data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +41 -38
- data/lib/pry/module_candidate.rb +4 -14
- data/lib/pry/object_path.rb +82 -0
- data/lib/pry/output.rb +50 -0
- data/lib/pry/pager.rb +193 -48
- data/lib/pry/plugins.rb +1 -1
- data/lib/pry/prompt.rb +26 -0
- data/lib/pry/pry_class.rb +149 -230
- data/lib/pry/pry_instance.rb +302 -413
- data/lib/pry/rbx_path.rb +1 -1
- data/lib/pry/repl.rb +202 -0
- data/lib/pry/repl_file_loader.rb +20 -26
- data/lib/pry/rubygem.rb +13 -5
- data/lib/pry/terminal.rb +2 -1
- data/lib/pry/test/helper.rb +26 -41
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +45 -59
- metadata +62 -225
- data/.document +0 -2
- data/.gitignore +0 -16
- data/.travis.yml +0 -25
- data/.yardopts +0 -1
- data/CHANGELOG +0 -534
- data/CONTRIBUTORS +0 -55
- data/Gemfile +0 -12
- data/Rakefile +0 -140
- data/TODO +0 -117
- data/lib/pry/completion.rb +0 -321
- data/lib/pry/custom_completions.rb +0 -6
- data/lib/pry/rbx_method.rb +0 -13
- data/man/pry.1 +0 -195
- data/man/pry.1.html +0 -204
- data/man/pry.1.ronn +0 -141
- data/pry.gemspec +0 -29
- data/spec/Procfile +0 -3
- data/spec/cli_spec.rb +0 -78
- data/spec/code_object_spec.rb +0 -277
- data/spec/code_spec.rb +0 -219
- data/spec/command_helpers_spec.rb +0 -29
- data/spec/command_integration_spec.rb +0 -644
- data/spec/command_set_spec.rb +0 -627
- data/spec/command_spec.rb +0 -821
- data/spec/commands/amend_line_spec.rb +0 -247
- data/spec/commands/bang_spec.rb +0 -19
- data/spec/commands/cat_spec.rb +0 -164
- data/spec/commands/cd_spec.rb +0 -250
- data/spec/commands/disable_pry_spec.rb +0 -25
- data/spec/commands/edit_spec.rb +0 -727
- data/spec/commands/exit_all_spec.rb +0 -34
- data/spec/commands/exit_program_spec.rb +0 -19
- data/spec/commands/exit_spec.rb +0 -34
- data/spec/commands/find_method_spec.rb +0 -70
- data/spec/commands/gem_list_spec.rb +0 -26
- data/spec/commands/gist_spec.rb +0 -79
- data/spec/commands/help_spec.rb +0 -56
- data/spec/commands/hist_spec.rb +0 -181
- data/spec/commands/jump_to_spec.rb +0 -15
- data/spec/commands/ls_spec.rb +0 -181
- data/spec/commands/play_spec.rb +0 -140
- data/spec/commands/raise_up_spec.rb +0 -56
- data/spec/commands/save_file_spec.rb +0 -177
- data/spec/commands/show_doc_spec.rb +0 -510
- data/spec/commands/show_input_spec.rb +0 -17
- data/spec/commands/show_source_spec.rb +0 -782
- data/spec/commands/whereami_spec.rb +0 -203
- data/spec/completion_spec.rb +0 -241
- data/spec/control_d_handler_spec.rb +0 -58
- data/spec/documentation_helper_spec.rb +0 -73
- data/spec/editor_spec.rb +0 -79
- data/spec/exception_whitelist_spec.rb +0 -21
- data/spec/fixtures/candidate_helper1.rb +0 -11
- data/spec/fixtures/candidate_helper2.rb +0 -8
- data/spec/fixtures/example.erb +0 -5
- data/spec/fixtures/example_nesting.rb +0 -33
- data/spec/fixtures/show_source_doc_examples.rb +0 -15
- data/spec/fixtures/testrc +0 -2
- data/spec/fixtures/testrcbad +0 -2
- data/spec/fixtures/whereami_helper.rb +0 -6
- data/spec/helper.rb +0 -34
- data/spec/helpers/bacon.rb +0 -86
- data/spec/helpers/mock_pry.rb +0 -43
- data/spec/helpers/table_spec.rb +0 -105
- data/spec/history_array_spec.rb +0 -67
- data/spec/hooks_spec.rb +0 -522
- data/spec/indent_spec.rb +0 -301
- data/spec/input_stack_spec.rb +0 -90
- data/spec/method_spec.rb +0 -482
- data/spec/prompt_spec.rb +0 -60
- data/spec/pry_defaults_spec.rb +0 -419
- data/spec/pry_history_spec.rb +0 -99
- data/spec/pry_output_spec.rb +0 -95
- data/spec/pry_spec.rb +0 -515
- data/spec/run_command_spec.rb +0 -25
- data/spec/sticky_locals_spec.rb +0 -157
- data/spec/syntax_checking_spec.rb +0 -81
- data/spec/wrapped_module_spec.rb +0 -261
- data/wiki/Customizing-pry.md +0 -397
- data/wiki/Home.md +0 -4
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'pry/commands/ls/jruby_hacks'
|
2
|
+
|
3
|
+
module Pry::Command::Ls::MethodsHelper
|
4
|
+
|
5
|
+
include Pry::Command::Ls::JRubyHacks
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
# Get all the methods that we'll want to output.
|
10
|
+
def all_methods(instance_methods = false)
|
11
|
+
methods = if instance_methods || @instance_methods_switch
|
12
|
+
Pry::Method.all_from_class(@interrogatee)
|
13
|
+
else
|
14
|
+
Pry::Method.all_from_obj(@interrogatee)
|
15
|
+
end
|
16
|
+
|
17
|
+
if Pry::Helpers::BaseHelpers.jruby? && !@jruby_switch
|
18
|
+
methods = trim_jruby_aliases(methods)
|
19
|
+
end
|
20
|
+
|
21
|
+
methods.select { |method| @ppp_switch || method.visibility == :public }
|
22
|
+
end
|
23
|
+
|
24
|
+
def resolution_order
|
25
|
+
if @instance_methods_switch
|
26
|
+
Pry::Method.instance_resolution_order(@interrogatee)
|
27
|
+
else
|
28
|
+
Pry::Method.resolution_order(@interrogatee)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def format(methods)
|
33
|
+
methods.sort_by(&:name).map do |method|
|
34
|
+
if method.name == 'method_missing'
|
35
|
+
color(:method_missing, 'method_missing')
|
36
|
+
elsif method.visibility == :private
|
37
|
+
color(:private_method, method.name)
|
38
|
+
elsif method.visibility == :protected
|
39
|
+
color(:protected_method, method.name)
|
40
|
+
else
|
41
|
+
color(:public_method, method.name)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'pry/commands/ls/interrogatable'
|
2
|
+
require 'pry/commands/ls/methods_helper'
|
3
|
+
|
4
|
+
class Pry
|
5
|
+
class Command::Ls < Pry::ClassCommand
|
6
|
+
class SelfMethods < Pry::Command::Ls::Formatter
|
7
|
+
include Pry::Command::Ls::Interrogatable
|
8
|
+
include Pry::Command::Ls::MethodsHelper
|
9
|
+
|
10
|
+
def initialize(interrogatee, no_user_opts, opts, _pry_)
|
11
|
+
super(_pry_)
|
12
|
+
@interrogatee = interrogatee
|
13
|
+
@no_user_opts = no_user_opts
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_self
|
17
|
+
methods = all_methods(true).select do |m|
|
18
|
+
m.owner == @interrogatee && grep.regexp[m.name]
|
19
|
+
end
|
20
|
+
heading = "#{ Pry::WrappedModule.new(@interrogatee).method_prefix }methods"
|
21
|
+
output_section(heading, format(methods))
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def correct_opts?
|
27
|
+
@no_user_opts && interrogating_a_module?
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pry/commands/play.rb
CHANGED
@@ -2,7 +2,7 @@ class Pry
|
|
2
2
|
class Command::Play < Pry::ClassCommand
|
3
3
|
match 'play'
|
4
4
|
group 'Editing'
|
5
|
-
description 'Playback a string variable
|
5
|
+
description 'Playback a string variable, method, line, or file as input.'
|
6
6
|
|
7
7
|
banner <<-'BANNER'
|
8
8
|
Usage: play [OPTIONS] [--help]
|
@@ -10,10 +10,15 @@ class Pry
|
|
10
10
|
The play command enables you to replay code from files and methods as if they
|
11
11
|
were entered directly in the Pry REPL.
|
12
12
|
|
13
|
-
play --lines 149..153
|
14
|
-
play -i 20 --lines 1..3
|
15
|
-
play
|
16
|
-
play
|
13
|
+
play --lines 149..153 # assumes current context
|
14
|
+
play -i 20 --lines 1..3 # assumes lines of the input expression at 20
|
15
|
+
play -o 4 # the output of of an expression at 4
|
16
|
+
play Pry#repl -l 1..-1 # play the contents of Pry#repl method
|
17
|
+
play -e 2 # play from specified line until end of valid expression
|
18
|
+
play hello.rb # play a file
|
19
|
+
play Rakefile -l 5 # play line 5 of a file
|
20
|
+
play -d hi # play documentation of hi method
|
21
|
+
play hi --open # play hi method and leave it open
|
17
22
|
|
18
23
|
https://github.com/pry/pry/wiki/User-Input#wiki-Play
|
19
24
|
BANNER
|
@@ -21,23 +26,52 @@ class Pry
|
|
21
26
|
def options(opt)
|
22
27
|
CodeCollector.inject_options(opt)
|
23
28
|
|
24
|
-
opt.on :open, 'Plays the
|
25
|
-
'
|
26
|
-
' can then be used to
|
29
|
+
opt.on :open, 'Plays the selected content except the last line. Useful' \
|
30
|
+
' for replaying methods and leaving the method definition' \
|
31
|
+
' "open". `amend-line` can then be used to' \
|
32
|
+
' modify the method.'
|
33
|
+
|
34
|
+
opt.on :e, :expression=, 'Executes until end of valid expression', :as => Integer
|
35
|
+
opt.on :p, :print, 'Prints executed code'
|
27
36
|
end
|
28
37
|
|
29
38
|
def process
|
30
39
|
@cc = CodeCollector.new(args, opts, _pry_)
|
31
40
|
|
32
41
|
perform_play
|
33
|
-
|
42
|
+
show_input
|
34
43
|
end
|
35
44
|
|
36
45
|
def perform_play
|
37
|
-
eval_string <<
|
46
|
+
eval_string << content_after_options
|
38
47
|
run "fix-indent"
|
39
48
|
end
|
40
49
|
|
50
|
+
def show_input
|
51
|
+
if opts.present?(:print) or !Pry::Code.complete_expression?(eval_string)
|
52
|
+
run "show-input"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def content_after_options
|
58
|
+
if opts.present?(:open)
|
59
|
+
restrict_to_lines(content, (0..-2))
|
60
|
+
elsif opts.present?(:expression)
|
61
|
+
content_at_expression
|
62
|
+
else
|
63
|
+
content
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def content_at_expression
|
68
|
+
code_object.expression_at(opts[:expression])
|
69
|
+
end
|
70
|
+
|
71
|
+
def code_object
|
72
|
+
Pry::Code.new(content)
|
73
|
+
end
|
74
|
+
|
41
75
|
def should_use_default_file?
|
42
76
|
!args.first && !opts.present?(:in) && !opts.present?(:out)
|
43
77
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Pry
|
2
2
|
# N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
|
3
3
|
class Command::RaiseUp < Pry::ClassCommand
|
4
|
-
match
|
4
|
+
match(/raise-up(!?\b.*)/)
|
5
5
|
group 'Context'
|
6
6
|
description 'Raise an exception out of the current pry instance.'
|
7
7
|
command_options :listing => 'raise-up'
|
@@ -22,7 +22,7 @@ class Pry
|
|
22
22
|
BANNER
|
23
23
|
|
24
24
|
def process
|
25
|
-
return
|
25
|
+
return _pry.pager.page help if captures[0] =~ /(-h|--help)\b/
|
26
26
|
# Handle 'raise-up', 'raise-up "foo"', 'raise-up RuntimeError, 'farble' in a rubyesque manner
|
27
27
|
target.eval("_pry_.raise_up#{captures[0]}")
|
28
28
|
end
|
@@ -10,19 +10,17 @@ class Pry
|
|
10
10
|
e.g reload-code MyClass#my_method #=> reload a method
|
11
11
|
reload-code MyClass #=> reload a class
|
12
12
|
reload-code my-command #=> reload a pry command
|
13
|
-
reload-code self #=> reload the
|
14
|
-
reload-code #=>
|
13
|
+
reload-code self #=> reload the current object
|
14
|
+
reload-code #=> reload the current file or object
|
15
15
|
BANNER
|
16
16
|
|
17
17
|
def process
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
reload_current_file
|
18
|
+
if !args.empty?
|
19
|
+
reload_object(args.join(" "))
|
20
|
+
elsif internal_binding?(target)
|
21
|
+
reload_object("self")
|
23
22
|
else
|
24
|
-
|
25
|
-
reload_code_object(code_object)
|
23
|
+
reload_current_file
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
@@ -41,21 +39,20 @@ class Pry
|
|
41
39
|
output.puts "The current file: #{current_file} was reloaded!"
|
42
40
|
end
|
43
41
|
|
44
|
-
def
|
45
|
-
|
42
|
+
def reload_object(identifier)
|
43
|
+
code_object = Pry::CodeObject.lookup(identifier, _pry_)
|
44
|
+
check_for_reloadability(code_object, identifier)
|
46
45
|
load code_object.source_file
|
47
|
-
output.puts "#{
|
48
|
-
end
|
49
|
-
|
50
|
-
def obj_name
|
51
|
-
@obj_name ||= args.join(" ")
|
46
|
+
output.puts "#{identifier} was reloaded!"
|
52
47
|
end
|
53
48
|
|
54
|
-
def check_for_reloadability(code_object)
|
49
|
+
def check_for_reloadability(code_object, identifier)
|
55
50
|
if !code_object || !code_object.source_file
|
56
|
-
raise CommandError, "Cannot locate #{
|
51
|
+
raise CommandError, "Cannot locate #{identifier}!"
|
57
52
|
elsif !File.exists?(code_object.source_file)
|
58
|
-
raise CommandError,
|
53
|
+
raise CommandError,
|
54
|
+
"Cannot reload #{identifier} as it has no associated file on disk. " \
|
55
|
+
"File found was: #{code_object.source_file}"
|
59
56
|
end
|
60
57
|
end
|
61
58
|
end
|
data/lib/pry/commands/ri.rb
CHANGED
@@ -23,14 +23,18 @@ class Pry
|
|
23
23
|
subclass = Class.new(RDoc::RI::Driver) # the hard way.
|
24
24
|
|
25
25
|
subclass.class_eval do
|
26
|
+
def initialize(pager, opts)
|
27
|
+
@pager = pager
|
28
|
+
super opts
|
29
|
+
end
|
26
30
|
def page
|
27
31
|
paging_text = StringIO.new
|
28
32
|
yield paging_text
|
29
|
-
|
33
|
+
@pager.page(paging_text.string)
|
30
34
|
end
|
31
35
|
|
32
36
|
def formatter(io)
|
33
|
-
if @formatter_klass
|
37
|
+
if @formatter_klass
|
34
38
|
@formatter_klass.new
|
35
39
|
else
|
36
40
|
RDoc::Markup::ToAnsi.new
|
@@ -42,7 +46,7 @@ class Pry
|
|
42
46
|
end
|
43
47
|
|
44
48
|
# Spin-up an RI insance.
|
45
|
-
ri = RDoc::RI::PryDriver.new :use_stdout => true, :interactive => false
|
49
|
+
ri = RDoc::RI::PryDriver.new _pry_.pager, :use_stdout => true, :interactive => false
|
46
50
|
|
47
51
|
begin
|
48
52
|
ri.display_names [spec] # Get the documentation (finally!)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Pry
|
2
2
|
class Command::ShellCommand < Pry::ClassCommand
|
3
|
-
match
|
3
|
+
match(/\.(.*)/)
|
4
4
|
group 'Input and Output'
|
5
5
|
description "All text following a '.' is forwarded to the shell."
|
6
6
|
command_options :listing => '.<shell command>', :use_prefix => false,
|
@@ -16,27 +16,32 @@ class Pry
|
|
16
16
|
BANNER
|
17
17
|
|
18
18
|
def process(cmd)
|
19
|
-
if cmd =~ /^cd\s
|
20
|
-
|
21
|
-
begin
|
22
|
-
Dir.chdir File.expand_path(dest)
|
23
|
-
rescue Errno::ENOENT
|
24
|
-
raise CommandError, "No such directory: #{dest}"
|
25
|
-
end
|
19
|
+
if cmd =~ /^cd\s*(.*)/i
|
20
|
+
process_cd parse_destination($1)
|
26
21
|
else
|
27
22
|
pass_block(cmd)
|
28
|
-
|
29
23
|
if command_block
|
30
24
|
command_block.call `#{cmd}`
|
31
25
|
else
|
32
|
-
|
26
|
+
_pry_.config.system.call(output, cmd, _pry_)
|
33
27
|
end
|
34
28
|
end
|
35
29
|
end
|
36
30
|
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
private
|
32
|
+
|
33
|
+
def parse_destination(dest)
|
34
|
+
return "~" if dest.empty?
|
35
|
+
return dest unless dest == "-"
|
36
|
+
state.old_pwd || raise(CommandError, "No prior directory available")
|
37
|
+
end
|
38
|
+
|
39
|
+
def process_cd(dest)
|
40
|
+
state.old_pwd = Dir.pwd
|
41
|
+
Dir.chdir File.expand_path(dest)
|
42
|
+
rescue Errno::ENOENT
|
43
|
+
raise CommandError, "No such directory: #{dest}"
|
44
|
+
end
|
40
45
|
end
|
41
46
|
|
42
47
|
Pry::Commands.add_command(Pry::Command::ShellCommand)
|
@@ -12,12 +12,10 @@ class Pry
|
|
12
12
|
case _pry_.prompt
|
13
13
|
when Pry::SHELL_PROMPT
|
14
14
|
_pry_.pop_prompt
|
15
|
-
_pry_.custom_completions =
|
15
|
+
_pry_.custom_completions = _pry_.config.file_completions
|
16
16
|
else
|
17
17
|
_pry_.push_prompt Pry::SHELL_PROMPT
|
18
|
-
_pry_.custom_completions =
|
19
|
-
Readline.completion_proc = Pry::InputCompleter.build_completion_proc target,
|
20
|
-
_pry_.instance_eval(&Pry::FILE_COMPLETIONS)
|
18
|
+
_pry_.custom_completions = _pry_.config.command_completions
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -2,18 +2,13 @@ class Pry
|
|
2
2
|
class Command::ShowInfo < Pry::ClassCommand
|
3
3
|
extend Pry::Helpers::BaseHelpers
|
4
4
|
|
5
|
-
command_options :shellwords => false
|
6
|
-
command_options :requires_gem => "ruby18_source_location" if mri_18?
|
7
|
-
|
8
|
-
def setup
|
9
|
-
require 'ruby18_source_location' if mri_18?
|
10
|
-
end
|
5
|
+
command_options :shellwords => false, :interpolate => false
|
11
6
|
|
12
7
|
def options(opt)
|
13
8
|
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors", :as => :count
|
14
9
|
opt.on :l, "line-numbers", "Show line numbers"
|
15
10
|
opt.on :b, "base-one", "Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)"
|
16
|
-
opt.on :a, :all,
|
11
|
+
opt.on :a, :all, "Show all definitions and monkeypatches of the module/class"
|
17
12
|
end
|
18
13
|
|
19
14
|
def process
|
@@ -32,7 +27,7 @@ class Pry
|
|
32
27
|
end
|
33
28
|
|
34
29
|
set_file_and_dir_locals(code_object.source_file)
|
35
|
-
|
30
|
+
_pry_.pager.page result
|
36
31
|
end
|
37
32
|
|
38
33
|
# This method checks whether the `code_object` is a WrappedModule,
|
@@ -63,7 +58,7 @@ class Pry
|
|
63
58
|
end
|
64
59
|
|
65
60
|
def content_and_header_for_code_object(code_object)
|
66
|
-
header(code_object)
|
61
|
+
header(code_object) << content_for(code_object)
|
67
62
|
end
|
68
63
|
|
69
64
|
def content_and_headers_for_all_module_candidates(mod)
|
@@ -95,7 +90,7 @@ class Pry
|
|
95
90
|
h << code_object_header(code_object, line_num)
|
96
91
|
h << "\n#{Pry::Helpers::Text.bold('Number of lines:')} " <<
|
97
92
|
"#{content_for(code_object).lines.count}\n\n"
|
98
|
-
h << Helpers::Text.bold('** Warning:')
|
93
|
+
h << Helpers::Text.bold('** Warning:') << " Cannot find code for #{@original_code_object.nonblank_name}. Showing superclass #{code_object.nonblank_name} instead. **\n\n" if @used_super
|
99
94
|
h
|
100
95
|
end
|
101
96
|
|
@@ -128,7 +123,7 @@ class Pry
|
|
128
123
|
h << " #{text.bold('name:')} #{code_object.nonblank_name}"
|
129
124
|
|
130
125
|
if code_object.number_of_candidates > 1
|
131
|
-
h << (text.bold("\nNumber of monkeypatches: ")
|
126
|
+
h << (text.bold("\nNumber of monkeypatches: ") << code_object.number_of_candidates.to_s)
|
132
127
|
h << ". Use the `-a` option to display all available monkeypatches"
|
133
128
|
end
|
134
129
|
h
|
@@ -155,7 +150,7 @@ class Pry
|
|
155
150
|
end
|
156
151
|
|
157
152
|
def obj_name
|
158
|
-
@obj_name ||= args.empty? ? nil : args.join(
|
153
|
+
@obj_name ||= args.empty? ? nil : args.join(' ')
|
159
154
|
end
|
160
155
|
|
161
156
|
def use_line_numbers?
|
@@ -186,7 +181,7 @@ class Pry
|
|
186
181
|
prefix, search = [$1, $2]
|
187
182
|
methods = begin
|
188
183
|
Pry::Method.all_from_class(binding.eval(prefix))
|
189
|
-
rescue RescuableException
|
184
|
+
rescue RescuableException
|
190
185
|
return super
|
191
186
|
end
|
192
187
|
methods.map do |method|
|
@@ -18,17 +18,29 @@ class Pry
|
|
18
18
|
show-source Pry#rep # source for Pry#rep method
|
19
19
|
show-source Pry # for Pry class
|
20
20
|
show-source Pry -a # for all Pry class definitions (all monkey patches)
|
21
|
+
show-source Pry.foo -e # for class of the return value of expression `Pry.foo`
|
21
22
|
show-source Pry --super # for superclass of Pry (Object class)
|
22
23
|
|
23
24
|
https://github.com/pry/pry/wiki/Source-browsing#wiki-Show_method
|
24
25
|
BANNER
|
25
26
|
|
27
|
+
def options(opt)
|
28
|
+
opt.on :e, :eval, "evaluate the command's argument as a ruby expression and show the class its return value"
|
29
|
+
super(opt)
|
30
|
+
end
|
31
|
+
|
32
|
+
def process
|
33
|
+
if opts.present?(:e)
|
34
|
+
obj = target.eval(args.first)
|
35
|
+
self.args = Array.new(1) { Module === obj ? obj.name : obj.class.name }
|
36
|
+
end
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
26
40
|
# The source for code_object prepared for display.
|
27
41
|
def content_for(code_object)
|
28
|
-
cannot_locate_source_error if !code_object.source
|
29
|
-
|
30
42
|
Code.new(code_object.source, start_line_for(code_object)).
|
31
|
-
with_line_numbers(use_line_numbers?)
|
43
|
+
with_line_numbers(use_line_numbers?)
|
32
44
|
end
|
33
45
|
end
|
34
46
|
|