resque_unit 0.4.8 → 1.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,31 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 1.0.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Weiss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-12 00:00:00.000000000 Z
11
+ date: 2015-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: json
14
+ name: fakeredis
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.4.6
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.4.6
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: resque
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: resque-scheduler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: shoulda
56
+ name: pry-byebug
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -52,6 +66,34 @@ dependencies:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.0'
55
97
  description:
56
98
  email: justin@uberweiss.org
57
99
  executables: []
@@ -62,13 +104,11 @@ files:
62
104
  - README.md
63
105
  - lib/resque_unit.rb
64
106
  - lib/resque_unit/assertions.rb
65
- - lib/resque_unit/errors.rb
66
- - lib/resque_unit/helpers.rb
67
- - lib/resque_unit/plugin.rb
68
107
  - lib/resque_unit/resque.rb
69
- - lib/resque_unit/scheduler.rb
108
+ - lib/resque_unit/resque/test_extensions.rb
70
109
  - lib/resque_unit/scheduler_assertions.rb
71
110
  - lib/resque_unit_scheduler.rb
111
+ - test/redis_test.rb
72
112
  - test/resque_test.rb
73
113
  - test/resque_unit_scheduler_test.rb
74
114
  - test/resque_unit_test.rb
@@ -89,16 +129,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
129
  version: '0'
90
130
  required_rubygems_version: !ruby/object:Gem::Requirement
91
131
  requirements:
92
- - - ">="
132
+ - - ">"
93
133
  - !ruby/object:Gem::Version
94
- version: '0'
134
+ version: 1.3.1
95
135
  requirements: []
96
136
  rubyforge_project:
97
- rubygems_version: 2.2.2
137
+ rubygems_version: 2.4.5.1
98
138
  signing_key:
99
139
  specification_version: 4
100
- summary: Test::Unit support for resque job queueing
140
+ summary: Minitest and Test::Unit support for resque job queueing
101
141
  test_files:
142
+ - test/redis_test.rb
102
143
  - test/resque_test.rb
103
144
  - test/resque_unit_scheduler_test.rb
104
145
  - test/resque_unit_test.rb
