2011-01-12 01:16:04 +00:00
|
|
|
class Module
|
|
|
|
public :remove_const
|
2010-12-21 14:03:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class InputTester
|
2010-12-24 08:30:51 +00:00
|
|
|
def initialize(*actions)
|
|
|
|
@orig_actions = actions.dup
|
|
|
|
@actions = actions
|
2010-12-21 14:03:52 +00:00
|
|
|
end
|
|
|
|
|
2011-01-09 11:51:45 +00:00
|
|
|
def readline(*)
|
2010-12-21 14:03:52 +00:00
|
|
|
@actions.shift
|
|
|
|
end
|
|
|
|
|
|
|
|
def rewind
|
2011-01-07 12:18:09 +00:00
|
|
|
@actions = @orig_actions.dup
|
2010-12-21 14:03:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-01-12 01:16:04 +00:00
|
|
|
class CommandTester < Pry::CommandBase
|
|
|
|
|
|
|
|
command "command1" do
|
|
|
|
describe "command 1 test"
|
|
|
|
action { |opts| opts[:output].puts "command1"; opts[:val].clear }
|
|
|
|
end
|
|
|
|
|
|
|
|
command "command2" do
|
|
|
|
describe "command 2 test"
|
|
|
|
pattern /command2\s*(.*)/
|
|
|
|
action { |opts|
|
|
|
|
arg = opts[:captures].first
|
|
|
|
opts[:output].puts arg
|
|
|
|
opts[:val].clear
|
2011-01-05 03:23:11 +00:00
|
|
|
}
|
2010-12-21 14:03:52 +00:00
|
|
|
end
|
2011-01-12 01:16:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
# def commands
|
|
|
|
# @commands ||= {
|
|
|
|
# "command1" => proc { |opts| opts[:output].puts "command1"; opts[:val].clear },
|
|
|
|
# /command2\s*(.*)/ => proc do |opts|
|
|
|
|
# arg = opts[:captures].first
|
|
|
|
# opts[:output].puts arg
|
|
|
|
# opts[:val].clear
|
|
|
|
# end
|
|
|
|
# }
|
|
|
|
# end
|
|
|
|
# e
|
2010-12-21 14:03:52 +00:00
|
|
|
end
|