Skip to content

Commit

Permalink
Bump version locked dependencies + refresh rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
meatballhat committed May 24, 2016
1 parent e6f4cda commit c9d45ee
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 59 deletions.
26 changes: 18 additions & 8 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-04-22 13:22:42 -0400 using RuboCop version 0.35.1.
# on 2016-05-24 19:32:49 -0400 using RuboCop version 0.40.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -13,6 +13,11 @@ Lint/AssignmentInCondition:
- 'lib/resque/scheduler/delaying_extensions.rb'
- 'lib/resque/scheduler/env.rb'

# Offense count: 2
Lint/UselessAccessModifier:
Exclude:
- 'lib/resque/scheduler.rb'

# Offense count: 16
Metrics/AbcSize:
Max: 36
Expand All @@ -21,10 +26,11 @@ Metrics/AbcSize:
Metrics/CyclomaticComplexity:
Max: 12

# Offense count: 2
# Configuration parameters: AllowURI, URISchemes.
# Offense count: 5
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 87
Max: 96

# Offense count: 19
# Configuration parameters: CountComments.
Expand All @@ -34,7 +40,7 @@ Metrics/MethodLength:
# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 314
Max: 313

# Offense count: 1
Style/CaseEquality:
Expand All @@ -47,16 +53,20 @@ Style/EachWithObject:
- 'lib/resque/scheduler.rb'

# Offense count: 3
# Configuration parameters: Exclude.
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
Style/FileName:
Exclude:
- 'examples/config/initializers/resque-web.rb'
- 'lib/resque-scheduler.rb'
- 'test/resque-web_test.rb'

# Offense count: 5
# Offense count: 1
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/resque/scheduler.rb'
- 'lib/resque/scheduler/lock/basic.rb'

# Offense count: 1
Style/IfInsideElse:
Exclude:
- 'lib/resque/scheduler.rb'
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rvm:
env:
global:
- COVERAGE=1
- JRUBY_OPTS=''
matrix:
allow_failures:
- rvm: jruby-9.1.1.0
Expand Down
20 changes: 10 additions & 10 deletions examples/config/initializers/resque-web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@

schedule_yml = ENV['RESQUE_SCHEDULE_YML']
if schedule_yml
if File.exist?(schedule_yml)
Resque.schedule = YAML.load_file(schedule_yml)
else
Resque.schedule = YAML.load(schedule_yml)
end
Resque.schedule = if File.exist?(schedule_yml)
YAML.load_file(schedule_yml)
else
YAML.load(schedule_yml)
end
end

schedule_json = ENV['RESQUE_SCHEDULE_JSON']
if schedule_json
if File.exist?(schedule_json)
Resque.schedule = JSON.parse(File.read(schedule_json))
else
Resque.schedule = JSON.parse(schedule_json)
end
Resque.schedule = if File.exist?(schedule_json)
JSON.parse(File.read(schedule_json))
else
JSON.parse(schedule_json)
end
end

class Putter
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic-scheduling/app/jobs/fix_schedules_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def self.perform
users_unscheduled << user if schedule.nil?
end

if users_unscheduled.length > 0
unless users_unscheduled.empty?
users_unscheduled.each do |user|
name = "send_email_#{user.id}"
config = {}
Expand Down
2 changes: 1 addition & 1 deletion lib/resque/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def load_schedule_job(name, config)
interval_defined = false
interval_types = %w(cron every)
interval_types.each do |interval_type|
next unless !config[interval_type].nil? && config[interval_type].length > 0
next unless !config[interval_type].nil? && !config[interval_type].empty?
args = optionizate_interval_value(config[interval_type])
args = [args, nil, job: true] if args.is_a?(::String)

Expand Down
4 changes: 2 additions & 2 deletions lib/resque/scheduler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Scheduler
pidfile: 'PIDFILE',
poll_sleep_amount: 'RESQUE_SCHEDULER_INTERVAL',
verbose: 'VERBOSE'
}
}.freeze

class Cli
BANNER = <<-EOF.gsub(/ {6}/, '')
Expand Down Expand Up @@ -129,7 +129,7 @@ def option_parser
OptionParser.new do |opts|
opts.banner = BANNER
OPTIONS.each do |opt|
opts.on(*opt[:args], &(opt[:callback].call(options)))
opts.on(*opt[:args], &opt[:callback].call(options))
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/resque/scheduler/delaying_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def enqueue_delayed(klass, *args)
# This allows for removal of delayed jobs that have arguments matching
# certain criteria
def remove_delayed_selection(klass = nil)
fail ArgumentError, 'Please supply a block' unless block_given?
raise ArgumentError, 'Please supply a block' unless block_given?

