зеркало из https://github.com/github/ruby.git
[ruby/reline] Add Reline.dialog_proc(name_sym)
https://github.com/ruby/reline/commit/7e5dbe4750
This commit is contained in:
Родитель
ec517d60b0
Коммит
c462e07a5c
|
@ -161,6 +161,12 @@ module Reline
|
|||
@dialog_proc_list << [name_sym, p, context]
|
||||
end
|
||||
|
||||
def dialog_proc(name_sym)
|
||||
dialog = @dialog_proc_list.find { |d| d[0] == name_sym }
|
||||
dialog.nil? ? nil : dialog[1]
|
||||
#@dialog_proc_list[name_sym]
|
||||
end
|
||||
|
||||
def input=(val)
|
||||
raise TypeError unless val.respond_to?(:getc) or val.nil?
|
||||
if val.respond_to?(:getc)
|
||||
|
@ -516,6 +522,7 @@ module Reline
|
|||
def_single_delegators :core, :last_incremental_search
|
||||
def_single_delegators :core, :last_incremental_search=
|
||||
def_single_delegators :core, :add_dialog_proc
|
||||
def_single_delegators :core, :dialog_proc
|
||||
def_single_delegators :core, :autocompletion, :autocompletion=
|
||||
|
||||
def_single_delegators :core, :readmultiline
|
||||
|
|
|
@ -313,9 +313,13 @@ class Reline::Test < Reline::TestCase
|
|||
def test_add_dialog_proc
|
||||
p = proc {}
|
||||
Reline.add_dialog_proc(:test_proc, p)
|
||||
assert_equal(p, Reline.dialog_proc(:test_proc))
|
||||
|
||||
l = lambda {}
|
||||
Reline.add_dialog_proc(:test_lambda, l)
|
||||
assert_equal(l, Reline.dialog_proc(:test_lambda))
|
||||
|
||||
assert_equal(nil, Reline.dialog_proc(:test_nothing))
|
||||
|
||||
assert_raise(ArgumentError) { Reline.add_dialog_proc(:error, 42) }
|
||||
assert_raise(ArgumentError) { Reline.add_dialog_proc(:error, 'hoge') }
|
||||
|
@ -323,6 +327,7 @@ class Reline::Test < Reline::TestCase
|
|||
|
||||
dummy = DummyCallbackObject.new
|
||||
Reline.add_dialog_proc(:dummy, dummy)
|
||||
assert_equal(dummy, Reline.dialog_proc(:dummy))
|
||||
end
|
||||
|
||||
def test_readmultiline
|
||||
|
|
Загрузка…
Ссылка в новой задаче