1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

no longer yields binding_stack to whenstarted, fixed #434

This commit is contained in:
John Mair 2012-01-20 17:39:25 +13:00
parent c59b8e2751
commit 75af6ad68d
4 changed files with 52 additions and 60 deletions

View file

@ -117,17 +117,16 @@ class Pry
# yield the binding_stack to the hook for modification
pry_instance.exec_hook(
:when_started,
binding_stack = [target],
options,
pry_instance
)
:when_started,
target,
options,
pry_instance
)
if pry_instance.binding_stack.empty?
head, *tail = binding_stack
pry_instance.binding_stack.push(*tail)
else
if !pry_instance.binding_stack.empty?
head = pry_instance.binding_stack.pop
else
head = target
end
# Enter the matrix

View file

@ -1,3 +1,3 @@
class Pry
VERSION = "0.9.8pre6"
VERSION = "0.9.8pre7"
end

View file

@ -1,21 +1,21 @@
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "pry"
s.version = "0.9.8pre4"
s.name = %q{pry}
s.version = "0.9.8pre7"
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["John Mair (banisterfiend)"]
s.date = "2012-01-16"
s.description = "An IRB alternative and runtime developer console"
s.email = "jrmair@gmail.com"
s.executables = ["pry"]
s.files = [".document", ".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "CONTRIBUTORS", "Gemfile", "LICENSE", "README.markdown", "Rakefile", "TODO", "bin/pry", "examples/example_basic.rb", "examples/example_command_override.rb", "examples/example_commands.rb", "examples/example_hooks.rb", "examples/example_image_edit.rb", "examples/example_input.rb", "examples/example_input2.rb", "examples/example_output.rb", "examples/example_print.rb", "examples/example_prompt.rb", "examples/helper.rb", "lib/pry.rb", "lib/pry/cli.rb", "lib/pry/code.rb", "lib/pry/command.rb", "lib/pry/command_set.rb", "lib/pry/commands.rb", "lib/pry/completion.rb", "lib/pry/config.rb", "lib/pry/core_extensions.rb", "lib/pry/custom_completions.rb", "lib/pry/default_commands/basic.rb", "lib/pry/default_commands/context.rb", "lib/pry/default_commands/documentation.rb", "lib/pry/default_commands/easter_eggs.rb", "lib/pry/default_commands/gems.rb", "lib/pry/default_commands/input.rb", "lib/pry/default_commands/introspection.rb", "lib/pry/default_commands/ls.rb", "lib/pry/default_commands/shell.rb", "lib/pry/extended_commands/experimental.rb", "lib/pry/helpers.rb", "lib/pry/helpers/base_helpers.rb", "lib/pry/helpers/command_helpers.rb", "lib/pry/helpers/options_helpers.rb", "lib/pry/helpers/text.rb", "lib/pry/history.rb", "lib/pry/history_array.rb", "lib/pry/hooks.rb", "lib/pry/indent.rb", "lib/pry/method.rb", "lib/pry/plugins.rb", "lib/pry/pry_class.rb", "lib/pry/pry_instance.rb", "lib/pry/rbx_method.rb", "lib/pry/rbx_path.rb", "lib/pry/version.rb", "lib/pry/wrapped_module.rb", "man/pry.1", "man/pry.1.html", "man/pry.1.ronn", "pry.gemspec", "test/helper.rb", "test/test_cli.rb", "test/test_code.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_integration.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_special_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad", "wiki/Customizing-pry.md", "wiki/Home.md"]
s.homepage = "http://pry.github.com"
s.require_paths = ["lib"]
s.rubygems_version = "1.8.11"
s.summary = "An IRB alternative and runtime developer console"
s.test_files = ["test/helper.rb", "test/test_cli.rb", "test/test_code.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_integration.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_special_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad"]
s.authors = [%q{John Mair (banisterfiend)}]
s.date = %q{2012-01-20}
s.description = %q{An IRB alternative and runtime developer console}
s.email = %q{jrmair@gmail.com}
s.executables = [%q{pry}]
s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.travis.yml}, %q{.yardopts}, %q{CHANGELOG}, %q{CONTRIBUTORS}, %q{Gemfile}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/cli.rb}, %q{lib/pry/code.rb}, %q{lib/pry/command.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/options_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/hooks.rb}, %q{lib/pry/indent.rb}, %q{lib/pry/method.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/rbx_method.rb}, %q{lib/pry/rbx_path.rb}, %q{lib/pry/version.rb}, %q{lib/pry/wrapped_module.rb}, %q{man/pry.1}, %q{man/pry.1.html}, %q{man/pry.1.ronn}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_cli.rb}, %q{test/test_code.rb}, %q{test/test_command.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_integration.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_ls.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_hooks.rb}, %q{test/test_indent.rb}, %q{test/test_input_stack.rb}, %q{test/test_method.rb}, %q{test/test_pry.rb}, %q{test/test_pry_defaults.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/test_syntax_checking.rb}, %q{test/test_wrapped_module.rb}, %q{test/testrc}, %q{test/testrcbad}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
s.homepage = %q{http://pry.github.com}
s.require_paths = [%q{lib}]
s.rubygems_version = %q{1.8.6}
s.summary = %q{An IRB alternative and runtime developer console}
s.test_files = [%q{test/helper.rb}, %q{test/test_cli.rb}, %q{test/test_code.rb}, %q{test/test_command.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_integration.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_ls.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_hooks.rb}, %q{test/test_indent.rb}, %q{test/test_input_stack.rb}, %q{test/test_method.rb}, %q{test/test_pry.rb}, %q{test/test_pry_defaults.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/test_syntax_checking.rb}, %q{test/test_wrapped_module.rb}, %q{test/testrc}, %q{test/testrcbad}]
if s.respond_to? :specification_version then
s.specification_version = 3

View file

@ -311,7 +311,7 @@ describe Pry::Hooks do
describe "when_started hook" do
it 'should yield options to the hook' do
options = nil
Pry.config.hooks.add_hook(:when_started, :test_hook) { |_, opt, _| options = opt }
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| options = opt }
redirect_pry_io(StringIO.new("exit"), out=StringIO.new) do
Pry.start binding, :hello => :baby
@ -321,12 +321,39 @@ describe Pry::Hooks do
Pry.config.hooks.delete_hook(:when_started, :test_hook)
end
describe "target" do
it 'should yield the target, as a binding ' do
b = nil
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| b = target }
redirect_pry_io(StringIO.new("exit"), out=StringIO.new) do
Pry.start 5, :hello => :baby
end
b.is_a?(Binding).should == true
Pry.config.hooks.delete_hook(:when_started, :test_hook)
end
it 'should yield the target to the hook' do
b = nil
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| b = target }
redirect_pry_io(StringIO.new("exit"), out=StringIO.new) do
Pry.start 5, :hello => :baby
end
b.eval('self').should == 5
Pry.config.hooks.delete_hook(:when_started, :test_hook)
end
end
it 'should allow overriding of target (and binding_stack)' do
options = nil
o = Object.new
class << o; attr_accessor :value; end
Pry.config.hooks.add_hook(:when_started, :test_hook) { |binding_stack, opt, _pry_| binding_stack.replace [Pry.binding_for(o)] }
Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _pry_| _pry_.binding_stack = [Pry.binding_for(o)] }
redirect_pry_io(InputTester.new("@value = true","exit-all")) do
Pry.start binding, :hello => :baby
@ -336,40 +363,6 @@ describe Pry::Hooks do
Pry.config.hooks.delete_hook(:when_started, :test_hook)
end
it 'should allow overriding of target (and binding_stack) via _pry_.binding_stack' do
options = nil
o = Object.new
class << o; attr_accessor :value; end
Pry.config.hooks.add_hook(:when_started, :test_hook) { |binding_stack, opt, _pry_| _pry_.binding_stack = [Pry.binding_for(o)] }
redirect_pry_io(InputTester.new("@value = true","exit-all")) do
Pry.start binding, :hello => :baby
end
o.value.should == true
Pry.config.hooks.delete_hook(:when_started, :test_hook)
end
it 'should give precedence to _pry_.binding_stack over binding_stack' do
options = nil
o = Object.new
class << o; attr_accessor :value; end
Pry.config.hooks.add_hook(:when_started, :test_hook) do |binding_stack, opt, _pry_|
_pry_.binding_stack = [Pry.binding_for(o)]
binding_stack.replace [Pry.binding_for(5)]
end
redirect_pry_io(InputTester.new("@value = true","exit-all")) do
Pry.start binding, :hello => :baby
end
o.value.should == true
Pry.config.hooks.delete_hook(:when_started, :test_hook)
end
end
describe "after_session hook" do