found_jobs = find_delayed_selection(klass) { |args| yield(args) }
found_jobs.reduce(0) do |sum, encoded_job|
Expand All @@ -169,7 +169,7 @@ def remove_delayed_selection(klass = nil)
# This allows for enqueuing of delayed jobs that have arguments matching
# certain criteria
def enqueue_delayed_selection(klass = nil)
fail ArgumentError, 'Please supply a block' unless block_given?
raise ArgumentError, 'Please supply a block' unless block_given?

found_jobs = find_delayed_selection(klass) { |args| yield(args) }
found_jobs.reduce(0) do |sum, encoded_job|
Expand All @@ -184,7 +184,7 @@ def enqueue_delayed_selection(klass = nil)
# This allows for finding of delayed jobs that have arguments matching
# certain criteria
def find_delayed_selection(klass = nil, &block)
fail ArgumentError, 'Please supply a block' unless block_given?
raise ArgumentError, 'Please supply a block' unless block_given?

found_jobs = []
start = nil
Expand Down
4 changes: 2 additions & 2 deletions lib/resque/scheduler/lock/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(key, options = {})

# Attempts to acquire the lock. Returns true if successfully acquired.
def acquire!
fail NotImplementedError
raise NotImplementedError
end

def value
Expand All @@ -25,7 +25,7 @@ def value

# Returns true if you currently hold the lock.
def locked?
fail NotImplementedError
raise NotImplementedError
end

# Releases the lock.
Expand Down
15 changes: 8 additions & 7 deletions lib/resque/scheduler/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
module Resque
module Scheduler
module Server
TIMESTAMP_FORMAT = '%Y-%m-%d %H:%M:%S %z'
TIMESTAMP_FORMAT = '%Y-%m-%d %H:%M:%S %z'.freeze

unless defined?(::Resque::Scheduler::Server::VIEW_PATH)
VIEW_PATH = File.join(File.dirname(__FILE__), 'server', 'views')
Expand Down Expand Up @@ -158,15 +158,15 @@ def find_job(worker)
dels = delayed_jobs_for_worker(worker)
results += dels.select do |j|
j['class'].downcase.include?(worker) &&
j.merge!('where_at' => 'delayed')
j.merge!('where_at' => 'delayed')
end

Resque.queues.each do |queue|
queued = Resque.peek(queue, 0, Resque.size(queue))
queued = [queued] unless queued.is_a?(Array)
results += queued.select do |j|
j['class'].downcase.include?(worker) &&
j.merge!('queue' => queue, 'where_at' => 'queued')
j.merge!('queue' => queue, 'where_at' => 'queued')
end
end

Expand Down Expand Up @@ -231,7 +231,7 @@ def working_jobs_for_worker(worker)
working = [*Resque.working]
work = working.select do |w|
w.job && w.job['payload'] &&
w.job['payload']['class'].downcase.include?(worker)
w.job['payload']['class'].downcase.include?(worker)
end
work.each do |w|
results += [
Expand All @@ -248,9 +248,10 @@ def delayed_jobs_for_worker(_worker)
schedule_size = Resque.delayed_queue_schedule_size
Resque.delayed_queue_peek(0, schedule_size).each do |d|
Resque.delayed_timestamp_peek(
d, 0, Resque.delayed_timestamp_size(d)).each do |j|
dels << j.merge!('timestamp' => d)
end
d, 0, Resque.delayed_timestamp_size(d)
).each do |j|
dels << j.merge!('timestamp' => d)
end
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/resque/scheduler/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def self.constantize(camel_cased_word)
names.each do |name|
args = Module.method(:const_get).arity != 1 ? [false] : []

if constant.const_defined?(name, *args)
constant = constant.const_get(name)
else
constant = constant.const_missing(name)
end
constant = if constant.const_defined?(name, *args)
constant.const_get(name)
else
constant.const_missing(name)
end
end
constant
end
Expand Down
2 changes: 1 addition & 1 deletion lib/resque/scheduler/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Resque
module Scheduler
VERSION = '4.2.0'
VERSION = '4.2.0'.freeze
end
end
6 changes: 3 additions & 3 deletions resque-scheduler.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ Gem::Specification.new do |spec|

# We pin rubocop because new cops have a tendency to result in false-y
# positives for new contributors, which is not a nice experience.
spec.add_development_dependency 'rubocop', '~> 0.35.1'
spec.add_development_dependency 'rubocop', '~> 0.40.0'

