hooks: remove old API's using hooks altogether

This commit is contained in:
Kyrylo Silin 2015-03-14 11:48:09 +02:00
parent dc1428c3ae
commit db8ba4a57c
5 changed files with 2 additions and 30 deletions

View File

@ -16,6 +16,7 @@
* Fixed regression with `pry -e` when it messes the terminal ([#1387](https://github.com/pry/pry/issues/1387))
* Fixed regression with space prefixes of expressions ([#1369](https://github.com/pry/pry/issues/1369))
* Introduced the new way to define hooks for commands (with `Pry.hooks.add_hook("{before,after}_commandName")`). The old way is deprecated, but still supported (with `Pry.commands.{before,after}_command`) ([#651](https://github.com/pry/pry/issues/651))
* Removed old API's using `Pry::Hooks.from_hash` altogether
### 0.10.1

View File

@ -7,18 +7,4 @@ class Pry::Config
def self.shortcuts
Convenience::SHORTCUTS
end
#
# FIXME
# @param [Pry::Hooks] hooks
#
def hooks=(hooks)
if hooks.is_a?(Hash)
warn "Hash-based hooks are now deprecated! Use a `Pry::Hooks` object " \
"instead! http://rubydoc.info/github/pry/pry/master/Pry/Hooks"
self["hooks"] = Pry::Hooks.from_hash(hooks)
else
self["hooks"] = hooks
end
end
end

View File

@ -10,21 +10,6 @@ class Pry
# puts "hello"
# end
class Hooks
# Converts a hash to a `Pry::Hooks` instance. All hooks defined this way are
# anonymous. This functionality is primarily to provide backwards
# compatibility with the old hash-based hook system in Pry versions < 0.9.8
#
# @param [Hash] hash The hash to convert to `Pry::Hooks`.
# @return [Pry::Hooks] The resulting `Pry::Hooks` instance.
def self.from_hash(hash)
return hash if hash.instance_of?(self)
instance = new
hash.each do |k, v|
instance.add_hook(k, nil, v)
end
instance
end
def initialize
@hooks = Hash.new { |h, k| h[k] = [] }
end

View File

@ -150,7 +150,6 @@ you can add "Pry.config.windows_console_warning = false" to your .pryrc.
end
options[:target] = Pry.binding_for(target || toplevel_binding)
options[:hooks] = Pry::Hooks.from_hash options.delete(:hooks) if options.key?(:hooks)
initial_session_setup
# Unless we were given a backtrace, save the current one

View File

@ -415,6 +415,7 @@ describe Pry::Hooks do
end
hooks = Pry::Hooks.new.add_hook(:before_eval, :quirk) { |code, pry| code.replace(":little_duck") }
redirect_pry_io(InputTester.new("how-do-you-like-your-blue-eyed-boy-now-mister-death", "exit-all"), out = StringIO.new) do
Pry.start(self, :hooks => hooks, :commands => commands)
end