@@ -1,17 +0,0 @@
1
- # Re-define errors in from Resque, in case the 'resque' gem was not loaded.
2
- module Resque
3
- # Raised whenever we need a queue but none is provided.
4
- unless defined?(NoQueueError)
5
- class NoQueueError < RuntimeError; end
6
- end
7
-
8
- # Raised when trying to create a job without a class
9
- unless defined?(NoClassError)
10
- class NoClassError < RuntimeError; end
11
- end
12
-
13
- # Raised when a worker was killed while processing a job.
14
- unless defined?(DirtyExit)
15
- class DirtyExit < RuntimeError; end
16
- end
17
- end
@@ -1,57 +0,0 @@
1
- module ResqueUnit
2
- module Helpers
3
- # Given a Ruby object, returns a string suitable for storage in a
4
- # queue.
5
- def encode(object)
6
- if defined? Yajl
7
- Yajl::Encoder.encode(object)
8
- else
9
- object.to_json
10
- end
11
- end
12
-
13
- # Given a string, returns a Ruby object.
14
- def decode(object)
15
- return unless object
16
-
17
- if defined? Yajl
18
- begin
19
- Yajl::Parser.parse(object, :check_utf8 => false)
20
- rescue Yajl::ParseError
21
- end
22
- else
23
- begin
24
- JSON.parse(object)
25
- rescue JSON::ParserError
26
- end
27
- end
28
- end
29
-
30
- # Given a word with dashes, returns a camel cased version of it.
31
- #
32
- # classify('job-name') # => 'JobName'
33
- def classify(dashed_word)
34
- dashed_word.split('-').each { |part| part[0] = part[0].chr.upcase }.join
35
- end
36
-
37
- # Given a camel cased word, returns the constant it represents
38
- #
39
- # constantize('JobName') # => JobName
40
- def constantize(camel_cased_word)
41
- camel_cased_word = camel_cased_word.to_s
42
-
43
- if camel_cased_word.include?('-')
44
- camel_cased_word = classify(camel_cased_word)
45
- end
46
-
47
- names = camel_cased_word.split('::')
48
- names.shift if names.empty? || names.first.empty?
49
-
50
- constant = Object
51
- names.each do |name|
52
- constant = constant.const_get(name) || constant.const_missing(name)
53
- end
54
- constant
55
- end
56
- end
57
- end
@@ -1,70 +0,0 @@
1
- # A copy of the original Resque:Plugin class from the "resque" gem
2
- # No need to redefine this class if the resque gem was already loaded
3
- unless defined?(Resque::Plugin)
4
-
5
- module Resque
6
- module Plugin
7
- extend self
8
-
9
- LintError = Class.new(RuntimeError)
10
-
11
- # Ensure that your plugin conforms to good hook naming conventions.
12
- #
13
- # Resque::Plugin.lint(MyResquePlugin)
14
- def lint(plugin)
15
- hooks = before_hooks(plugin) + around_hooks(plugin) + after_hooks(plugin)
16
-
17
- hooks.each do |hook|
18
- if hook =~ /perform$/
19
- raise LintError, "#{plugin}.#{hook} is not namespaced"
20
- end
21
- end
22
-
23
- failure_hooks(plugin).each do |hook|
24
- if hook =~ /failure$/
25
- raise LintError, "#{plugin}.#{hook} is not namespaced"
26
- end
27
- end
28
- end
29
-
30
- # Given an object, returns a list `before_perform` hook names.
31
- def before_hooks(job)
32
- job.methods.grep(/^before_perform/).sort
33
- end
34
-
35
- # Given an object, returns a list `around_perform` hook names.
36
- def around_hooks(job)
37
- job.methods.grep(/^around_perform/).sort
38
- end
39
-
40
- # Given an object, returns a list `after_perform` hook names.
41
- def after_hooks(job)
42
- job.methods.grep(/^after_perform/).sort
43
- end
44
-
45
- # Given an object, returns a list `on_failure` hook names.
46
- def failure_hooks(job)
47
- job.methods.grep(/^on_failure/).sort
48
- end
49
-
50
- # Given an object, returns a list `after_enqueue` hook names.
51
- def after_enqueue_hooks(job)
52
- job.methods.grep(/^after_enqueue/).sort
53
- end
54
-
55
- # Given an object, returns a list `before_enqueue` hook names.
56
- def before_enqueue_hooks(job)
57
- job.methods.grep(/^before_enqueue/).sort
58
- end
59
- end
60
- end
61
-
62
- end
63
-
64
- unless defined?(Resque::Job::DontPerform)
65
- module Resque
66
- class Job
67
- DontPerform = Class.new(StandardError)
68
- end
69
- end
70
- end
@@ -1,40 +0,0 @@
1
- module ResqueUnit
2
-
3
- # ResqueUnit::Scheduler is a group of functions mocking the behavior
4
- # of resque-scheduler. It is included into Resque when
5
- # 'resque_unit_scheduler' is required.
6
- module Scheduler
7
-
8
- # takes a timestamp which will be used to schedule the job
9
- # for queueing. Until timestamp is in the past, the job will
10
- # sit in the schedule list.
11
- def enqueue_at(timestamp, klass, *args)
12
- enqueue_with_timestamp(timestamp, klass, *args)
13
- end
14
-
15
- # Identical to enqueue_at but takes number_of_seconds_from_now
16
- # instead of a timestamp.
17
- def enqueue_in(number_of_seconds_from_now, klass, *args)
18
- enqueue_at(Time.now + number_of_seconds_from_now, klass, *args)
19
- end
20
-
21
- def enqueue_with_timestamp(timestamp, klass, *args)
22
- enqueue_unit(queue_for(klass), {"class" => klass.name, "args" => args, "timestamp" => timestamp})
23
- end
24
-
25
- def remove_delayed(klass, *args)
26
- # points to real queue
27
- encoded_job_payloads = Resque.queue(queue_for(klass))
28
- args ||= []
29
- encoded_job_payloads.delete_if { |e| e = Resque.decode(e); e["class"] == klass.to_s && e["args"] == args }
30
- end
31
-
32
- def remove_delayed_job_from_timestamp(timestamp, klass, *args)
33
- encoded_job_payloads = Resque.queue(queue_for(klass))
34
- args ||= []
35
- encoded_job_payloads.delete_if { |e| e = Resque.decode(e); e["class"] == klass.to_s && Time.parse(e["timestamp"]).to_i == Time.parse(timestamp.to_s).to_i && e["args"] == args }
36
- end
37
- end
38
-
39
- Resque.send(:extend, Scheduler)
40
- end