Skip to content

Commit

Permalink
Further style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Cygan committed Dec 17, 2014
1 parent b70c3ef commit 2d0bff6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/sidekiq/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def initialize(name)
end

def size
Sidekiq.redis {|c| c.zcard(name) }
Sidekiq.redis { |c| c.zcard(name) }
end

def clear
Expand Down Expand Up @@ -411,7 +411,7 @@ def each(&block)
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
Expand Down
4 changes: 2 additions & 2 deletions lib/sidekiq/middleware/server/retry_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def retries_exhausted(worker, msg)
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
Expand Down Expand Up @@ -183,7 +183,7 @@ def retry_in(worker, count)
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
Expand Down
4 changes: 2 additions & 2 deletions lib/sidekiq/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Util
def watchdog(last_words)
yield
rescue Exception => ex
handle_exception(ex, { :context => last_words })
handle_exception(ex, { context: last_words })
raise ex
end

Expand All @@ -39,7 +39,7 @@ def fire_event(event)
begin
block.call
rescue => ex
handle_exception(ex, { :event => event })
handle_exception(ex, { event: event })
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/sidekiq/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def custom_tabs
@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

Expand All @@ -85,8 +85,8 @@ def custom_tabs

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

Expand Down Expand Up @@ -128,7 +128,7 @@ def custom_tabs
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

Expand Down Expand Up @@ -167,7 +167,7 @@ def custom_tabs
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

Expand Down
8 changes: 4 additions & 4 deletions lib/sidekiq/web_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def redis_connection
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
Expand Down Expand Up @@ -110,9 +110,9 @@ def parse_params(params)
# 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)
Expand Down Expand Up @@ -147,7 +147,7 @@ def number_with_delimiter(number)
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])
Expand Down

0 comments on commit 2d0bff6

Please sign in to comment.