Permalink
Browse files

Merge remote-tracking branch 'rking/master'

  • Loading branch information...
2 parents 4a7d06e + 8136429 commit bc4fb838eb48b5fb7419c5f2320e88ec1101e95c @ConradIrwin ConradIrwin committed Sep 19, 2012
Showing with 43 additions and 24 deletions.
  1. +19 −2 Guardfile
  2. +5 −0 lib/pry/history_array.rb
  3. +3 −3 pry.gemspec
  4. +16 −19 test/test_history_array.rb
View
@@ -33,8 +33,24 @@ module ::Guard
end
guard 'bacon' do
- # Example of mapping a lib file to one or more test files
- watch('lib/pry/indent.rb') { 'test/test_indent.rb' }
+ def deduce_test_from(token)
+ "test/test_#{token}.rb"
+ end
+
+ Dir['lib/pry/*.rb'].each do |rb|
+ rb[%r(lib/pry/(.+)\.rb$)]
+ test_rb = deduce_test_from $1
+ if File.exists?(test_rb)
+ watch(rb) { test_rb }
+ else
+ exempt = %w(
+ commands
+ version
+ ).map {|token| deduce_test_from token}
+ puts 'Missing ' + test_rb if
+ ENV['WANT_TEST_COMPLAINTS'] and not exempt.include?(test_rb)
+ end
+ end
watch(%r{^lib/pry/commands/([^.]+)\.rb}) { |m| "test/test_commands/test_#{m[1]}.rb" }
@@ -45,3 +61,4 @@ guard 'bacon' do
watch(%r{^test.*/test_.+\.rb$})
end
+# vim:ft=ruby
View
@@ -89,6 +89,11 @@ def to_a
((@count - size)...@count).map { |n| @hash[n] }
end
+ def pop!
+ @hash.delete @count - 1
+ @count -= 1
+ end
+
def inspect
"#<#{self.class} size=#{size} first=#{@count - size} max_size=#{max_size}>"
end
View
@@ -6,16 +6,16 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["John Mair (banisterfiend)", "Conrad Irwin", "Ryan Fitzgerald"]
- s.date = "2012-09-08"
+ s.date = "2012-09-17"
s.description = "An IRB alternative and runtime developer console"
s.email = ["jrmair@gmail.com", "conrad.irwin@gmail.com", "rwfitzge@gmail.com"]
s.executables = ["pry"]
- s.files = [".document", ".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "CONTRIBUTORS", "Gemfile", "Guardfile", "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/commands/amend_line.rb", "lib/pry/commands/bang.rb", "lib/pry/commands/bang_pry.rb", "lib/pry/commands/cat.rb", "lib/pry/commands/cd.rb", "lib/pry/commands/easter_eggs.rb", "lib/pry/commands/edit.rb", "lib/pry/commands/edit_method.rb", "lib/pry/commands/exit.rb", "lib/pry/commands/exit_all.rb", "lib/pry/commands/exit_program.rb", "lib/pry/commands/find_method.rb", "lib/pry/commands/gem_cd.rb", "lib/pry/commands/gem_install.rb", "lib/pry/commands/gem_list.rb", "lib/pry/commands/gist.rb", "lib/pry/commands/help.rb", "lib/pry/commands/hist.rb", "lib/pry/commands/import_set.rb", "lib/pry/commands/install_command.rb", "lib/pry/commands/jump_to.rb", "lib/pry/commands/ls.rb", "lib/pry/commands/nesting.rb", "lib/pry/commands/play.rb", "lib/pry/commands/pry_backtrace.rb", "lib/pry/commands/pry_version.rb", "lib/pry/commands/raise_up.rb", "lib/pry/commands/reload_method.rb", "lib/pry/commands/reset.rb", "lib/pry/commands/ri.rb", "lib/pry/commands/save_file.rb", "lib/pry/commands/shell_command.rb", "lib/pry/commands/shell_mode.rb", "lib/pry/commands/show_command.rb", "lib/pry/commands/show_doc.rb", "lib/pry/commands/show_input.rb", "lib/pry/commands/show_source.rb", "lib/pry/commands/simple_prompt.rb", "lib/pry/commands/stat.rb", "lib/pry/commands/switch_to.rb", "lib/pry/commands/toggle_color.rb", "lib/pry/commands/whereami.rb", "lib/pry/commands/wtf.rb", "lib/pry/completion.rb", "lib/pry/config.rb", "lib/pry/core_extensions.rb", "lib/pry/custom_completions.rb", "lib/pry/helpers.rb", "lib/pry/helpers/base_helpers.rb", "lib/pry/helpers/command_helpers.rb", "lib/pry/helpers/documentation_helpers.rb", "lib/pry/helpers/module_introspection_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/module_candidate.rb", "lib/pry/pager.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/repl_file_loader.rb", "lib/pry/version.rb", "lib/pry/wrapped_module.rb", "man/pry.1", "man/pry.1.html", "man/pry.1.ronn", "pry.gemspec", "test/candidate_helper1.rb", "test/candidate_helper2.rb", "test/example_nesting.rb", "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_control_d_handler.rb", "test/test_default_commands/example.erb", "test/test_default_commands/test_cd.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_find_method.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_help.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_default_commands/test_show_source.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_prompt.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_sticky_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad", "wiki/Customizing-pry.md", "wiki/Home.md"]
+ s.files = [".document", ".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "CONTRIBUTORS", "Gemfile", "Guardfile", "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/commands/amend_line.rb", "lib/pry/commands/bang.rb", "lib/pry/commands/bang_pry.rb", "lib/pry/commands/cat.rb", "lib/pry/commands/cd.rb", "lib/pry/commands/easter_eggs.rb", "lib/pry/commands/edit.rb", "lib/pry/commands/edit_method.rb", "lib/pry/commands/exit.rb", "lib/pry/commands/exit_all.rb", "lib/pry/commands/exit_program.rb", "lib/pry/commands/find_method.rb", "lib/pry/commands/gem_cd.rb", "lib/pry/commands/gem_install.rb", "lib/pry/commands/gem_list.rb", "lib/pry/commands/gist.rb", "lib/pry/commands/help.rb", "lib/pry/commands/hist.rb", "lib/pry/commands/import_set.rb", "lib/pry/commands/install_command.rb", "lib/pry/commands/jump_to.rb", "lib/pry/commands/ls.rb", "lib/pry/commands/nesting.rb", "lib/pry/commands/play.rb", "lib/pry/commands/pry_backtrace.rb", "lib/pry/commands/pry_version.rb", "lib/pry/commands/raise_up.rb", "lib/pry/commands/reload_method.rb", "lib/pry/commands/reset.rb", "lib/pry/commands/ri.rb", "lib/pry/commands/save_file.rb", "lib/pry/commands/shell_command.rb", "lib/pry/commands/shell_mode.rb", "lib/pry/commands/show_command.rb", "lib/pry/commands/show_doc.rb", "lib/pry/commands/show_input.rb", "lib/pry/commands/show_source.rb", "lib/pry/commands/simple_prompt.rb", "lib/pry/commands/stat.rb", "lib/pry/commands/switch_to.rb", "lib/pry/commands/toggle_color.rb", "lib/pry/commands/whereami.rb", "lib/pry/commands/wtf.rb", "lib/pry/completion.rb", "lib/pry/config.rb", "lib/pry/core_extensions.rb", "lib/pry/custom_completions.rb", "lib/pry/helpers.rb", "lib/pry/helpers/base_helpers.rb", "lib/pry/helpers/command_helpers.rb", "lib/pry/helpers/documentation_helpers.rb", "lib/pry/helpers/module_introspection_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/module_candidate.rb", "lib/pry/pager.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/repl_file_loader.rb", "lib/pry/version.rb", "lib/pry/wrapped_module.rb", "man/pry.1", "man/pry.1.html", "man/pry.1.ronn", "pry.gemspec", "test/candidate_helper1.rb", "test/candidate_helper2.rb", "test/example_nesting.rb", "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_commands/example.erb", "test/test_commands/test_amend_line.rb", "test/test_commands/test_bang.rb", "test/test_commands/test_cat.rb", "test/test_commands/test_cd.rb", "test/test_commands/test_edit.rb", "test/test_commands/test_edit_method.rb", "test/test_commands/test_exit.rb", "test/test_commands/test_exit_all.rb", "test/test_commands/test_exit_program.rb", "test/test_commands/test_find_method.rb", "test/test_commands/test_gem_list.rb", "test/test_commands/test_help.rb", "test/test_commands/test_hist.rb", "test/test_commands/test_jump_to.rb", "test/test_commands/test_ls.rb", "test/test_commands/test_play.rb", "test/test_commands/test_raise_up.rb", "test/test_commands/test_save_file.rb", "test/test_commands/test_show_doc.rb", "test/test_commands/test_show_input.rb", "test/test_commands/test_show_source.rb", "test/test_commands/test_whereami.rb", "test/test_completion.rb", "test/test_control_d_handler.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_prompt.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_sticky_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.24"
s.summary = "An IRB alternative and runtime developer console"
- s.test_files = ["test/candidate_helper1.rb", "test/candidate_helper2.rb", "test/example_nesting.rb", "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_control_d_handler.rb", "test/test_default_commands/example.erb", "test/test_default_commands/test_cd.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_find_method.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_help.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_default_commands/test_show_source.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_prompt.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_sticky_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad"]
+ s.test_files = ["test/candidate_helper1.rb", "test/candidate_helper2.rb", "test/example_nesting.rb", "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_commands/example.erb", "test/test_commands/test_amend_line.rb", "test/test_commands/test_bang.rb", "test/test_commands/test_cat.rb", "test/test_commands/test_cd.rb", "test/test_commands/test_edit.rb", "test/test_commands/test_edit_method.rb", "test/test_commands/test_exit.rb", "test/test_commands/test_exit_all.rb", "test/test_commands/test_exit_program.rb", "test/test_commands/test_find_method.rb", "test/test_commands/test_gem_list.rb", "test/test_commands/test_help.rb", "test/test_commands/test_hist.rb", "test/test_commands/test_jump_to.rb", "test/test_commands/test_ls.rb", "test/test_commands/test_play.rb", "test/test_commands/test_raise_up.rb", "test/test_commands/test_save_file.rb", "test/test_commands/test_show_doc.rb", "test/test_commands/test_show_input.rb", "test/test_commands/test_show_source.rb", "test/test_commands/test_whereami.rb", "test/test_completion.rb", "test/test_control_d_handler.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_prompt.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_sticky_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad"]
if s.respond_to? :specification_version then
s.specification_version = 3
View
@@ -3,56 +3,48 @@
describe Pry::HistoryArray do
before do
@array = Pry::HistoryArray.new 10
+ @populated = @array.dup << 1 << 2 << 3 << 4
end
it 'should have a maximum size specifed at creation time' do
@array.max_size.should == 10
end
it 'should be able to be added objects to' do
- @array << 1 << 2 << 3
- @array.size.should == 3
- @array.to_a.should == [1, 2, 3]
+ @populated.size.should == 4
+ @populated.to_a.should == [1, 2, 3, 4]
end
it 'should be able to access single elements' do
- @array << 1 << 2 << 3
- @array[2].should == 3
+ @populated[2].should == 3
end
it 'should be able to access negative indices' do
- @array << 1 << 2 << 3
- @array[-1].should == 3
+ @populated[-1].should == 4
end
it 'should be able to access ranges' do
- @array << 1 << 2 << 3 << 4
- @array[1..2].should == [2, 3]
+ @populated[1..2].should == [2, 3]
end
it 'should be able to access ranges starting from a negative index' do
- @array << 1 << 2 << 3 << 4
- @array[-2..3].should == [3, 4]
+ @populated[-2..3].should == [3, 4]
end
it 'should be able to access ranges ending at a negative index' do
- @array << 1 << 2 << 3 << 4
- @array[2..-1].should == [3, 4]
+ @populated[2..-1].should == [3, 4]
end
it 'should be able to access ranges using only negative indices' do
- @array << 1 << 2 << 3 << 4
- @array[-2..-1].should == [3, 4]
+ @populated[-2..-1].should == [3, 4]
end
it 'should be able to use range where end is excluded' do
- @array << 1 << 2 << 3 << 4
- @array[-2...-1].should == [3]
+ @populated[-2...-1].should == [3]
end
it 'should be able to access slices using a size' do
- @array << 1 << 2 << 3 << 4
- @array[-3, 2].should == [2, 3]
+ @populated[-3, 2].should == [2, 3]
end
it 'should remove older entries' do
@@ -67,4 +59,9 @@
12.times { |n| @array << n }
@array.entries.compact.size.should == 10
end
+
+ it 'should pop!' do
+ @populated.pop!
+ @populated.to_a.should == [1, 2, 3]
+ end
end

0 comments on commit bc4fb83

Please sign in to comment.