resque-restriction 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc.example +2 -0
- data/README.markdown +7 -2
- data/VERSION +1 -1
- data/lib/resque-restriction/restriction_job.rb +2 -2
- data/resque-restriction.gemspec +5 -4
- data/spec/resque-restriction/restriction_job_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +13 -5
data/.rvmrc.example
ADDED
data/README.markdown
CHANGED
@@ -9,6 +9,11 @@ Resque Restriction is a plugin for the [Resque][0] queueing system (http://githu
|
|
9
9
|
|
10
10
|
Resque Restriction requires Resque 1.7.0.
|
11
11
|
|
12
|
+
Attention
|
13
|
+
---------
|
14
|
+
|
15
|
+
The <code>identifier</code> method is renamed to <code>restriction_identifier</code> to solve the confliction with resque-retry from version 0.3.0.
|
16
|
+
|
12
17
|
Install
|
13
18
|
-------
|
14
19
|
|
@@ -37,14 +42,14 @@ You can also add customized restriction as you like. For example, we have a job
|
|
37
42
|
class GenerateFacebookShares < Resque::Plugins::RestrictionJob
|
38
43
|
restrict :per_day => 40
|
39
44
|
|
40
|
-
def self.
|
45
|
+
def self.restriction_identifier(options)
|
41
46
|
[self.to_s, options["user_id"]].join(":")
|
42
47
|
end
|
43
48
|
|
44
49
|
#rest of your class here
|
45
50
|
end
|
46
51
|
|
47
|
-
options["user_id"] returns the user's facebook uid, the key point is that the different
|
52
|
+
options["user_id"] returns the user's facebook uid, the key point is that the different restriction_identifiers can restrict different job execution numbers.
|
48
53
|
|
49
54
|
Contributing
|
50
55
|
------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -66,10 +66,10 @@ module Resque
|
|
66
66
|
when :per_month then Date.today.strftime("%Y-%m")
|
67
67
|
when :per_year then Date.today.year.to_s
|
68
68
|
else period.to_s =~ /^per_(\d+)$/ and (Time.now.to_i / $1.to_i).to_s end
|
69
|
-
[self.
|
69
|
+
[self.restriction_identifier(*args), period_str].compact.join(":")
|
70
70
|
end
|
71
71
|
|
72
|
-
def
|
72
|
+
def restriction_identifier(*args)
|
73
73
|
self.to_s
|
74
74
|
end
|
75
75
|
|
data/resque-restriction.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{resque-restriction}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Richard Huang"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-04}
|
13
13
|
s.description = %q{resque-restriction is an extension to resque queue system that restricts the execution number of certain jobs in a period time, the exceeded jobs will be executed at the next period.}
|
14
14
|
s.email = %q{flyerhzm@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".gitignore",
|
21
|
+
".rvmrc.example",
|
21
22
|
"LICENSE",
|
22
23
|
"README.markdown",
|
23
24
|
"Rakefile",
|
@@ -37,7 +38,7 @@ Gem::Specification.new do |s|
|
|
37
38
|
s.homepage = %q{http://github.com/flyerhzm/resque-restriction}
|
38
39
|
s.rdoc_options = ["--charset=UTF-8"]
|
39
40
|
s.require_paths = ["lib"]
|
40
|
-
s.rubygems_version = %q{1.3.
|
41
|
+
s.rubygems_version = %q{1.3.7}
|
41
42
|
s.summary = %q{resque-restriction is an extension to resque queue system that restricts the execution number of certain jobs in a period time.}
|
42
43
|
s.test_files = [
|
43
44
|
"spec/resque-restriction/job_spec.rb",
|
@@ -49,7 +50,7 @@ Gem::Specification.new do |s|
|
|
49
50
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
51
|
s.specification_version = 3
|
51
52
|
|
52
|
-
if Gem::Version.new(Gem::
|
53
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
54
|
s.add_runtime_dependency(%q<resque>, [">= 1.7.0"])
|
54
55
|
else
|
55
56
|
s.add_dependency(%q<resque>, [">= 1.7.0"])
|
@@ -42,7 +42,7 @@ describe Resque::Plugins::RestrictionJob do
|
|
42
42
|
Resque.redis.get(OneHourRestrictionJob.redis_key(:per_hour)).should == "9"
|
43
43
|
end
|
44
44
|
|
45
|
-
it "should use
|
45
|
+
it "should use restriction_identifier to set exclusive execution counts" do
|
46
46
|
result = perform_job(IdentifiedRestrictionJob, 1)
|
47
47
|
result.should be_true
|
48
48
|
result = perform_job(IdentifiedRestrictionJob, 1)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-restriction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Richard Huang
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-11-04 00:00:00 +08:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: resque
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 11
|
27
30
|
segments:
|
28
31
|
- 1
|
29
32
|
- 7
|
@@ -42,6 +45,7 @@ extra_rdoc_files:
|
|
42
45
|
- README.markdown
|
43
46
|
files:
|
44
47
|
- .gitignore
|
48
|
+
- .rvmrc.example
|
45
49
|
- LICENSE
|
46
50
|
- README.markdown
|
47
51
|
- Rakefile
|
@@ -67,23 +71,27 @@ rdoc_options:
|
|
67
71
|
require_paths:
|
68
72
|
- lib
|
69
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
70
75
|
requirements:
|
71
76
|
- - ">="
|
72
77
|
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
73
79
|
segments:
|
74
80
|
- 0
|
75
81
|
version: "0"
|
76
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
77
84
|
requirements:
|
78
85
|
- - ">="
|
79
86
|
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
80
88
|
segments:
|
81
89
|
- 0
|
82
90
|
version: "0"
|
83
91
|
requirements: []
|
84
92
|
|
85
93
|
rubyforge_project:
|
86
|
-
rubygems_version: 1.3.
|
94
|
+
rubygems_version: 1.3.7
|
87
95
|
signing_key:
|
88
96
|
specification_version: 3
|
89
97
|
summary: resque-restriction is an extension to resque queue system that restricts the execution number of certain jobs in a period time.
|