spec.add_runtime_dependency 'mono_logger', '~> 1.0'
spec.add_runtime_dependency 'redis', '~> 3.0'
spec.add_runtime_dependency 'resque', '~> 1.25'
spec.add_runtime_dependency 'redis', '~> 3.3'
spec.add_runtime_dependency 'resque', '~> 1.26'
spec.add_runtime_dependency 'rufus-scheduler', '~> 3.2'
end
4 changes: 2 additions & 2 deletions test/delayed_queue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
test 'calls klass#scheduled when enqueuing jobs if it exists' do
t = Time.now - 60
FakeCustomJobClassEnqueueAt.expects(:scheduled)
.once.with(:test, FakeCustomJobClassEnqueueAt.to_s, foo: 'bar')
.once.with(:test, FakeCustomJobClassEnqueueAt.to_s, foo: 'bar')
Resque.enqueue_at(t, FakeCustomJobClassEnqueueAt, foo: 'bar')
end

Expand All @@ -258,7 +258,7 @@
Resque.inline = true
t = Time.now - 60
FakeCustomJobClassEnqueueAt.expects(:scheduled)
.once.with(:test, FakeCustomJobClassEnqueueAt.to_s, foo: 'bar')
.once.with(:test, FakeCustomJobClassEnqueueAt.to_s, foo: 'bar')
Resque.enqueue_at(t, FakeCustomJobClassEnqueueAt, foo: 'bar')
ensure
Resque.inline = old_val
Expand Down
4 changes: 2 additions & 2 deletions test/multi_process_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def get_results_from_children(children)
children.each do |pid, pipe|
wait_for_child_process_to_terminate(pid)

fail "forked process failed with #{$CHILD_STATUS}" unless $CHILD_STATUS.success?
raise "forked process failed with #{$CHILD_STATUS}" unless $CHILD_STATUS.success?
result, exc = Marshal.load(pipe.read)
fail exc if exc
raise exc if exc
results << result
end
results
Expand Down
6 changes: 3 additions & 3 deletions test/resque-web_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
test('is 200') { assert last_response.ok? }
end

context 'on GET to /delayed/jobs/:klass'do
context 'on GET to /delayed/jobs/:klass' do
setup do
@t = Time.now + 3600
Resque.enqueue_at(@t, SomeIvarJob, 'foo', 'bar')
Expand Down Expand Up @@ -144,7 +144,7 @@ module Test
}
}
}
}
}.freeze
end

context 'POST /schedule/requeue' do
Expand All @@ -157,7 +157,7 @@ module Test
# Regular jobs without params should redirect to /overview
job_name = 'job_without_params'
Resque::Scheduler.stubs(:enqueue_from_config)
.once.with(Resque.schedule[job_name])
.once.with(Resque.schedule[job_name])

post '/schedule/requeue', 'job_name' => job_name
follow_redirect!
Expand Down
10 changes: 5 additions & 5 deletions test/scheduler_args_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

test 'enqueue_from_config puts stuff in resque without class loaded' do
Resque::Job.stubs(:create).once.returns(true)
.with('joes_queue', 'UndefinedJob', '/tmp')
.with('joes_queue', 'UndefinedJob', '/tmp')
Resque::Scheduler.enqueue_from_config(
'cron' => '* * * * *',
'class' => 'UndefinedJob',
Expand All @@ -25,7 +25,7 @@

test 'enqueue_from_config with_every_syntax' do
Resque::Job.stubs(:create).once.returns(true)
.with('james_queue', 'JamesJob', '/tmp')
.with('james_queue', 'JamesJob', '/tmp')
Resque::Scheduler.enqueue_from_config(
'every' => '1m',
'class' => 'JamesJob',
Expand All @@ -36,7 +36,7 @@

test 'enqueue_from_config puts jobs in the resque queue' do
Resque::Job.stubs(:create).once.returns(true)
.with(:ivar, SomeIvarJob, '/tmp')
.with(:ivar, SomeIvarJob, '/tmp')
Resque::Scheduler.enqueue_from_config(
'cron' => '* * * * *',
'class' => 'SomeIvarJob',
Expand All @@ -46,7 +46,7 @@

test 'enqueue_from_config with custom_class_job in resque' do
FakeCustomJobClass.stubs(:scheduled).once.returns(true)
.with(:ivar, 'SomeIvarJob', '/tmp')
.with(:ivar, 'SomeIvarJob', '/tmp')
Resque::Scheduler.enqueue_from_config(
'cron' => '* * * * *',
'class' => 'SomeIvarJob',
Expand Down Expand Up @@ -207,7 +207,7 @@
second_key: value
YAML
SomeIvarJob.expects(:perform).once
.with('first_key' => { 'second_key' => 'value' })
.with('first_key' => { 'second_key' => 'value' })
Resque.reserve('ivar').perform
end

Expand Down
Loading

0 comments on commit c9d45ee

Please sign in to comment.