Module: Bond::Rc
Overview
Namespace in which completion files, ~/.bondrc and ~/.bond/completions/*.rb, are evaluated. Methods in this module and Search are the DSL in completion files and can be used within completion actions.
Example ~/.bondrc
# complete arguments for any object's :respond_to?
complete(:method => "Object#respond_to?") {|e| e.object.methods }
# complete arguments for any module's :public
complete(:method => "Module#public") {|e| e.object.instance_methods }
# Share generate_tags action across completions
complete(:method => "edit_tags", :action => :generate_tags)
complete(:method => "delete_tags", :search => false) {|e| generate_tags(e).grep(/#{e}/i) }
def generate_tags(input)
...
end
Instance Method Summary collapse
-
#complete(*args, &block) ⇒ Object
See #complete.
-
#eval(str) ⇒ Object
Calls eval with Mission.current_eval, rescuing any exceptions to return nil.
-
#files(input) ⇒ Object
Action method with search which returns array of files that match current input.
-
#objects_of(klass) ⇒ Object
Helper method which returns objects of a given class.
-
#recomplete(*args, &block) ⇒ Object
See #recomplete.
Methods included from Search
anywhere_search, default_search, files_search, ignore_case_search, incremental_filter, modules_search, normal_search, underscore_search
Instance Method Details
#complete(*args, &block) ⇒ Object
See Bond#complete
22 |
# File 'lib/bond/rc.rb', line 22 def complete(*args, &block); M.complete(*args, &block); end |
#eval(str) ⇒ Object
Calls eval with Mission.current_eval, rescuing any exceptions to return nil. If Bond.config is true, exceptions are raised again.
42 43 44 45 46 |
# File 'lib/bond/rc.rb', line 42 def eval(str) Mission.current_eval(str) rescue Exception raise if Bond.config[:debug] end |
#files(input) ⇒ Object
Action method with search which returns array of files that match current input.
27 28 29 30 31 |
# File 'lib/bond/rc.rb', line 27 def files(input) (::Readline::FILENAME_COMPLETION_PROC.call(input) || []).map {|f| f =~ /^~/ ? File.(f) : f } end |
#objects_of(klass) ⇒ Object
Helper method which returns objects of a given class.
34 35 36 37 38 |
# File 'lib/bond/rc.rb', line 34 def objects_of(klass) object = [] ObjectSpace.each_object(klass) {|e| object.push(e) } object end |
#recomplete(*args, &block) ⇒ Object
See Bond#recomplete
24 |
# File 'lib/bond/rc.rb', line 24 def recomplete(*args, &block); M.recomplete(*args, &block); end |