Skip to content

Commit

Permalink
rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
jugyo committed Mar 21, 2009
1 parent f520b2f commit 44270eb
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/standard_plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ module Termtter::Client
["show ID", "Show a single status"]
]
helps += @@helps
helps += @@new_commands.map {|name, command| command.help}
helps += @@commands.map {|name, command| command.help}
helps.compact!
puts formatted_help(helps)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/termtter/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def call_hooks(point, *args)
result = nil
get_hooks(point).each {|hook|
break if result == false # interrupt if hook return false
result = hook.execute(*args)
result = hook.call(*args)
}
result
rescue => e
Expand Down Expand Up @@ -159,7 +159,7 @@ def call_commands(text, tw = nil)
pre_exec_hook_result = call_hooks("pre_exec_#{command.name.to_s}", command_str, modified_arg)
next if pre_exec_hook_result == false
# exec command
result = command.execute(modified_arg)
result = command.call(modified_arg)
if result
call_hooks("post_exec_#{command.name.to_s}", command_str, modified_arg, result)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/termtter/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def complement(input)
end
end

def execute(arg)
def call(arg)
arg = case arg
when nil
''
Expand Down
2 changes: 1 addition & 1 deletion lib/termtter/hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def match?(point)
end

# TODO: need spec
def execute(*args)
def call(*args)
self.exec_proc.call(*args)
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/termtter/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Termtter

describe Client do

it 'should take new_command' do
it 'should take command' do
command = Command.new(:name => :test)
Client.register_command(command)
Client.get_command(:test).should == command
Expand All @@ -17,7 +17,7 @@ module Termtter
Client.get_command(:test).name.should == :test
end

it 'should call new_command' do
it 'should call command' do
command_arg = nil
command = Command.new(:name => :test, :exec_proc => lambda {|arg| command_arg = arg})
Client.register_command(command)
Expand Down Expand Up @@ -49,7 +49,7 @@ module Termtter
hook_called = false
Client.register_hook(:name => :test1, :points => [:point1], :exec_proc => lambda {hook_called = true})
hook_called.should == false
Client.call_new_hooks(:point1)
Client.call_hooks(:point1)
hook_called.should == true
end

Expand All @@ -59,7 +59,7 @@ module Termtter
Client.register_hook(:name => :test1, :points => [:point1], :exec_proc => lambda {|a1, a2| arg1 = a1; arg2 = a2})
arg1.should == nil
arg2.should == nil
Client.call_new_hooks(:point1, 'foo', 'bar')
Client.call_hooks(:point1, 'foo', 'bar')
arg1.should == 'foo'
arg2.should == 'bar'
end
Expand Down Expand Up @@ -180,7 +180,7 @@ module Termtter
Client.should_receive(:load_config)
Termtter::API.should_receive(:setup)
Client.should_receive(:post_config_load)
Client.should_receive(:call_new_hooks)
Client.should_receive(:call_hooks)
Client.should_receive(:setup_update_timeline_task)
Client.should_receive(:start_input_thread)
Client.run
Expand Down
20 changes: 10 additions & 10 deletions spec/termtter/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,18 @@ module Termtter
lambda { Command.new(:aliases => ['u']) }.should raise_error(ArgumentError)
end

it 'should call exec_proc when call method "execute"' do
@command.execute('test').should == 'test'
@command.execute(' test').should == ' test'
@command.execute(' test ').should == ' test '
@command.execute('test test').should == 'test test'
it 'should call exec_proc when call method "call"' do
@command.call('test').should == 'test'
@command.call(' test').should == ' test'
@command.call(' test ').should == ' test '
@command.call('test test').should == 'test test'
end

it 'should raise ArgumentError at execute' do
lambda { @command.execute(nil) }.should_not raise_error(ArgumentError)
lambda { @command.execute('foo') }.should_not raise_error(ArgumentError)
lambda { @command.execute(false) }.should raise_error(ArgumentError)
lambda { @command.execute(Array.new) }.should raise_error(ArgumentError)
it 'should raise ArgumentError at call' do
lambda { @command.call(nil) }.should_not raise_error(ArgumentError)
lambda { @command.call('foo') }.should_not raise_error(ArgumentError)
lambda { @command.call(false) }.should raise_error(ArgumentError)
lambda { @command.call(Array.new) }.should raise_error(ArgumentError)
end
end
end
Expand Down

0 comments on commit 44270eb

Please sign in to comment.