pry 0.9.3pre1-i386-mingw32 → 0.9.4-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +53 -0
- data/CONTRIBUTORS +13 -0
- data/README.markdown +4 -2
- data/Rakefile +17 -3
- data/TODO +22 -0
- data/lib/pry.rb +102 -24
- data/lib/pry/command_context.rb +12 -0
- data/lib/pry/command_processor.rb +50 -19
- data/lib/pry/command_set.rb +17 -7
- data/lib/pry/completion.rb +6 -6
- data/lib/pry/config.rb +6 -2
- data/lib/pry/default_commands/basic.rb +8 -4
- data/lib/pry/default_commands/context.rb +84 -36
- data/lib/pry/default_commands/documentation.rb +50 -30
- data/lib/pry/default_commands/easter_eggs.rb +5 -0
- data/lib/pry/default_commands/input.rb +20 -16
- data/lib/pry/default_commands/introspection.rb +61 -77
- data/lib/pry/default_commands/ls.rb +22 -14
- data/lib/pry/default_commands/shell.rb +32 -17
- data/lib/pry/extended_commands/user_command_api.rb +32 -1
- data/lib/pry/helpers/base_helpers.rb +21 -9
- data/lib/pry/helpers/command_helpers.rb +99 -17
- data/lib/pry/helpers/text.rb +12 -11
- data/lib/pry/history.rb +61 -0
- data/lib/pry/plugins.rb +19 -8
- data/lib/pry/pry_class.rb +49 -60
- data/lib/pry/pry_instance.rb +122 -119
- data/lib/pry/version.rb +1 -1
- data/pry.gemspec +15 -14
- data/test/helper.rb +31 -0
- data/test/test_command_processor.rb +8 -87
- data/test/test_command_set.rb +40 -2
- data/test/test_completion.rb +26 -0
- data/test/test_default_commands/test_context.rb +185 -1
- data/test/test_default_commands/test_documentation.rb +10 -0
- data/test/test_default_commands/test_input.rb +39 -13
- data/test/test_default_commands/test_introspection.rb +11 -1
- data/test/test_default_commands/test_shell.rb +18 -0
- data/test/test_pry.rb +217 -47
- data/test/test_pry_history.rb +84 -0
- data/test/test_pry_output.rb +44 -0
- data/test/test_special_locals.rb +35 -0
- metadata +83 -77
data/CHANGELOG
CHANGED
@@ -1,3 +1,56 @@
|
|
1
|
+
8/9/2011 version 0.9.4
|
2
|
+
|
3
|
+
MAJOR NEW FEATURES:
|
4
|
+
- JRuby support, including show-method/edit-method and editor integration on both 1.8 and 1.9 versions
|
5
|
+
- extended cd syntax: cd ../@x/y
|
6
|
+
- play command now works much better with _in_ array (this is a very powerful feature, esp with Pry::NAV_PROMPT)
|
7
|
+
- history saving/loading is now lightning fast
|
8
|
+
- 'edit' (entered by itself) now opens current lines in input buffer in an editor, and evals on exit
|
9
|
+
- 'edit' command is also, in general more intelligent
|
10
|
+
- ls output no longer in array format, and colors can be configured, e.g: Pry.config.ls.ivar_color = :bright_blue
|
11
|
+
- new switch-to command for moving around the binding stack without exiting out of sessions
|
12
|
+
- more sophisticated prompts, Pry::NAV_PROMPT to ease deep spelunking of code
|
13
|
+
- major bug fix for windows systems
|
14
|
+
- much better support for huge objects, should no longer hang pry (see #245)
|
15
|
+
- cat --ex and edit --ex now work better
|
16
|
+
|
17
|
+
complete CHANGELOG:
|
18
|
+
* tempfile should end in .rb (for edit -t)
|
19
|
+
* ls output should not be in array format
|
20
|
+
* fix history saving (should not save all of Readline::HISTORY, but only what changed)
|
21
|
+
* prevent blank lines going to Readline::HISTORY (thanks cirwin!)
|
22
|
+
* ensure that cat --ex emulates the `whereami` format - includes line numbers and formatted the same, etc
|
23
|
+
* fixed bug #200 ( https://github.com/pry/pry/issues/200 )- string interpolation bug (thanks to ryanf)
|
24
|
+
* show-doc and stat now display method visibility (update WIKI)
|
25
|
+
* got rid of warnings caused by stricter ruby 1.9.3 rules
|
26
|
+
* remove interpolation of command names and fix interpolation error messag (update WIKI) (thanks ryanf!)
|
27
|
+
* 'nested sessions' now use binding stacks (so each instance manages its own collection of bindings without spawning other instances)
|
28
|
+
* 'cd ..' just pops a binding off the binding_stack with special behaviour when only one binding in stack - it breaks out of the repl loop
|
29
|
+
* added switch-to command (like jump-to but doesnt unwind the stack)
|
30
|
+
* show-method and show-doc now accept multiple method names
|
31
|
+
* control_d hook added (Pry.config.control_d_handler)
|
32
|
+
* behaviour of ^d is now to break out of current expr if in multi-line expr, or break out of current context if nested, or break out of pry repl loop if at top-level
|
33
|
+
* can no longer interpolate command name itself e.g #{x}-#{y} where x = "show" and y = "doc"
|
34
|
+
* ^C no longer captured
|
35
|
+
* got rid of Pry.active_instance, Pry.last_exception and friends.
|
36
|
+
* also special locals now shared among bindings in a pry instance (i.e _ex_ (and friends) re-injected into new binding entered with 'cd')
|
37
|
+
* renamed inp and out to _in_ and _out_ (to avoid collisions with actual locals in debugging scope)
|
38
|
+
* added third parameter to prompts, the pry instance itself (_pry) see https://github.com/pry/pry/issues/233 for why it's important
|
39
|
+
* cd behaviour when no args performs the same as `cd /`
|
40
|
+
* commands with keep_retval can now return nil (to suppress output now return 'void' instead)
|
41
|
+
* Pry::CommandProcessor::Result introduced
|
42
|
+
* Pry.view_clip() modified to be more robust and properly display Class#name
|
43
|
+
* edit command when invoked with no args now works like edit -t
|
44
|
+
* when edit is invoked (with no args or with -t) inside a multi-line expression input buffer, it dumps that buffer into a temp file and takes you to it
|
45
|
+
* got rid of Pry#null_input? since all that was needed was eval_string.empty?
|
46
|
+
* cd command now supports complex syntax: cd ../@y/y/../z
|
47
|
+
* JRuby is no longer a 2nd class citizen, almost full JRuby support, passing 100% tests
|
48
|
+
* added Pry::NAV_PROMPT (great new navigation prompt, per robgleeson) and Pry::SIMPLE_PRINT for simple (IRB-style) print output (just using inspect)
|
49
|
+
* _pry_ now passed as 3rd parameter to :before_session hook
|
50
|
+
* ls colors now configurable via Pry.config.ls.local_var_color = :bright_red etc
|
51
|
+
* ls separator configurable via, e.g Pry.config.ls.separator = " "
|
52
|
+
* Pry.view_clip() now only calls inspect on a few immediates, otherwise uses the #<> syntax, which has been truncated further to exclude teh mem address, again related to #245
|
53
|
+
|
1
54
|
*/7/2011 version 0.9.3
|
2
55
|
* cat --ex (cats 5 lines above and below line in file where exception was raised)
|
3
56
|
* edit --ex (edits line in file where exception was raised)
|
data/CONTRIBUTORS
ADDED
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
![Alt text](http://dl.dropbox.com/u/
|
1
|
+
![Alt text](http://dl.dropbox.com/u/26521875/pry_logo_350.png)
|
2
2
|
|
3
3
|
(C) John Mair (banisterfiend) 2011
|
4
4
|
|
@@ -6,8 +6,10 @@ _Get to the code_
|
|
6
6
|
|
7
7
|
**Note that JRuby is not yet supported in this release, but will be
|
8
8
|
soon.**
|
9
|
+
|
10
|
+
**Please** [DONATE](http://www.pledgie.com/campaigns/15899) to the Pry project - Pry was a **huge** amount of work and every donation received is encouraging and supports Pry's continued development!
|
9
11
|
|
10
|
-
[Skip to the website](http://pry.github.com) <br />
|
12
|
+
[Skip to the website (recommended)](http://pry.github.com) <br />
|
11
13
|
[Skip to the wiki](https://github.com/pry/pry/wiki)
|
12
14
|
|
13
15
|
Pry is a powerful alternative to the standard IRB shell for Ruby. It is
|
data/Rakefile
CHANGED
@@ -22,8 +22,8 @@ def apply_spec_defaults(s)
|
|
22
22
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
23
23
|
s.add_dependency("ruby_parser",">=2.0.5")
|
24
24
|
s.add_dependency("coderay",">=0.9.8")
|
25
|
-
s.add_dependency("slop","~>1.
|
26
|
-
s.add_dependency("method_source",">=0.6.
|
25
|
+
s.add_dependency("slop","~>2.1.0")
|
26
|
+
s.add_dependency("method_source",">=0.6.5")
|
27
27
|
s.add_development_dependency("bacon",">=1.1.0")
|
28
28
|
s.add_development_dependency("open4", "~>1.0.1")
|
29
29
|
end
|
@@ -62,6 +62,20 @@ namespace :ruby do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
namespace :jruby do
|
66
|
+
spec = Gem::Specification.new do |s|
|
67
|
+
apply_spec_defaults(s)
|
68
|
+
s.add_dependency("spoon", ">=0.0.1")
|
69
|
+
s.platform = "java"
|
70
|
+
end
|
71
|
+
|
72
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
73
|
+
pkg.need_zip = false
|
74
|
+
pkg.need_tar = false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
65
79
|
[:mingw32, :mswin32].each do |v|
|
66
80
|
namespace v do
|
67
81
|
spec = Gem::Specification.new do |s|
|
@@ -78,7 +92,7 @@ end
|
|
78
92
|
end
|
79
93
|
|
80
94
|
desc "build all platform gems at once"
|
81
|
-
task :gems => [:clean, :rmgems, "ruby:gem", "mswin32:gem", "mingw32:gem"]
|
95
|
+
task :gems => [:clean, :rmgems, "ruby:gem", "mswin32:gem", "mingw32:gem", "jruby:gem"]
|
82
96
|
|
83
97
|
desc "remove all platform gems"
|
84
98
|
task :rmgems => ["ruby:clobber_package"]
|
data/TODO
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
0.9.4
|
2
|
+
* include method visiblity in show-doc and stat output
|
3
|
+
* tempfile should end in .rb (for edit -t)
|
4
|
+
* ls output should not be in array format
|
5
|
+
* exceptions should allow access to previous items in the backtrace
|
6
|
+
* input should allow multiple objects which are switched to automatically when EOF is reached on the preceding one
|
7
|
+
* pry -r should happen in pry
|
8
|
+
* more plugin-related commands in pry - see installed ones, see activated ones, see available on rubygems
|
9
|
+
* should also allow plugins be explicitly activated as a command line option
|
10
|
+
* should not raise if plugin activation fails (should show warning instead)
|
11
|
+
* more documentation on CommandContext, etc and also command helpers
|
12
|
+
* fix history saving (should not save all of Readline::HISTORY, but only what changed)
|
13
|
+
* prevent blank lines going to Readline::HISTORY
|
14
|
+
* ensure that cat --ex emulates the `whereami` format - includes line numbers and formatted the same, etc
|
15
|
+
* rename inp and out to _inp_ and _out_ otherwise than can overwrite locals by those names when debugging (not good)
|
16
|
+
* add source file to stat command
|
17
|
+
* make plugins use hash instead of array
|
18
|
+
* ensure edit -t has 'edit' alias (no parameters) and dumps eval_string into buffer
|
19
|
+
* whitelist exceptions
|
20
|
+
* hooks system
|
21
|
+
* jruby shell command support
|
22
|
+
|
1
23
|
0.9.3
|
2
24
|
* hist command now excludes last line of input (the command invocation itself)
|
3
25
|
* hist now has `history` alias
|
data/lib/pry.rb
CHANGED
@@ -6,27 +6,50 @@ require 'pry/helpers/base_helpers'
|
|
6
6
|
class Pry
|
7
7
|
# The default hooks - display messages when beginning and ending Pry sessions.
|
8
8
|
DEFAULT_HOOKS = {
|
9
|
-
:before_session => proc do |out, target|
|
9
|
+
:before_session => proc do |out, target, _pry_|
|
10
10
|
# ensure we're actually in a method
|
11
|
-
meth_name = target.eval('__method__')
|
12
11
|
file = target.eval('__FILE__')
|
13
12
|
|
14
13
|
# /unknown/ for rbx
|
15
14
|
if file !~ /(\(.*\))|<.*>/ && file !~ /__unknown__/ && file != "" && file != "-e"
|
16
|
-
|
15
|
+
_pry_.process_line("whereami 5", "", target)
|
17
16
|
end
|
18
17
|
end
|
19
18
|
}
|
20
19
|
|
21
|
-
# The default
|
20
|
+
# The default print
|
22
21
|
DEFAULT_PRINT = proc do |output, value|
|
22
|
+
stringified = begin
|
23
|
+
value.pretty_inspect
|
24
|
+
rescue RescuableException => ex
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
unless String === stringified
|
29
|
+
# Read the class name off of the singleton class to provide a default inspect.
|
30
|
+
klass = (class << value; self; end).ancestors.first
|
31
|
+
stringified = "#<#{klass}:0x#{value.__id__.to_s(16)}>"
|
32
|
+
Helpers::BaseHelpers.stagger_output("output error: #{ex.inspect}", output) if ex
|
33
|
+
end
|
34
|
+
|
35
|
+
Helpers::BaseHelpers.stagger_output("=> #{Helpers::BaseHelpers.colorize_code(stringified)}", output)
|
36
|
+
end
|
37
|
+
|
38
|
+
# may be convenient when working with enormous objects and
|
39
|
+
# pretty_print is too slow
|
40
|
+
SIMPLE_PRINT = proc do |output, value|
|
23
41
|
begin
|
24
|
-
|
25
|
-
rescue
|
42
|
+
output.puts "=> #{value.inspect}"
|
43
|
+
rescue RescuableException
|
26
44
|
output.puts "=> unknown"
|
27
45
|
end
|
28
46
|
end
|
29
47
|
|
48
|
+
# useful when playing with truly enormous objects
|
49
|
+
CLIPPED_PRINT = proc do |output, value|
|
50
|
+
output.puts "=> #{Pry.view_clip(value)}"
|
51
|
+
end
|
52
|
+
|
30
53
|
# Will only show the first line of the backtrace
|
31
54
|
DEFAULT_EXCEPTION_HANDLER = proc do |output, exception|
|
32
55
|
output.puts "#{exception.class}: #{exception.message}"
|
@@ -35,30 +58,84 @@ class Pry
|
|
35
58
|
|
36
59
|
# The default prompt; includes the target and nesting level
|
37
60
|
DEFAULT_PROMPT = [
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
61
|
+
proc { |target_self, nest_level, _|
|
62
|
+
if nest_level == 0
|
63
|
+
"pry(#{Pry.view_clip(target_self)})> "
|
64
|
+
else
|
65
|
+
"pry(#{Pry.view_clip(target_self)}):#{nest_level}> "
|
66
|
+
end
|
67
|
+
},
|
45
68
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
69
|
+
proc { |target_self, nest_level, _|
|
70
|
+
if nest_level == 0
|
71
|
+
"pry(#{Pry.view_clip(target_self)})* "
|
72
|
+
else
|
73
|
+
"pry(#{Pry.view_clip(target_self)}):#{nest_level}* "
|
74
|
+
end
|
75
|
+
}
|
76
|
+
]
|
77
|
+
|
78
|
+
# Deal with the ^D key being pressed, different behaviour in
|
79
|
+
# different cases:
|
80
|
+
# 1) In an expression - behave like `!` command (clear input buffer)
|
81
|
+
# 2) At top-level session - behave like `exit command (break out of repl loop)
|
82
|
+
# 3) In a nested session - behave like `cd ..` (pop a binding)
|
83
|
+
DEFAULT_CONTROL_D_HANDLER = proc do |eval_string, _pry_|
|
84
|
+
if !eval_string.empty?
|
85
|
+
# clear input buffer
|
86
|
+
eval_string.replace("")
|
87
|
+
elsif _pry_.binding_stack.one?
|
88
|
+
# ^D at top-level breaks out of loop
|
89
|
+
_pry_.binding_stack.clear
|
90
|
+
throw(:breakout)
|
91
|
+
else
|
92
|
+
# otherwise just pops a binding
|
93
|
+
_pry_.binding_stack.pop
|
94
|
+
end
|
95
|
+
end
|
54
96
|
|
55
97
|
# A simple prompt - doesn't display target or nesting level
|
56
98
|
SIMPLE_PROMPT = [proc { ">> " }, proc { " | " }]
|
57
99
|
|
58
100
|
SHELL_PROMPT = [
|
59
|
-
|
60
|
-
|
61
|
-
|
101
|
+
proc { |target_self, _, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },
|
102
|
+
proc { |target_self, _, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} * " }
|
103
|
+
]
|
104
|
+
|
105
|
+
# A prompt that includes the full object path as well as
|
106
|
+
# input/output (_in_ and _out_) information. Good for navigation.
|
107
|
+
NAV_PROMPT = [
|
108
|
+
proc do |_, level, pry|
|
109
|
+
tree = pry.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
|
110
|
+
"[#{pry.input_array.size}] (pry) #{tree}: #{level}> "
|
111
|
+
end,
|
112
|
+
proc do |_, level, pry|
|
113
|
+
tree = pry.binding_stack.map { |b| Pry.view_clip(b.eval("self")) }.join " / "
|
114
|
+
"[#{pry.input_array.size}] (pry) #{tree}: #{level}* "
|
115
|
+
end,
|
116
|
+
]
|
117
|
+
|
118
|
+
|
119
|
+
# As a REPL, we often want to catch any unexpected exceptions that may have
|
120
|
+
# been raised; however we don't want to go overboard and prevent the user
|
121
|
+
# from exiting Pry when they want to.
|
122
|
+
module RescuableException
|
123
|
+
def self.===(exception)
|
124
|
+
case exception
|
125
|
+
# Catch when the user hits ^C (Interrupt < SignalException), and assume
|
126
|
+
# that they just wanted to stop the in-progress command (just like bash etc.)
|
127
|
+
when Interrupt
|
128
|
+
true
|
129
|
+
# Don't catch signals (particularly not SIGTERM) as these are unlikely to be
|
130
|
+
# intended for pry itself. We should also make sure that Kernel#exit works.
|
131
|
+
when SystemExit, SignalException
|
132
|
+
false
|
133
|
+
# All other exceptions will be caught.
|
134
|
+
else
|
135
|
+
true
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
62
139
|
|
63
140
|
end
|
64
141
|
|
@@ -83,6 +160,7 @@ end
|
|
83
160
|
require "pry/version"
|
84
161
|
require "pry/history_array"
|
85
162
|
require "pry/helpers"
|
163
|
+
require "pry/history"
|
86
164
|
require "pry/command_set"
|
87
165
|
require "pry/commands"
|
88
166
|
require "pry/command_context"
|
data/lib/pry/command_context.rb
CHANGED
@@ -2,6 +2,13 @@ class Pry
|
|
2
2
|
# Command contexts are the objects runing each command.
|
3
3
|
# Helper modules can be mixed into this class.
|
4
4
|
class CommandContext
|
5
|
+
|
6
|
+
# represents a void return value for a command
|
7
|
+
VOID_VALUE = Object.new
|
8
|
+
|
9
|
+
# give it a nice inspect
|
10
|
+
def VOID_VALUE.inspect() "void" end
|
11
|
+
|
5
12
|
attr_accessor :output
|
6
13
|
attr_accessor :target
|
7
14
|
attr_accessor :captures
|
@@ -10,6 +17,7 @@ class Pry
|
|
10
17
|
attr_accessor :opts
|
11
18
|
attr_accessor :command_set
|
12
19
|
attr_accessor :command_processor
|
20
|
+
attr_accessor :_pry_
|
13
21
|
|
14
22
|
# Run a command from another command.
|
15
23
|
# @param [String] command_string The string that invokes the command
|
@@ -33,6 +41,10 @@ class Pry
|
|
33
41
|
Pry::Helpers::Text
|
34
42
|
end
|
35
43
|
|
44
|
+
def void
|
45
|
+
VOID_VALUE
|
46
|
+
end
|
47
|
+
|
36
48
|
include Pry::Helpers::BaseHelpers
|
37
49
|
include Pry::Helpers::CommandHelpers
|
38
50
|
end
|
@@ -2,6 +2,36 @@ require 'forwardable'
|
|
2
2
|
|
3
3
|
class Pry
|
4
4
|
class CommandProcessor
|
5
|
+
|
6
|
+
# Wraps the return result of process_commands, indicates if the
|
7
|
+
# result IS a command and what kind of command (e.g void)
|
8
|
+
class Result
|
9
|
+
attr_reader :retval
|
10
|
+
|
11
|
+
def initialize(is_command, keep_retval = false, retval = nil)
|
12
|
+
@is_command, @keep_retval, @retval = is_command, keep_retval, retval
|
13
|
+
end
|
14
|
+
|
15
|
+
# Is the result a command?
|
16
|
+
# @return [Boolean]
|
17
|
+
def command?
|
18
|
+
@is_command
|
19
|
+
end
|
20
|
+
|
21
|
+
# Is the result a command and if it is, is it a void command?
|
22
|
+
# (one that does not return a value)
|
23
|
+
# @return [Boolean]
|
24
|
+
def void_command?
|
25
|
+
(command? && !keep_retval?) || retval == CommandContext::VOID_VALUE
|
26
|
+
end
|
27
|
+
|
28
|
+
# Is the return value kept for this command? (i.e :keep_retval => true)
|
29
|
+
# @return [Boolean]
|
30
|
+
def keep_retval?
|
31
|
+
@keep_retval
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
5
35
|
extend Forwardable
|
6
36
|
|
7
37
|
attr_accessor :pry_instance
|
@@ -10,7 +40,7 @@ class Pry
|
|
10
40
|
@pry_instance = pry_instance
|
11
41
|
end
|
12
42
|
|
13
|
-
def_delegators :@pry_instance, :commands, :
|
43
|
+
def_delegators :@pry_instance, :commands, :output
|
14
44
|
|
15
45
|
# Is the string a valid command?
|
16
46
|
# @param [String] val The string passed in from the Pry prompt.
|
@@ -54,24 +84,17 @@ class Pry
|
|
54
84
|
# @return [Array] The command data and arg string pair
|
55
85
|
def command_matched(val, target)
|
56
86
|
_, cmd_data = commands.commands.find do |name, data|
|
57
|
-
|
58
|
-
prefix = Regexp.escape(Pry.config.command_prefix)
|
87
|
+
prefix = convert_to_regex(Pry.config.command_prefix)
|
59
88
|
prefix = "(?:#{prefix})?" unless data.options[:use_prefix]
|
60
89
|
|
61
90
|
command_regex = /^#{prefix}#{convert_to_regex(name)}(?!\S)/
|
62
91
|
|
63
|
-
if
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
interp_val = interpolate_string(val, target)
|
68
|
-
rescue Exception
|
69
|
-
next
|
92
|
+
if command_regex =~ val
|
93
|
+
if data.options[:interpolate]
|
94
|
+
val.replace(interpolate_string(val, target))
|
95
|
+
command_regex =~ val # re-match with the interpolated string
|
70
96
|
end
|
71
|
-
|
72
|
-
val.replace interp_val if command_regex =~ interp_val
|
73
|
-
else
|
74
|
-
command_regex =~ val
|
97
|
+
true
|
75
98
|
end
|
76
99
|
end
|
77
100
|
|
@@ -87,11 +110,17 @@ class Pry
|
|
87
110
|
# @param [String] eval_string The cumulative lines of input for
|
88
111
|
# multi-line input.
|
89
112
|
# @param [Binding] target The receiver of the commands.
|
113
|
+
# @return [Pry::CommandProcessor::Result] A wrapper object
|
114
|
+
# containing info about the result of the command processing
|
115
|
+
# (indicating whether it is a command and if it is what kind of
|
116
|
+
# command it is.
|
90
117
|
def process_commands(val, eval_string, target)
|
91
118
|
|
92
|
-
# no command was matched, so return to caller
|
93
119
|
command, captures, pos = command_matched(val, target)
|
94
|
-
|
120
|
+
|
121
|
+
# no command was matched, so return to caller
|
122
|
+
return Result.new(false) if !command
|
123
|
+
|
95
124
|
arg_string = val[pos..-1]
|
96
125
|
|
97
126
|
# remove the one leading space if it exists
|
@@ -103,12 +132,13 @@ class Pry
|
|
103
132
|
:val => val,
|
104
133
|
:arg_string => arg_string,
|
105
134
|
:eval_string => eval_string,
|
106
|
-
:nesting => nesting,
|
107
135
|
:commands => commands.commands,
|
108
136
|
:captures => captures
|
109
137
|
}
|
110
138
|
|
111
|
-
execute_command(target, command.name, options, *(captures + args))
|
139
|
+
ret = execute_command(target, command.name, options, *(captures + args))
|
140
|
+
|
141
|
+
Result.new(true, command.options[:keep_retval], ret)
|
112
142
|
end
|
113
143
|
|
114
144
|
# Execute a Pry command.
|
@@ -117,6 +147,7 @@ class Pry
|
|
117
147
|
# @param [String] command The name of the command to be run.
|
118
148
|
# @param [Hash] options The options to set on the Commands object.
|
119
149
|
# @param [Array] args The command arguments.
|
150
|
+
# @return [Object] The value returned by the command
|
120
151
|
def execute_command(target, command, options, *args)
|
121
152
|
context = CommandContext.new
|
122
153
|
|
@@ -128,12 +159,12 @@ class Pry
|
|
128
159
|
context.eval_string = options[:eval_string]
|
129
160
|
context.arg_string = options[:arg_string]
|
130
161
|
context.command_set = commands
|
162
|
+
context._pry_ = @pry_instance
|
131
163
|
|
132
164
|
context.command_processor = self
|
133
165
|
|
134
166
|
ret = commands.run_command(context, command, *args)
|
135
167
|
|
136
|
-
# Tick, tock, im getting rid of this shit soon.
|
137
168
|
options[:val].replace("")
|
138
169
|
|
139
170
|
ret
|