acts_as_async 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,10 +8,12 @@ easy-to-use Resque helpers.
8
8
 
9
9
  Installing ActsAsAsync is as simple as adding it to your Gemfile:
10
10
 
11
- $ cat Gemfile
12
- ...
13
- gem "acts_as_async"
14
- ...
11
+ ```
12
+ $ cat Gemfile
13
+ ...
14
+ gem "acts_as_async"
15
+ ...
16
+ ```
15
17
 
16
18
 
17
19
  ## Usage
@@ -19,63 +21,71 @@ Installing ActsAsAsync is as simple as adding it to your Gemfile:
19
21
  ActsAsAsync aims to be as simple as possible to use. Including it in your model
20
22
  is as easy as:
21
23
 
22
- class Post < ActiveRecord::Base
23
- acts_as_async
24
- end
24
+ ```ruby
25
+ class Post < ActiveRecord::Base
26
+ acts_as_async
27
+ end
28
+ ```
25
29
 
26
30
  ### Basic usage
27
31
 
28
32
  ActsAsAsync adds three instance methods to your model that you can use to async
29
33
  any other instance method:
30
34
 
31
- post = Post.create(:body => "Wow, acts_as_async is neat!")
35
+ ```ruby
36
+ post = Post.create(:body => "Wow, acts_as_async is neat!")
32
37
 
33
- # Self-destruct as soon as possible
34
- post.async(:destroy)
38
+ # Self-destruct as soon as possible
39
+ post.async(:destroy)
35
40
 
36
- # Self-destruct at this time tomorrow
37
- post.async_at(Time.now + 1.day, :destroy)
41
+ # Self-destruct at this time tomorrow
42
+ post.async_at(Time.now + 1.day, :destroy)
38
43
 
39
- # Self-destruct in 10 minutes
40
- post.async_in(10.minutes, :destroy)
44
+ # Self-destruct in 10 minutes
45
+ post.async_in(10.minutes, :destroy)
46
+ ```
41
47
 
42
48
  It also adds three identical class methods:
43
49
 
44
- Post.async(:destroy_all)
45
- Post.async_at(1.day.from_now, :destroy_all)
46
- Post.async_in(10.minutes, :destroy_all)
50
+ ```ruby
51
+ Post.async(:destroy_all)
52
+ Post.async_at(1.day.from_now, :destroy_all)
53
+ Post.async_in(10.minutes, :destroy_all)
54
+ ```
47
55
 
48
56
  ### Dynamic methods
49
57
 
50
58
  In addition to the helper methods above, ActsAsAsync supports dynamic methods
51
59
  for any existing method on your model. For example:
52
60
 
53
- class Audiobook < ActiveRecord::Base
54
- acts_as_async
61
+ ```ruby
62
+ class Audiobook < ActiveRecord::Base
63
+ acts_as_async
55
64
 
56
- def transcribe
57
- # Some long-running logic here
58
- end
65
+ def transcribe
66
+ # Some long-running logic here
67
+ end
59
68
 
60
- def read!
61
- # Computers like to read too!
62
- end
69
+ def read!
70
+ # Computers like to read too!
71
+ end
63
72
 
64
- def paint(color)
65
- # I don't know why you'd paint a book...
66
- end
67
- end
73
+ def paint(color)
74
+ # I don't know why you'd paint a book...
75
+ end
76
+ end
68
77
 
69
- book = Audiobook.first
78
+ book = Audiobook.first
70
79
 
71
- # Transcribe the book as soon as possible
72
- book.async_transcribe
80
+ # Transcribe the book as soon as possible
81
+ book.async_transcribe
73
82
 
74
- # Read the book at this time tomorrow
75
- book.async_read_at!(Time.now + 1.day)
83
+ # Read the book at this time tomorrow
84
+ book.async_read_at!(Time.now + 1.day)
76
85
 
77
- # Paint the book blue in a couple years
78
- book.async_paint_in(2.years, "blue")
86
+ # Paint the book blue in a couple years
87
+ book.async_paint_in(2.years, "blue")
88
+ ```
79
89
 
80
90
  ### Additional notes
81
91
 
@@ -105,8 +115,8 @@ pages.
105
115
 
106
116
  ## Compatibility
107
117
 
108
- ActsAsAsync is tested against the same Rubies as Resque: Ruby 1.8.7, 1.9.2,
109
- Rubinius 2.0, and JRuby.
118
+ ActsAsAsync is tested against the following Rubies: MRI 1.8.7, MRI 1.9.2,
119
+ MRI 1.9.3, Rubinius 2.0, and JRuby.
110
120
 
111
121
  ![Build Status](https://secure.travis-ci.org/bloudermilk/acts_as_async.png?branch=master&.png)
112
122
 
data/Rakefile CHANGED
@@ -18,6 +18,6 @@ task :build do
18
18
  end
19
19
 
20
20
  task :install => :build do
21
- system "sudo gem install acts_as_async-#{ActsAsAsync::VERSION}.gem"
21
+ system "gem install acts_as_async-#{ActsAsAsync::VERSION}.gem"
22
22
  end
23
23
 
@@ -36,6 +36,11 @@ module ActsAsAsync
36
36
  def async_in(time, method, *args)
37
37
  Resque.enqueue_in(time, self, method, *args)
38
38
  end
39
+
40
+ def inherited(subclass)
41
+ queue = instance_variable_get(:@queue)
42
+ subclass.instance_variable_set(:@queue, queue)
43
+ end
39
44
  end
40
45
 
41
46
  module InstanceMethods
@@ -1,3 +1,3 @@
1
1
  module ActsAsAsync
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_async
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-27 00:00:00.000000000Z
12
+ date: 2011-11-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: resque
16
- requirement: &70250306568840 !ruby/object:Gem::Requirement
16
+ requirement: &70167909402680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70250306568840
24
+ version_requirements: *70167909402680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: resque-scheduler
27
- requirement: &70250306568160 !ruby/object:Gem::Requirement
27
+ requirement: &70167909402080 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70250306568160
35
+ version_requirements: *70167909402080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
- requirement: &70250306567560 !ruby/object:Gem::Requirement
38
+ requirement: &70167909401520 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70250306567560
46
+ version_requirements: *70167909401520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activerecord
49
- requirement: &70250306567100 !ruby/object:Gem::Requirement
49
+ requirement: &70167909401020 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70250306567100
57
+ version_requirements: *70167909401020
58
58
  description: ActsAsAsync is an ActiveRecord extension that provides your models with
59
59
  easy-to-use Resque helpers.
60
60
  email:
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  segments:
87
87
  - 0
88
- hash: -1993462197746381036
88
+ hash: 2610132422325218421
89
89
  required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  none: false
91
91
  requirements:
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  segments:
96
96
  - 0
97
- hash: -1993462197746381036
97
+ hash: 2610132422325218421
98
98
  requirements: []
99
99
  rubyforge_project:
100
100
  rubygems_version: 1.8.10