Skip to content

Commit

Permalink
Constant TimeoutError is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
id774 committed Jul 5, 2016
1 parent f009b4d commit 7fd4ef4
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 10 deletions.
3 changes: 2 additions & 1 deletion bin/termtter_frame
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ARGV.unshift '-m' unless ARGV.include?('-m') #monochrome

require 'singleton'
require 'termtter'
require 'timeout'

module Termtter
class CommandLine
Expand Down Expand Up @@ -52,7 +53,7 @@ module Termtter
hooks.each {|hook|
hook.call(command_text)
}
rescue TimeoutError
rescue Timeout::Error
puts TermColor.parse("<red>Time out :(</red>")
end

Expand Down
4 changes: 3 additions & 1 deletion lib/plugins/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'timeout'

config.plugins.channel.set_default(:auto_reload_channels, {})
config.plugins.channel.set_default(:short_names, {})
config.plugins.channel.set_default(:colorize, true)
Expand Down Expand Up @@ -139,7 +141,7 @@ def call_by_channel(c, *opt)
Readline.refresh_line
end
end
rescue TimeoutError
rescue Timeout::Error
# do nothing
rescue Exception => e
Termtter::Client.handle_error(e)
Expand Down
5 changes: 4 additions & 1 deletion lib/plugins/defaults/auto_reload.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-

require 'timeout'

auto_reload_proc = lambda do
begin
Termtter::Client.execute('reload -r')
rescue TimeoutError
rescue Timeout::Error
# do nothing
rescue
rescue Exception => e
Expand Down
3 changes: 2 additions & 1 deletion lib/plugins/defaults/command_line.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
require 'singleton'
require 'timeout'

module Termtter
class CommandLine
Expand Down Expand Up @@ -38,7 +39,7 @@ def call(command_text)
hooks.each {|hook|
hook.call(command_text)
}
rescue TimeoutError
rescue Timeout::Error
puts TermColor.parse("<red>Time out :(</red>")
end

Expand Down
4 changes: 3 additions & 1 deletion lib/plugins/defaults/list.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
require 'timeout'

module Termtter::Client
public_storage[:lists] = []

register_hook(:fetch_my_lists, :point => :launched) do
begin
public_storage[:lists] +=
Termtter::API.twitter.lists(:screen_name => config.user_name).map(&:full_name)
rescue TimeoutError
rescue Timeout::Error
# do nothing
rescue Exception => e
Termtter::Client.handle_error(e)
Expand Down
3 changes: 2 additions & 1 deletion lib/termtter/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'fileutils'
require 'logger'
require 'termcolor'
require 'timeout'

module Termtter
class CommandNotFound < StandardError; end
Expand Down Expand Up @@ -187,7 +188,7 @@ def execute(text)
end
return true
end
rescue TimeoutError
rescue Timeout::Error
call_hooks("timeout", text)
raise
end
Expand Down
4 changes: 2 additions & 2 deletions lib/termtter/rubytter_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def method_missing(method, *args, &block)

self.class.call_hooks("post_#{method}", *args)
rescue HookCanceled
rescue TimeoutError => e
rescue Timeout::Error => e
Termtter::Client.logger.debug {
"rubytter_proxy: #{method}(#{modified_args.inspect[1...-1]}) " +
"#{e.message} #{'%.2fsec' % (Time.now - from)}"
Expand Down Expand Up @@ -147,7 +147,7 @@ def call_rubytter(method, *args, &block)
else
raise e
end
rescue StandardError, TimeoutError => e
rescue StandardError, Timeout::Error => e
if now + 1 == config.retry
raise e
else
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
$:.unshift(File.dirname(__FILE__) + '/../lib')
ARGV.delete '-c'
require 'termtter'
require 'timeout'

if ENV['COVERAGE'] == 'on'
require 'simplecov'
Expand Down
4 changes: 2 additions & 2 deletions spec/termtter/rubytter_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ module Termtter
@twitter.update('test')
end

it 'should retry when raise TimeoutError' do
it 'should retry when raise Timeout::Error' do
pending("Not yet implemented")
config.retry = 3
@rubytter_mock.stub!(:update).exactly(config.retry).times.and_raise(TimeoutError)
@rubytter_mock.stub!(:update).exactly(config.retry).times.and_raise(Timeout::Error)
@twitter.update('test')
end

Expand Down

0 comments on commit 7fd4ef4

Please sign in to comment.