Remove deprecated hooks API

It's been around for a long, long time. It's time to get rid of it.
This commit is contained in:
Kyrylo Silin 2014-04-29 11:13:26 +03:00
parent 33c45dbf52
commit 9f25fffb6d
3 changed files with 1 additions and 63 deletions

View File

@ -6,6 +6,7 @@
* Remove require of `openstruct` from pry (#1096)
* Ruby 1.9 or later required
* Require Coderay `~> 1.1.0`
* Remove deprecated hooks API (#1209)
#### Features
* Added a `watch` command that lets you see how values change over time.

View File

@ -49,22 +49,6 @@ class Pry
@errors ||= []
end
# FIXME:
# This is a hack to alert people of the new API.
def [](event_name)
warn "`Pry.hooks[]` is deprecated! Please use the new `Pry::Hooks` API! http://rubydoc.info/github/pry/pry/master/Pry/Hooks"
get_hook(event_name, nil)
end
# FIXME:
# This is a hack to alert people of the new API.
def []=(event_name, callable)
warn "`Pry.hooks[]=` is deprecated! Please use the new `Pry::Hooks` API! http://rubydoc.info/github/pry/pry/master/Pry/Hooks"
add_hook(event_name, nil, callable)
end
# Destructively merge the contents of two `Pry:Hooks` instances.
# @param [Pry::Hooks] other The `Pry::Hooks` instance to merge
# @return [Pry:Hooks] Returns the receiver.

View File

@ -472,51 +472,4 @@ describe Pry::Hooks do
end
end
describe "deprecated hash-based API" do
after do
Pry.config.hooks.clear_all if Pry.config.hooks
end
describe "Pry.config.hooks" do
it 'should allow a hash-assignment' do
Pry.config.hooks = { :before_session => proc { :hello } }
Pry.config.hooks.get_hook(:before_session, nil).call.should == :hello
end
describe "Pry.config.hooks[]" do
it 'should return the only anonymous hook' do
Pry.config.hooks = { :before_session => proc { :hello } }
Pry.config.hooks[:before_session].call.should == :hello
end
it 'should add an anonymous hook when using Pry.config.hooks[]=' do
Pry.config.hooks[:before_session] = proc { :bing }
Pry.config.hooks.hook_count(:before_session).should == 1
end
it 'should add overwrite previous anonymous hooks with new one when calling Pry.config.hooks[]= multiple times' do
x = nil
Pry.config.hooks[:before_session] = proc { x = 1 }
Pry.config.hooks[:before_session] = proc { x = 2 }
Pry.config.hooks.exec_hook(:before_session)
Pry.config.hooks.hook_count(:before_session).should == 1
x.should == 2
end
end
end
describe "Pry.start" do
it 'should accept a hash for :hooks parameter' do
redirect_pry_io(InputTester.new("exit-all"), out=StringIO.new) do
Pry.start binding, :hooks => { :before_session => proc { |output, _, _| output.puts 'hello friend' } }
end
out.string.should =~ /hello friend/
end
end
end
end