pry 0.10.2-i386-mswin32 → 1.0.0.pre1-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +2 -0
- data/.gitignore +16 -0
- data/.travis.yml +21 -0
- data/.yardopts +3 -0
- data/CHANGELOG +503 -0
- data/CONTRIBUTORS +55 -0
- data/Gemfile +9 -0
- data/Guardfile +62 -0
- data/LICENSE +2 -2
- data/{README.md → README.markdown} +31 -37
- data/Rakefile +144 -0
- data/TODO +117 -0
- data/lib/pry.rb +146 -33
- data/lib/pry/cli.rb +13 -35
- data/lib/pry/code.rb +63 -24
- data/lib/pry/code/loc.rb +2 -2
- data/lib/pry/code_object.rb +21 -40
- data/lib/pry/command.rb +6 -9
- data/lib/pry/command_set.rb +37 -80
- data/lib/pry/commands.rb +1 -1
- data/lib/pry/commands/amend_line.rb +1 -1
- data/lib/pry/commands/bang.rb +1 -1
- data/lib/pry/commands/cat.rb +2 -11
- data/lib/pry/commands/cat/abstract_formatter.rb +1 -1
- data/lib/pry/commands/cat/exception_formatter.rb +7 -6
- data/lib/pry/commands/cat/file_formatter.rb +32 -15
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/cd.rb +3 -14
- data/lib/pry/commands/code_collector.rb +4 -4
- data/lib/pry/commands/easter_eggs.rb +3 -3
- data/lib/pry/commands/edit.rb +22 -10
- data/lib/pry/commands/edit/exception_patcher.rb +1 -1
- data/lib/pry/commands/edit/file_and_line_locator.rb +2 -0
- data/lib/pry/{method/patcher.rb → commands/edit/method_patcher.rb} +37 -40
- data/lib/pry/commands/find_method.rb +22 -16
- data/lib/pry/commands/gem_install.rb +2 -5
- data/lib/pry/commands/gem_open.rb +1 -1
- data/lib/pry/commands/gist.rb +11 -10
- data/lib/pry/commands/help.rb +14 -14
- data/lib/pry/commands/hist.rb +5 -24
- data/lib/pry/commands/ls.rb +287 -56
- data/lib/pry/commands/play.rb +10 -44
- data/lib/pry/commands/pry_backtrace.rb +2 -1
- data/lib/pry/commands/raise_up.rb +1 -1
- data/lib/pry/commands/reload_code.rb +15 -31
- data/lib/pry/commands/ri.rb +3 -7
- data/lib/pry/commands/shell_command.rb +12 -17
- data/lib/pry/commands/shell_mode.rb +2 -2
- data/lib/pry/commands/show_doc.rb +0 -5
- data/lib/pry/commands/show_info.rb +10 -11
- data/lib/pry/commands/show_source.rb +3 -15
- data/lib/pry/commands/simple_prompt.rb +1 -1
- data/lib/pry/commands/toggle_color.rb +4 -8
- data/lib/pry/commands/whereami.rb +10 -18
- data/lib/pry/completion.rb +293 -0
- data/lib/pry/config.rb +233 -20
- data/lib/pry/core_extensions.rb +19 -29
- data/lib/pry/custom_completions.rb +6 -0
- data/lib/pry/editor.rb +103 -109
- data/lib/pry/helpers/base_helpers.rb +109 -22
- data/lib/pry/helpers/command_helpers.rb +8 -10
- data/lib/pry/helpers/documentation_helpers.rb +2 -1
- data/lib/pry/helpers/text.rb +5 -4
- data/lib/pry/history.rb +10 -21
- data/lib/pry/history_array.rb +0 -5
- data/lib/pry/hooks.rb +29 -9
- data/lib/pry/indent.rb +10 -5
- data/lib/pry/method.rb +86 -81
- data/lib/pry/method/weird_method_locator.rb +2 -4
- data/lib/pry/module_candidate.rb +14 -5
- data/lib/pry/pager.rb +48 -193
- data/lib/pry/plugins.rb +2 -2
- data/lib/pry/pry_class.rb +193 -104
- data/lib/pry/pry_instance.rb +154 -152
- data/lib/pry/rbx_method.rb +13 -0
- data/lib/pry/rbx_path.rb +1 -1
- data/lib/pry/repl.rb +14 -17
- data/lib/pry/repl_file_loader.rb +3 -8
- data/lib/pry/rubygem.rb +3 -3
- data/lib/pry/terminal.rb +3 -4
- data/lib/pry/test/helper.rb +11 -6
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +56 -49
- data/man/pry.1 +195 -0
- data/man/pry.1.html +204 -0
- data/man/pry.1.ronn +141 -0
- data/pry.gemspec +31 -0
- data/spec/Procfile +3 -0
- data/spec/cli_spec.rb +78 -0
- data/spec/code_object_spec.rb +277 -0
- data/spec/code_spec.rb +219 -0
- data/spec/command_helpers_spec.rb +29 -0
- data/spec/command_integration_spec.rb +562 -0
- data/spec/command_set_spec.rb +627 -0
- data/spec/command_spec.rb +821 -0
- data/spec/commands/amend_line_spec.rb +247 -0
- data/spec/commands/bang_spec.rb +18 -0
- data/spec/commands/cat_spec.rb +164 -0
- data/spec/commands/cd_spec.rb +250 -0
- data/spec/commands/disable_pry_spec.rb +25 -0
- data/spec/commands/edit_spec.rb +725 -0
- data/spec/commands/exit_all_spec.rb +27 -0
- data/spec/commands/exit_program_spec.rb +19 -0
- data/spec/commands/exit_spec.rb +28 -0
- data/spec/commands/find_method_spec.rb +70 -0
- data/spec/commands/gem_list_spec.rb +26 -0
- data/spec/commands/gist_spec.rb +79 -0
- data/spec/commands/help_spec.rb +56 -0
- data/spec/commands/hist_spec.rb +172 -0
- data/spec/commands/jump_to_spec.rb +15 -0
- data/spec/commands/ls_spec.rb +189 -0
- data/spec/commands/play_spec.rb +136 -0
- data/spec/commands/raise_up_spec.rb +56 -0
- data/spec/commands/save_file_spec.rb +177 -0
- data/spec/commands/show_doc_spec.rb +488 -0
- data/spec/commands/show_input_spec.rb +17 -0
- data/spec/commands/show_source_spec.rb +760 -0
- data/spec/commands/whereami_spec.rb +203 -0
- data/spec/completion_spec.rb +221 -0
- data/spec/control_d_handler_spec.rb +62 -0
- data/spec/documentation_helper_spec.rb +73 -0
- data/spec/editor_spec.rb +79 -0
- data/spec/exception_whitelist_spec.rb +21 -0
- data/spec/fixtures/candidate_helper1.rb +11 -0
- data/spec/fixtures/candidate_helper2.rb +8 -0
- data/spec/fixtures/example.erb +5 -0
- data/spec/fixtures/example_nesting.rb +33 -0
- data/spec/fixtures/show_source_doc_examples.rb +15 -0
- data/spec/fixtures/testlinkrc +2 -0
- data/spec/fixtures/testrc +2 -0
- data/spec/fixtures/testrcbad +2 -0
- data/spec/fixtures/whereami_helper.rb +6 -0
- data/spec/helper.rb +35 -0
- data/spec/helpers/bacon.rb +86 -0
- data/spec/helpers/mock_pry.rb +44 -0
- data/spec/helpers/repl_tester.rb +112 -0
- data/spec/helpers/table_spec.rb +105 -0
- data/spec/history_array_spec.rb +67 -0
- data/spec/hooks_spec.rb +522 -0
- data/spec/indent_spec.rb +301 -0
- data/spec/method_spec.rb +482 -0
- data/spec/prompt_spec.rb +61 -0
- data/spec/pry_defaults_spec.rb +420 -0
- data/spec/pry_history_spec.rb +69 -0
- data/spec/pry_output_spec.rb +95 -0
- data/spec/pry_repl_spec.rb +86 -0
- data/spec/pry_spec.rb +394 -0
- data/spec/pryrc_spec.rb +97 -0
- data/spec/run_command_spec.rb +25 -0
- data/spec/sticky_locals_spec.rb +147 -0
- data/spec/syntax_checking_spec.rb +81 -0
- data/spec/wrapped_module_spec.rb +261 -0
- data/wiki/Customizing-pry.md +397 -0
- data/wiki/Home.md +4 -0
- metadata +272 -61
- checksums.yaml +0 -7
- data/CHANGELOG.md +0 -714
- data/lib/pry/code/code_file.rb +0 -103
- data/lib/pry/color_printer.rb +0 -55
- data/lib/pry/commands/change_inspector.rb +0 -27
- data/lib/pry/commands/change_prompt.rb +0 -26
- data/lib/pry/commands/list_inspectors.rb +0 -35
- data/lib/pry/commands/list_prompts.rb +0 -35
- data/lib/pry/commands/ls/constants.rb +0 -47
- data/lib/pry/commands/ls/formatter.rb +0 -49
- data/lib/pry/commands/ls/globals.rb +0 -48
- data/lib/pry/commands/ls/grep.rb +0 -21
- data/lib/pry/commands/ls/instance_vars.rb +0 -39
- data/lib/pry/commands/ls/interrogatable.rb +0 -18
- data/lib/pry/commands/ls/jruby_hacks.rb +0 -49
- data/lib/pry/commands/ls/local_names.rb +0 -35
- data/lib/pry/commands/ls/local_vars.rb +0 -39
- data/lib/pry/commands/ls/ls_entity.rb +0 -70
- data/lib/pry/commands/ls/methods.rb +0 -57
- data/lib/pry/commands/ls/methods_helper.rb +0 -46
- data/lib/pry/commands/ls/self_methods.rb +0 -32
- data/lib/pry/commands/watch_expression.rb +0 -105
- data/lib/pry/commands/watch_expression/expression.rb +0 -38
- data/lib/pry/config/behavior.rb +0 -139
- data/lib/pry/config/convenience.rb +0 -25
- data/lib/pry/config/default.rb +0 -161
- data/lib/pry/exceptions.rb +0 -78
- data/lib/pry/input_completer.rb +0 -242
- data/lib/pry/input_lock.rb +0 -132
- data/lib/pry/inspector.rb +0 -27
- data/lib/pry/last_exception.rb +0 -61
- data/lib/pry/object_path.rb +0 -82
- data/lib/pry/output.rb +0 -50
- data/lib/pry/prompt.rb +0 -26
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 or a method or a file as input.'
|
6
6
|
|
7
7
|
banner <<-'BANNER'
|
8
8
|
Usage: play [OPTIONS] [--help]
|
@@ -10,15 +10,10 @@ 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
|
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
|
13
|
+
play --lines 149..153
|
14
|
+
play -i 20 --lines 1..3
|
15
|
+
play Pry#repl --lines 1..-1
|
16
|
+
play Rakefile --lines 5
|
22
17
|
|
23
18
|
https://github.com/pry/pry/wiki/User-Input#wiki-Play
|
24
19
|
BANNER
|
@@ -26,52 +21,23 @@ class Pry
|
|
26
21
|
def options(opt)
|
27
22
|
CodeCollector.inject_options(opt)
|
28
23
|
|
29
|
-
opt.on :open, 'Plays the
|
30
|
-
' for replaying methods and leaving the method definition' \
|
31
|
-
'
|
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'
|
24
|
+
opt.on :open, 'Plays the select content except except' \
|
25
|
+
' the last line. Useful for replaying methods and leaving the method definition "open". `amend-line`' \
|
26
|
+
' can then be used to modify the method.'
|
36
27
|
end
|
37
28
|
|
38
29
|
def process
|
39
30
|
@cc = CodeCollector.new(args, opts, _pry_)
|
40
31
|
|
41
32
|
perform_play
|
42
|
-
|
33
|
+
run "show-input" unless Pry::Code.complete_expression?(eval_string)
|
43
34
|
end
|
44
35
|
|
45
36
|
def perform_play
|
46
|
-
eval_string <<
|
37
|
+
eval_string << (opts.present?(:open) ? restrict_to_lines(content, (0..-2)) : content)
|
47
38
|
run "fix-indent"
|
48
39
|
end
|
49
40
|
|
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
|
-
|
75
41
|
def should_use_default_file?
|
76
42
|
!args.first && !opts.present?(:in) && !opts.present?(:out)
|
77
43
|
end
|
@@ -22,7 +22,7 @@ class Pry
|
|
22
22
|
BANNER
|
23
23
|
|
24
24
|
def process
|
25
|
-
return
|
25
|
+
return stagger_output 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,49 +10,33 @@ 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 current object
|
14
|
-
reload-code #=>
|
13
|
+
reload-code self #=> reload the 'current' object
|
14
|
+
reload-code #=> identical to reload-code self
|
15
15
|
BANNER
|
16
16
|
|
17
17
|
def process
|
18
|
-
|
19
|
-
reload_object(args.join(" "))
|
20
|
-
elsif internal_binding?(target)
|
21
|
-
reload_object("self")
|
22
|
-
else
|
23
|
-
reload_current_file
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
18
|
+
code_object = Pry::CodeObject.lookup(obj_name, _pry_)
|
28
19
|
|
29
|
-
|
30
|
-
|
20
|
+
check_for_reloadability(code_object)
|
21
|
+
reload_code_object(code_object)
|
31
22
|
end
|
32
23
|
|
33
|
-
|
34
|
-
if !File.exists?(current_file)
|
35
|
-
raise CommandError, "Current file: #{current_file} cannot be found on disk!"
|
36
|
-
end
|
24
|
+
private
|
37
25
|
|
38
|
-
|
39
|
-
|
26
|
+
def reload_code_object(code_object)
|
27
|
+
load code_object.source_file
|
28
|
+
output.puts "#{obj_name} was reloaded!"
|
40
29
|
end
|
41
30
|
|
42
|
-
def
|
43
|
-
|
44
|
-
check_for_reloadability(code_object, identifier)
|
45
|
-
load code_object.source_file
|
46
|
-
output.puts "#{identifier} was reloaded!"
|
31
|
+
def obj_name
|
32
|
+
@obj_name ||= args.empty? ? "self" : args.join(" ")
|
47
33
|
end
|
48
34
|
|
49
|
-
def check_for_reloadability(code_object
|
50
|
-
if !code_object
|
51
|
-
raise CommandError, "Cannot locate #{
|
35
|
+
def check_for_reloadability(code_object)
|
36
|
+
if !code_object
|
37
|
+
raise CommandError, "Cannot locate #{obj_name}!"
|
52
38
|
elsif !File.exists?(code_object.source_file)
|
53
|
-
raise CommandError,
|
54
|
-
"Cannot reload #{identifier} as it has no associated file on disk. " \
|
55
|
-
"File found was: #{code_object.source_file}"
|
39
|
+
raise CommandError, "Cannot reload #{obj_name} as it has no associated file on disk. File found was: #{code_object.source_file}"
|
56
40
|
end
|
57
41
|
end
|
58
42
|
end
|
data/lib/pry/commands/ri.rb
CHANGED
@@ -23,18 +23,14 @@ 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
|
30
26
|
def page
|
31
27
|
paging_text = StringIO.new
|
32
28
|
yield paging_text
|
33
|
-
|
29
|
+
Pry::Pager.page(paging_text.string)
|
34
30
|
end
|
35
31
|
|
36
32
|
def formatter(io)
|
37
|
-
if @formatter_klass
|
33
|
+
if @formatter_klass then
|
38
34
|
@formatter_klass.new
|
39
35
|
else
|
40
36
|
RDoc::Markup::ToAnsi.new
|
@@ -46,7 +42,7 @@ class Pry
|
|
46
42
|
end
|
47
43
|
|
48
44
|
# Spin-up an RI insance.
|
49
|
-
ri = RDoc::RI::PryDriver.new
|
45
|
+
ri = RDoc::RI::PryDriver.new :use_stdout => true, :interactive => false
|
50
46
|
|
51
47
|
begin
|
52
48
|
ri.display_names [spec] # Get the documentation (finally!)
|
@@ -16,32 +16,27 @@ class Pry
|
|
16
16
|
BANNER
|
17
17
|
|
18
18
|
def process(cmd)
|
19
|
-
if cmd =~ /^cd\s
|
20
|
-
|
19
|
+
if cmd =~ /^cd\s+(.+)/i
|
20
|
+
dest = $1
|
21
|
+
begin
|
22
|
+
Dir.chdir File.expand_path(dest)
|
23
|
+
rescue Errno::ENOENT
|
24
|
+
raise CommandError, "No such directory: #{dest}"
|
25
|
+
end
|
21
26
|
else
|
22
27
|
pass_block(cmd)
|
28
|
+
|
23
29
|
if command_block
|
24
30
|
command_block.call `#{cmd}`
|
25
31
|
else
|
26
|
-
|
32
|
+
Pry.config.system.call(output, cmd, _pry_)
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
37
|
+
def complete(search)
|
38
|
+
super + Bond::Rc.files(search.split(" ").last || '')
|
39
|
+
end
|
45
40
|
end
|
46
41
|
|
47
42
|
Pry::Commands.add_command(Pry::Command::ShellCommand)
|
@@ -12,10 +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::DEFAULT_CUSTOM_COMPLETIONS
|
16
16
|
else
|
17
17
|
_pry_.push_prompt Pry::SHELL_PROMPT
|
18
|
-
_pry_.custom_completions =
|
18
|
+
_pry_.custom_completions = Pry::FILE_COMPLETIONS
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -3,12 +3,17 @@ class Pry
|
|
3
3
|
extend Pry::Helpers::BaseHelpers
|
4
4
|
|
5
5
|
command_options :shellwords => false, :interpolate => 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
|
6
11
|
|
7
12
|
def options(opt)
|
8
13
|
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors", :as => :count
|
9
14
|
opt.on :l, "line-numbers", "Show line numbers"
|
10
15
|
opt.on :b, "base-one", "Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)"
|
11
|
-
opt.on :a, :all,
|
16
|
+
opt.on :a, :all, "Show all definitions and monkeypatches of the module/class"
|
12
17
|
end
|
13
18
|
|
14
19
|
def process
|
@@ -27,7 +32,7 @@ class Pry
|
|
27
32
|
end
|
28
33
|
|
29
34
|
set_file_and_dir_locals(code_object.source_file)
|
30
|
-
|
35
|
+
stagger_output result
|
31
36
|
end
|
32
37
|
|
33
38
|
# This method checks whether the `code_object` is a WrappedModule,
|
@@ -58,7 +63,7 @@ class Pry
|
|
58
63
|
end
|
59
64
|
|
60
65
|
def content_and_header_for_code_object(code_object)
|
61
|
-
header(code_object)
|
66
|
+
header(code_object) + content_for(code_object)
|
62
67
|
end
|
63
68
|
|
64
69
|
def content_and_headers_for_all_module_candidates(mod)
|
@@ -90,7 +95,7 @@ class Pry
|
|
90
95
|
h << code_object_header(code_object, line_num)
|
91
96
|
h << "\n#{Pry::Helpers::Text.bold('Number of lines:')} " <<
|
92
97
|
"#{content_for(code_object).lines.count}\n\n"
|
93
|
-
h << Helpers::Text.bold('** Warning:')
|
98
|
+
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
|
94
99
|
h
|
95
100
|
end
|
96
101
|
|
@@ -121,12 +126,6 @@ class Pry
|
|
121
126
|
h << "@ line #{line_num}:\n"
|
122
127
|
h << text.bold(code_object.module? ? "Module" : "Class")
|
123
128
|
h << " #{text.bold('name:')} #{code_object.nonblank_name}"
|
124
|
-
|
125
|
-
if code_object.number_of_candidates > 1
|
126
|
-
h << (text.bold("\nNumber of monkeypatches: ") << code_object.number_of_candidates.to_s)
|
127
|
-
h << ". Use the `-a` option to display all available monkeypatches"
|
128
|
-
end
|
129
|
-
h
|
130
129
|
end
|
131
130
|
|
132
131
|
def method_sections(code_object)
|
@@ -150,7 +149,7 @@ class Pry
|
|
150
149
|
end
|
151
150
|
|
152
151
|
def obj_name
|
153
|
-
@obj_name ||= args.empty? ? nil : args.join(
|
152
|
+
@obj_name ||= args.empty? ? nil : args.join(" ")
|
154
153
|
end
|
155
154
|
|
156
155
|
def use_line_numbers?
|
@@ -18,29 +18,17 @@ 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`
|
22
21
|
show-source Pry --super # for superclass of Pry (Object class)
|
23
22
|
|
24
23
|
https://github.com/pry/pry/wiki/Source-browsing#wiki-Show_method
|
25
24
|
BANNER
|
26
25
|
|
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
|
-
|
40
26
|
# The source for code_object prepared for display.
|
41
27
|
def content_for(code_object)
|
28
|
+
cannot_locate_source_error if !code_object.source
|
29
|
+
|
42
30
|
Code.new(code_object.source, start_line_for(code_object)).
|
43
|
-
with_line_numbers(use_line_numbers?).
|
31
|
+
with_line_numbers(use_line_numbers?).to_s
|
44
32
|
end
|
45
33
|
end
|
46
34
|
|
@@ -11,14 +11,10 @@ class Pry
|
|
11
11
|
BANNER
|
12
12
|
|
13
13
|
def process
|
14
|
-
|
15
|
-
output.puts "Syntax highlighting #{
|
14
|
+
Pry.color = !Pry.color
|
15
|
+
output.puts "Syntax highlighting #{Pry.color ? "on" : "off"}"
|
16
16
|
end
|
17
|
-
|
18
|
-
def color_toggle
|
19
|
-
!_pry_.color
|
20
|
-
end
|
21
|
-
|
22
|
-
Pry::Commands.add_command(self)
|
23
17
|
end
|
18
|
+
|
19
|
+
Pry::Commands.add_command(Pry::Command::ToggleColor)
|
24
20
|
end
|
@@ -88,10 +88,10 @@ class Pry
|
|
88
88
|
|
89
89
|
set_file_and_dir_locals(@file)
|
90
90
|
|
91
|
-
out = "\n#{text.bold('From:')} #{location}:\n\n"
|
92
|
-
code.with_line_numbers(use_line_numbers?).with_marker(marker).
|
91
|
+
out = "\n#{text.bold('From:')} #{location}:\n\n" +
|
92
|
+
code.with_line_numbers(use_line_numbers?).with_marker(marker).to_s + "\n"
|
93
93
|
|
94
|
-
|
94
|
+
stagger_output(out)
|
95
95
|
end
|
96
96
|
|
97
97
|
private
|
@@ -109,7 +109,7 @@ class Pry
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def top_level?
|
112
|
-
target_self ==
|
112
|
+
target_self == TOPLEVEL_BINDING.eval("self")
|
113
113
|
end
|
114
114
|
|
115
115
|
def handle_internal_binding
|
@@ -144,21 +144,14 @@ class Pry
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
# This either returns the `target_self`
|
148
|
-
# or it returns the class of `target_self` if `target_self` is not a class.
|
149
|
-
# @return [Pry::WrappedModule]
|
150
|
-
def target_class
|
151
|
-
target_self.is_a?(Module) ? Pry::WrappedModule(target_self) :
|
152
|
-
Pry::WrappedModule(target_self.class)
|
153
|
-
end
|
154
|
-
|
155
147
|
def class_code
|
156
148
|
return @class_code if @class_code
|
157
149
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
150
|
+
if valid_method?
|
151
|
+
mod = Pry::WrappedModule(@method.owner)
|
152
|
+
idx = mod.candidates.find_index { |v| expand_path(v.source_file) == @file }
|
153
|
+
@class_code = idx && Pry::Code.from_module(mod, idx)
|
154
|
+
end
|
162
155
|
end
|
163
156
|
|
164
157
|
def valid_method?
|
@@ -178,7 +171,7 @@ class Pry
|
|
178
171
|
|
179
172
|
def window_size
|
180
173
|
if args.empty?
|
181
|
-
|
174
|
+
Pry.config.default_window_size
|
182
175
|
else
|
183
176
|
args.first.to_i
|
184
177
|
end
|
@@ -186,5 +179,4 @@ class Pry
|
|
186
179
|
end
|
187
180
|
|
188
181
|
Pry::Commands.add_command(Pry::Command::Whereami)
|
189
|
-
Pry::Commands.alias_command '@', 'whereami'
|
190
182
|
end
|