delayed_job_recurring 0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/delayed/recurring_job.rb +22 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 611fadd7b0841b22954dbfb4aeb07b4a1e4374df
|
4
|
+
data.tar.gz: 876ea72b2951452c45547d8241cb1c97ee3c2c56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03330925d4bb8a28d0926a43a78d73c07531f3e7bafc9bb1557a8722566c8892e5f6ec285dd3abdaee1102512a446d3434800c3e71061a2da78fc7173e056e4e
|
7
|
+
data.tar.gz: de4ffb37d1a04c881da94c96309167202ced75dd928df0c0a3ca8eefade2b5f91f63da20b6794870d1946d1cf10b21487d2725fd7bc414a7ef6838a3aeb790ae
|
data/README.md
CHANGED
@@ -4,13 +4,15 @@ Extends delayed\_job to support recurring jobs.
|
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
|
-
|
7
|
+
Add it to your Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
10
|
gem 'delayed_job_recurring'
|
11
11
|
```
|
12
12
|
|
13
|
-
Then define a task class
|
13
|
+
Then define a task class. We like the concept of
|
14
|
+
[interactors](http://eng.joingrouper.com/blog/2014/03/03/rails-the-missing-parts-interactors),
|
15
|
+
so we put our task classes in `app/interactors`. You could also put them in `lib` or even `app/models`.
|
14
16
|
|
15
17
|
```ruby
|
16
18
|
class MyTask
|
@@ -41,6 +41,7 @@ module Delayed
|
|
41
41
|
def next_run_time
|
42
42
|
times = @schedule_options[:run_at]
|
43
43
|
times = [times] unless times.is_a? Array
|
44
|
+
times = times.map{|time| parse_time(time, @schedule_options[:timezone])}
|
44
45
|
times = times.map{|time| time.in_time_zone @schedule_options[:timezone]} if @schedule_options[:timezone]
|
45
46
|
|
46
47
|
interval = deserialize_duration(@schedule_options[:run_interval])
|
@@ -76,16 +77,34 @@ module Delayed
|
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
80
|
+
def parse_time(time, timezone)
|
81
|
+
case time
|
82
|
+
when String
|
83
|
+
get_timezone(timezone).parse(time)
|
84
|
+
else
|
85
|
+
time
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_timezone(zone)
|
90
|
+
if zone
|
91
|
+
ActiveSupport::TimeZone.new(zone)
|
92
|
+
else
|
93
|
+
Time.zone
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
79
97
|
def next_future_time(times)
|
80
98
|
times.select{|time| time > Time.now}.min
|
81
99
|
end
|
82
100
|
|
83
101
|
module ClassMethods
|
84
|
-
def run_at(
|
85
|
-
if
|
102
|
+
def run_at(*times)
|
103
|
+
if times.length == 0
|
86
104
|
@run_at || run_every.from_now
|
87
105
|
else
|
88
|
-
@run_at
|
106
|
+
@run_at ||= []
|
107
|
+
@run_at.concat times
|
89
108
|
end
|
90
109
|
end
|
91
110
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_job_recurring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Novak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|