class Pry::BondCompleter

Pry::Bond is not the best name for a namespace, because all references to Bond from Pry now pointing to the “wrong” module

Constants

VERSION

Attributes

bond[R]

Public Class Methods

new(input, pry = nil) click to toggle source
# File lib/pry/bond/completer.rb, line 44
def initialize input, pry = nil
  BondCompleter.setup if BondCompleter.bond.nil?
  @pry = pry
  @input = input
end
setup(config={}) click to toggle source
# File lib/pry/bond/completer.rb, line 18
def self.setup(config={})
  @lock = Mutex.new
  @bond = Bond::M
  @bond.config.merge!(config)
  @bond.config[:readline] ||= NoopReadline
  @current_pry_instance = nil
  @bond.start(:eval_binding => lambda {@current_pry_instance.current_binding})
  @bond.complete(:on => /^(.+)$/, :place => :last, :name => "pry-autocomplete", :action => lambda {|input|
    Bond::DefaultMission.completions.map(&:to_s) + Pry.commands.complete(input.line,
                          :pry_instance => @current_pry_instance,
                          :target       => @current_pry_instance.current_binding,
                          :command_set  => @current_pry_instance.commands)
  })
end
with_pry(instance) { || ... } click to toggle source
# File lib/pry/bond/completer.rb, line 33
def self.with_pry instance
  @lock.synchronize do
    begin
      @current_pry_instance = instance
      yield
    ensure
      @current_pry_instance = nil 
    end
  end
end

Public Instance Methods

call(str, options) click to toggle source
# File lib/pry/bond/completer.rb, line 50
def call str, options
  BondCompleter.with_pry(@pry) {BondCompleter.bond.agent.call(str, get_full_line_input || str)}
end

Protected Instance Methods

get_full_line_input() click to toggle source
# File lib/pry/bond/completer.rb, line 55
def get_full_line_input
  if @input.respond_to?(:line_buffer)
    @input.line_buffer
  elsif @input.respond_to? :line
    @input.line
  else
    nil
  end
end