1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Further style improvements

This commit is contained in:
Artur Cygan 2014-12-17 21:09:20 +01:00
parent b70c3ef50d
commit 2d0bff6351
5 changed files with 15 additions and 15 deletions

View file

@ -382,7 +382,7 @@ module Sidekiq
end
def size
Sidekiq.redis {|c| c.zcard(name) }
Sidekiq.redis { |c| c.zcard(name) }
end
def clear
@ -411,7 +411,7 @@ module Sidekiq
range_start = page * page_size + offset_size
range_end = page * page_size + offset_size + (page_size - 1)
elements = Sidekiq.redis do |conn|
conn.zrange name, range_start, range_end, :with_scores => true
conn.zrange name, range_start, range_end, with_scores: true
end
break if elements.empty?
page -= 1

View file

@ -143,7 +143,7 @@ module Sidekiq
worker.sidekiq_retries_exhausted_block.call(msg)
end
rescue => e
handle_exception(e, { :context => "Error calling retries_exhausted for #{worker.class}", :job => msg })
handle_exception(e, { context: "Error calling retries_exhausted for #{worker.class}", job: msg })
end
send_to_morgue(msg) unless msg['dead'] == false
@ -183,7 +183,7 @@ module Sidekiq
begin
worker.sidekiq_retry_in_block.call(count)
rescue Exception => e
handle_exception(e, { :context => "Failure scheduling retry using the defined `sidekiq_retry_in` in #{worker.class.name}, falling back to default" })
handle_exception(e, { context: "Failure scheduling retry using the defined `sidekiq_retry_in` in #{worker.class.name}, falling back to default" })
nil
end
end

View file

@ -14,7 +14,7 @@ module Sidekiq
def watchdog(last_words)
yield
rescue Exception => ex
handle_exception(ex, { :context => last_words })
handle_exception(ex, { context: last_words })
raise ex
end
@ -39,7 +39,7 @@ module Sidekiq
begin
block.call
rescue => ex
handle_exception(ex, { :event => event })
handle_exception(ex, { event: event })
end
end
end

View file

@ -69,7 +69,7 @@ module Sidekiq
@name = params[:name]
@queue = Sidekiq::Queue.new(@name)
(@current_page, @total_size, @messages) = page("queue:#{@name}", params[:page], @count)
@messages = @messages.map {|msg| Sidekiq::Job.new(msg, @name) }
@messages = @messages.map { |msg| Sidekiq::Job.new(msg, @name) }
erb :queue
end
@ -85,8 +85,8 @@ module Sidekiq
get '/morgue' do
@count = (params[:count] || 25).to_i
(@current_page, @total_size, @dead) = page("dead", params[:page], @count, :reverse => true)
@dead = @dead.map {|msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
(@current_page, @total_size, @dead) = page("dead", params[:page], @count, reverse: true)
@dead = @dead.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
erb :morgue
end
@ -128,7 +128,7 @@ module Sidekiq
get '/retries' do
@count = (params[:count] || 25).to_i
(@current_page, @total_size, @retries) = page("retry", params[:page], @count)
@retries = @retries.map {|msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
@retries = @retries.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
erb :retries
end
@ -167,7 +167,7 @@ module Sidekiq
get '/scheduled' do
@count = (params[:count] || 25).to_i
(@current_page, @total_size, @scheduled) = page("schedule", params[:page], @count)
@scheduled = @scheduled.map {|msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
@scheduled = @scheduled.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
erb :scheduled
end

View file

@ -65,7 +65,7 @@ module Sidekiq
end
def namespace
@@ns ||= Sidekiq.redis {|conn| conn.respond_to?(:namespace) ? conn.namespace : nil }
@@ns ||= Sidekiq.redis { |conn| conn.respond_to?(:namespace) ? conn.namespace : nil }
end
def redis_info
@ -110,9 +110,9 @@ module Sidekiq
# Merge options with current params, filter safe params, and stringify to query string
def qparams(options)
options = options.stringify_keys
params.merge(options).map { |key, value|
params.merge(options).map do |key, value|
SAFE_QPARAMS.include?(key) ? "#{key}=#{value}" : next
}.join("&")
end.join("&")
end
def truncate(text, truncate_after_chars = 2000)
@ -147,7 +147,7 @@ module Sidekiq
return number
end
options = {:delimiter => ',', :separator => '.'}
options = {delimiter: ',', separator: '.'}
parts = number.to_s.to_str.split('.')
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{options[:delimiter]}")
parts.join(options[:separator])