Add Bond completion (when available) cirwin++
This commit is contained in:
parent
8c9c38ef4c
commit
6617856b06
2
Rakefile
2
Rakefile
|
@ -25,6 +25,8 @@ def apply_spec_defaults(s)
|
|||
s.add_development_dependency('bacon', '~> 1.1')
|
||||
s.add_development_dependency('open4', '~> 1.3')
|
||||
s.add_development_dependency('rake', '~> 0.9')
|
||||
# TODO: make this a plain dependency:
|
||||
s.add_development_dependency('bond', '~> 0.4.2')
|
||||
end
|
||||
|
||||
def check_dependencies
|
||||
|
|
|
@ -222,3 +222,11 @@ require 'pry/pry_class'
|
|||
require 'pry/pry_instance'
|
||||
require 'pry/cli'
|
||||
require 'pry/pager'
|
||||
|
||||
begin
|
||||
require 'bond'
|
||||
rescue LoadError
|
||||
Pry.config.completer = Pry::InputCompleter
|
||||
else
|
||||
Pry.config.completer = Pry::BondCompleter
|
||||
end
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
# taken from irb
|
||||
|
||||
require "readline"
|
||||
|
||||
class Pry
|
||||
|
||||
module BondCompleter
|
||||
def self.build_completion_proc(target, pry=nil, commands=[""])
|
||||
Bond.start
|
||||
proc{ |*a| Bond.agent.call(*a) }
|
||||
end
|
||||
end
|
||||
|
||||
# Implements tab completion for Readline in Pry
|
||||
module InputCompleter
|
||||
|
||||
|
@ -42,6 +47,7 @@ class Pry
|
|||
# @param [Binding] target The current binding context.
|
||||
# @param [Array<String>] commands The array of Pry commands.
|
||||
def self.build_completion_proc(target, pry=nil, commands=[""])
|
||||
|
||||
proc do |input|
|
||||
|
||||
# if there are multiple contexts e.g. cd 1/2/3
|
||||
|
|
|
@ -228,6 +228,9 @@ class Pry
|
|||
# Pry.config.extra_sticky_locals = { :random_number => proc {
|
||||
# rand(10) } }
|
||||
attr_accessor :extra_sticky_locals
|
||||
|
||||
# @return [#build_completion_proc] A completer to use.
|
||||
attr_accessor :completer
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ class Pry
|
|||
@indent.reset if eval_string.empty?
|
||||
|
||||
current_prompt = select_prompt(eval_string, target)
|
||||
completion_proc = Pry::InputCompleter.build_completion_proc(target, self,
|
||||
completion_proc = Pry.config.completer.build_completion_proc(target, self,
|
||||
instance_eval(&custom_completions))
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ 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"]
|
||||
s.date = "2012-08-13"
|
||||
s.date = "2012-08-18"
|
||||
s.description = "An IRB alternative and runtime developer console"
|
||||
s.email = ["jrmair@gmail.com", "conrad.irwin@gmail.com"]
|
||||
s.executables = ["pry"]
|
||||
|
@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|||
s.add_development_dependency(%q<bacon>, ["~> 1.1"])
|
||||
s.add_development_dependency(%q<open4>, ["~> 1.3"])
|
||||
s.add_development_dependency(%q<rake>, ["~> 0.9"])
|
||||
s.add_development_dependency(%q<bond>, ["~> 0.4.2"])
|
||||
else
|
||||
s.add_dependency(%q<coderay>, ["~> 1.0.5"])
|
||||
s.add_dependency(%q<slop>, ["~> 3.3.1"])
|
||||
|
@ -34,6 +35,7 @@ Gem::Specification.new do |s|
|
|||
s.add_dependency(%q<bacon>, ["~> 1.1"])
|
||||
s.add_dependency(%q<open4>, ["~> 1.3"])
|
||||
s.add_dependency(%q<rake>, ["~> 0.9"])
|
||||
s.add_dependency(%q<bond>, ["~> 0.4.2"])
|
||||
end
|
||||
else
|
||||
s.add_dependency(%q<coderay>, ["~> 1.0.5"])
|
||||
|
@ -42,5 +44,6 @@ Gem::Specification.new do |s|
|
|||
s.add_dependency(%q<bacon>, ["~> 1.1"])
|
||||
s.add_dependency(%q<open4>, ["~> 1.3"])
|
||||
s.add_dependency(%q<rake>, ["~> 0.9"])
|
||||
s.add_dependency(%q<bond>, ["~> 0.4.2"])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,11 @@ def completer_test(bind, pry=nil, assert_flag=true)
|
|||
return proc {|*symbols| symbols.each(&test) }
|
||||
end
|
||||
|
||||
describe 'bond-based completion' do
|
||||
it 'should pull in Bond by default' do
|
||||
Pry.config.completer.should == Pry::BondCompleter
|
||||
end
|
||||
end
|
||||
|
||||
describe Pry::InputCompleter do
|
||||
|
||||
|
@ -20,9 +25,13 @@ describe Pry::InputCompleter do
|
|||
module SymbolyName
|
||||
def self.name; :symboly_name; end
|
||||
end
|
||||
|
||||
$default_completer = Pry.config.completer
|
||||
Pry.config.completer = Pry::InputCompleter
|
||||
end
|
||||
|
||||
after do
|
||||
Pry.config.completer = $default_completer
|
||||
Object.remove_const :SymbolyName
|
||||
end
|
||||
|
||||
|
@ -216,4 +225,3 @@ describe Pry::InputCompleter do
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue