qe 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d5d103943b57c5379eae62343dcd251b55427a6
4
- data.tar.gz: 7b54ece3f2ada83d0653c967dccdfa6d69e7201d
3
+ metadata.gz: e9a7a8be2452bf7a28feac011c403dd167be6649
4
+ data.tar.gz: 01bd26a4b64b180294fcef65ef61a431b830c128
5
5
  SHA512:
6
- metadata.gz: 82deb1ea3844a3ae856d782b68b4605c96e7038fc8fb13cb48525c7dde874eab2258064430b8f2f482dfc87955d37082308e0633f5f2d1bf33ab1bcff41c8e5b
7
- data.tar.gz: 23730bbb17b303ae805d0c965a1b06d7a756ea196981561f9139163d5078f45abf52cff5512eac2707d187b9d7ce83329539f7381d25c5b2dfb1fe19c9efcf9b
6
+ metadata.gz: dda74e97109518db33edc375c88ff40120e06df1d9936e940d00d78cc2f9e5514a3b9c1f0346f05af8861bd17f4331253ecde6f58149a73cc8a4592f9909ef3c
7
+ data.tar.gz: 6bac9793acfa1a0ced8e23324fa4a1a4434d89671368b9ea66e93dc560e017b806c920333512471e3d75ad9559cdf391595102c1a0dc8fb7fa9dab2bf23b9eaf
data/Gemfile CHANGED
@@ -3,4 +3,3 @@ gemspec
3
3
 
4
4
  gem "delayed_job", "~> 4.0.0.beta2"
5
5
  gem "delayed_job_active_record", "~> 4.0.0.beta3"
6
- gem "rspec", "~> 2.14.0.rc1"
@@ -1,101 +1,100 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qe (0.3.2)
4
+ qe (0.3.3)
5
5
  activesupport
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (4.0.0)
11
- activesupport (= 4.0.0)
10
+ activemodel (4.0.2)
11
+ activesupport (= 4.0.2)
12
12
  builder (~> 3.1.0)
13
- activerecord (4.0.0)
14
- activemodel (= 4.0.0)
13
+ activerecord (4.0.2)
14
+ activemodel (= 4.0.2)
15
15
  activerecord-deprecated_finders (~> 1.0.2)
16
- activesupport (= 4.0.0)
16
+ activesupport (= 4.0.2)
17
17
  arel (~> 4.0.0)
18
18
  activerecord-deprecated_finders (1.0.3)
19
- activesupport (4.0.0)
19
+ activesupport (4.0.2)
20
20
  i18n (~> 0.6, >= 0.6.4)
21
21
  minitest (~> 4.2)
22
22
  multi_json (~> 1.3)
23
23
  thread_safe (~> 0.1)
24
24
  tzinfo (~> 0.3.37)
25
- arel (4.0.0)
26
- atomic (1.1.12)
27
- awesome_print (1.1.0)
28
- backburner (0.4.3)
25
+ arel (4.0.1)
26
+ atomic (1.1.14)
27
+ awesome_print (1.2.0)
28
+ backburner (0.4.5)
29
29
  beaneater (~> 0.3.1)
30
30
  dante (~> 0.1.5)
31
- beaneater (0.3.1)
31
+ beaneater (0.3.2)
32
32
  builder (3.1.4)
33
- celluloid (0.14.1)
34
- timers (>= 1.0.0)
35
- coderay (1.0.9)
36
- connection_pool (1.1.0)
33
+ celluloid (0.15.2)
34
+ timers (~> 1.1.0)
35
+ coderay (1.1.0)
36
+ connection_pool (1.2.0)
37
37
  dante (0.1.5)
38
38
  delayed_job (4.0.0)
39
39
  activesupport (>= 3.0, < 4.1)
40
40
  delayed_job_active_record (4.0.0)
41
41
  activerecord (>= 3.0, < 4.1)
42
42
  delayed_job (>= 3.0, < 4.1)
43
- diff-lcs (1.2.4)
44
- i18n (0.6.4)
45
- json (1.8.0)
43
+ diff-lcs (1.2.5)
44
+ i18n (0.6.9)
45
+ json (1.8.1)
46
46
  method_source (0.8.2)
47
47
  minitest (4.7.5)
48
48
  mono_logger (1.1.0)
49
- multi_json (1.7.8)
50
- pry (0.9.12.2)
51
- coderay (~> 1.0.5)
49
+ multi_json (1.8.4)
50
+ pry (0.9.12.4)
51
+ coderay (~> 1.0)
52
52
  method_source (~> 0.8)
53
53
  slop (~> 3.4)
54
54
  qu (0.2.0)
55
55
  multi_json
56
56
  rack (1.5.2)
57
- rack-protection (1.5.0)
57
+ rack-protection (1.5.2)
58
58
  rack
59
- redis (3.0.4)
60
- redis-namespace (1.3.1)
61
- redis (~> 3.0.0)
62
- resque (1.24.1)
59
+ redis (3.0.6)
60
+ redis-namespace (1.4.1)
61
+ redis (~> 3.0.4)
62
+ resque (1.25.1)
63
63
  mono_logger (~> 1.0)
64
64
  multi_json (~> 1.0)
65
65
  redis-namespace (~> 1.2)
66
66
  sinatra (>= 0.9.2)
67
67
  vegas (~> 0.1.2)
68
- resque-scheduler (2.0.1)
69
- redis (>= 2.0.1)
70
- resque (>= 1.20.0)
71
- rufus-scheduler
68
+ resque-scheduler (2.3.1)
69
+ redis (>= 3.0.0)
70
+ resque (~> 1.25)
71
+ rufus-scheduler (~> 2.0)
72
72
  rspec (2.14.1)
73
73
  rspec-core (~> 2.14.0)
74
74
  rspec-expectations (~> 2.14.0)
75
75
  rspec-mocks (~> 2.14.0)
76
- rspec-core (2.14.4)
77
- rspec-expectations (2.14.0)
76
+ rspec-core (2.14.7)
77
+ rspec-expectations (2.14.4)
78
78
  diff-lcs (>= 1.1.3, < 2.0)
79
- rspec-mocks (2.14.2)
80
- rufus-scheduler (2.0.23)
81
- tzinfo (>= 0.3.23)
82
- sidekiq (2.13.0)
83
- celluloid (>= 0.14.1)
79
+ rspec-mocks (2.14.4)
80
+ rufus-scheduler (2.0.6)
81
+ sidekiq (2.17.3)
82
+ celluloid (>= 0.15.2)
84
83
  connection_pool (>= 1.0.0)
85
84
  json
86
- redis (>= 3.0)
87
- redis-namespace
88
- sinatra (1.4.3)
85
+ redis (>= 3.0.6)
86
+ redis-namespace (>= 1.3.1)
87
+ sinatra (1.4.4)
89
88
  rack (~> 1.4)
90
89
  rack-protection (~> 1.4)
91
90
  tilt (~> 1.3, >= 1.3.4)
92
- slop (3.4.6)
93
- sqlite3 (1.3.7)
94
- thread_safe (0.1.2)
91
+ slop (3.4.7)
92
+ sqlite3 (1.3.8)
93
+ thread_safe (0.1.3)
95
94
  atomic
96
95
  tilt (1.4.1)
97
96
  timers (1.1.0)
98
- tzinfo (0.3.37)
97
+ tzinfo (0.3.38)
99
98
  vegas (0.1.11)
100
99
  rack (>= 1.0.0)
101
100
 
@@ -113,6 +112,6 @@ DEPENDENCIES
113
112
  qu
114
113
  resque
115
114
  resque-scheduler
116
- rspec (~> 2.14.0.rc1)
115
+ rspec
117
116
  sidekiq
118
117
  sqlite3
@@ -10,14 +10,14 @@ module Qe
10
10
  # the current locale to the options.
11
11
  enqueue = instance_method(:enqueue)
12
12
  define_method :enqueue do |options = {}|
13
- options[:locale] = I18n.locale
13
+ options[:locale] ||= I18n.locale
14
14
  enqueue.bind(self).call(options)
15
15
  end
16
16
  end
17
17
 
18
18
  base.class_eval do
19
- # Intercept <tt>Worker#before</tt> method, adding
20
- # the setting the current locale.
19
+ # Intercept <tt>Worker#before</tt> method and
20
+ # set the current locale.
21
21
  before = instance_method(:before)
22
22
  define_method :before do
23
23
  I18n.locale = options.delete(:locale)
@@ -11,8 +11,8 @@ module Qe
11
11
  @scheduled = scheduled
12
12
  end
13
13
 
14
- def with(options)
15
- @options = options
14
+ def with(options = nil, &block)
15
+ @options = block || options
16
16
  self
17
17
  end
18
18
 
@@ -24,13 +24,15 @@ module Qe
24
24
  def matches?(block)
25
25
  block.call
26
26
 
27
- jobs.any? do |job|
27
+ result = jobs.any? do |job|
28
28
  condition = job[:worker] == worker
29
29
  condition = condition && datetime? if scheduled
30
- condition = condition && job[:options] == options if options
30
+ condition = condition && job[:options] == (options.kind_of?(Proc) ? options.call : options) if options
31
31
  condition = condition && job[:run_at].to_i == date.to_i if date
32
32
  condition
33
- end != nil
33
+ end
34
+
35
+ !!result
34
36
  end
35
37
 
36
38
  def does_not_match?(block)
@@ -38,7 +40,7 @@ module Qe
38
40
 
39
41
  jobs.none? do |job|
40
42
  condition = job[:worker] != worker
41
- condition = condition && job[:options] != options if options
43
+ condition = condition && job[:options] != (options.kind_of?(Proc) ? options.call : options) if options
42
44
  condition = condition && job[:run_at].to_i != date.to_i if date
43
45
  condition
44
46
  end
@@ -77,7 +79,7 @@ module Qe
77
79
  # expect {}.to enqueue(MailerWorker).with(options)
78
80
  #
79
81
  def enqueue(worker)
80
- Matcher.new(worker, true)
82
+ Matcher.new(worker, false)
81
83
  end
82
84
 
83
85
  #
@@ -1,3 +1,3 @@
1
1
  module Qe
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -2,7 +2,7 @@ module Qe
2
2
  module Worker
3
3
  module InstanceMethods
4
4
  def initialize(options)
5
- @options = options.with_indifferent_access
5
+ @options = HashWithIndifferentAccess.new(options)
6
6
  end
7
7
 
8
8
  # Return options that were provided when
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Qe::Locale do
4
- let(:i18n) { double("I18n", :locale => :en) }
4
+ let(:i18n) { double("I18n", locale: :en) }
5
5
 
6
6
  before do
7
7
  stub_const("I18n", i18n)
@@ -38,21 +38,24 @@ describe Qe::Locale do
38
38
  it "sets locale" do
39
39
  expect {
40
40
  LocalizedWorker.enqueue
41
- }.to enqueue(LocalizedWorker).with(:locale => :en)
41
+ }.to enqueue(LocalizedWorker).with(locale: :en)
42
42
  end
43
- end
44
43
 
45
- context "when performing" do
46
- before do
47
- Qe.adapter = Qe::Immediate
44
+ it "keeps defined locale" do
45
+ expect {
46
+ LocalizedWorker.enqueue(locale: "pt-BR")
47
+ }.to enqueue(LocalizedWorker).with(locale: "pt-BR")
48
48
  end
49
+ end
49
50
 
51
+ context "when performing" do
50
52
  it "sets locale" do
51
53
  i18n
52
54
  .should_receive(:locale=)
53
55
  .with(:en)
54
56
 
55
57
  LocalizedWorker.enqueue
58
+ Qe.drain
56
59
  end
57
60
  end
58
61
  end
@@ -11,6 +11,12 @@ describe Qe::EnqueueMatcher do
11
11
  }.to enqueue(HelloWorker).with(a: 1)
12
12
  end
13
13
 
14
+ it "enqueues job with options as a block" do
15
+ expect {
16
+ HelloWorker.enqueue(a: 1)
17
+ }.to enqueue(HelloWorker).with { {a: 1} }
18
+ end
19
+
14
20
  it "enqueues job without mentioning options" do
15
21
  expect {
16
22
  HelloWorker.enqueue(a: 1)
metadata CHANGED
@@ -1,181 +1,181 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-05 00:00:00.000000000 Z
11
+ date: 2014-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
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
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sidekiq
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: qu
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: delayed_job_active_record
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: backburner
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: resque
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: resque-scheduler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: activerecord
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: awesome_print
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: pry
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rspec
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: sqlite3
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '>='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '>='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  description: A simple interface over several background job libraries like Resque,
@@ -186,8 +186,8 @@ executables: []
186
186
  extensions: []
187
187
  extra_rdoc_files: []
188
188
  files:
189
- - .gitignore
190
- - .rspec
189
+ - ".gitignore"
190
+ - ".rspec"
191
191
  - Gemfile
192
192
  - Gemfile.lock
193
193
  - README.md
@@ -248,17 +248,17 @@ require_paths:
248
248
  - lib
249
249
  required_ruby_version: !ruby/object:Gem::Requirement
250
250
  requirements:
251
- - - '>='
251
+ - - ">="
252
252
  - !ruby/object:Gem::Version
253
253
  version: '0'
254
254
  required_rubygems_version: !ruby/object:Gem::Requirement
255
255
  requirements:
256
- - - '>='
256
+ - - ">="
257
257
  - !ruby/object:Gem::Version
258
258
  version: '0'
259
259
  requirements: []
260
260
  rubyforge_project:
261
- rubygems_version: 2.0.3
261
+ rubygems_version: 2.2.0
262
262
  signing_key:
263
263
  specification_version: 4
264
264
  summary: A simple interface over several background job libraries like Resque, Sidekiq