mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
fixed run
command builder, now takes target parameter, also accepts system
commands. Also: * changed Rakefile to remove the -k flag from bacon test * changed pry_instance attr_reader to attr_accessor in CommandProcessor class * updated tests to reflect new `run` parameters
This commit is contained in:
parent
3c271ff712
commit
d111b19f82
4 changed files with 14 additions and 7 deletions
2
Rakefile
2
Rakefile
|
@ -30,7 +30,7 @@ def apply_spec_defaults(s)
|
|||
end
|
||||
|
||||
task :test do
|
||||
sh "bacon -k #{direc}/test/test.rb"
|
||||
sh "bacon #{direc}/test/test.rb"
|
||||
end
|
||||
|
||||
desc "run pry"
|
||||
|
|
|
@ -68,20 +68,27 @@ class Pry
|
|||
end
|
||||
|
||||
# Execute a command (this enables commands to call other commands).
|
||||
# @param [Binding] target The current target object.
|
||||
# @param [String] name The command to execute
|
||||
# @param [Array] args The parameters to pass to the command.
|
||||
# @example Wrap one command with another
|
||||
# class MyCommands < Pry::Commands
|
||||
# command "ls2" do
|
||||
# output.puts "before ls"
|
||||
# run "ls"
|
||||
# run target, "ls"
|
||||
# output.puts "after ls"
|
||||
# end
|
||||
# end
|
||||
def run(name, *args)
|
||||
def run(target, name, *args)
|
||||
command_processor = CommandProcessor.new(target.eval('_pry_'))
|
||||
|
||||
if command_processor.system_command?(name)
|
||||
command_processor.execute_system_command("#{name} #{args.join}")
|
||||
else
|
||||
action = opts[:commands][name][:action]
|
||||
instance_exec(*args, &action)
|
||||
end
|
||||
end
|
||||
|
||||
# Import commands from another command object.
|
||||
# @param [Pry::CommandBase] klass The class to import from (must
|
||||
|
|
|
@ -7,7 +7,7 @@ class Pry
|
|||
|
||||
extend Forwardable
|
||||
|
||||
attr_reader :pry_instance
|
||||
attr_accessor :pry_instance
|
||||
|
||||
def initialize(pry_instance)
|
||||
@pry_instance = pry_instance
|
||||
|
|
|
@ -492,7 +492,7 @@ describe Pry do
|
|||
end
|
||||
|
||||
command "run_v" do
|
||||
run "v"
|
||||
run target, "v"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue