rufus-scheduler 3.3.3 → 3.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.txt +5 -0
- data/CREDITS.txt +1 -0
- data/README.md +9 -4
- data/lib/rufus/scheduler.rb +1 -1
- data/lib/rufus/scheduler/zotime.rb +4 -1
- data/sofia.md +89 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aadc34a3585ec0563a43eeecee75009ac311490f
|
4
|
+
data.tar.gz: ea9e07f929da453a7fe63711bd80c75457444f6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f43b61128d67c893d88a1a796dbf029c3d18577a80d4f8874c25d8272318252c96da6f499c561e5bafa25349c228d0c950a937db12b492ef2f348667b2ba700d
|
7
|
+
data.tar.gz: c01cbfd377824b64f148f515e65db781f5433eaab1d574fd46c45210139bf1fbbb3ec5b8208f371044bdde909bb7917d38955d5e3dd8fcd3bdff79ef4f52d450
|
data/CHANGELOG.txt
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
= rufus-scheduler CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
+
== rufus-scheduler - 3.3.4 released 2017-02-16
|
6
|
+
|
7
|
+
- More detailed "cannot determine timezone from nil" message, gh-237
|
8
|
+
|
9
|
+
|
5
10
|
== rufus-scheduler - 3.3.3 released 2017-01-29
|
6
11
|
|
7
12
|
- use Rails' timezone by default if Rails is present, gh-230, gh-233,
|
data/CREDITS.txt
CHANGED
@@ -53,6 +53,7 @@
|
|
53
53
|
|
54
54
|
== Feedback
|
55
55
|
|
56
|
+
- Yoshimi Keiji - https://githuc.com/walf443 - v.3.3.3 mislabelling
|
56
57
|
- Alexander Deeb - https://github.com/adeeb1 - gh-230
|
57
58
|
- Sofia Bravo - http://stackoverflow.com/users/1123850/sofia-bravo - gh-231
|
58
59
|
- zzjin - https://githu.com/zzjin - 3.3.x vs CST abbreviated timezone - gh-228
|
data/README.md
CHANGED
@@ -1449,7 +1449,7 @@ rufus-scheduler/lib/rufus/scheduler/zotime.rb:41:
|
|
1449
1449
|
...
|
1450
1450
|
```
|
1451
1451
|
|
1452
|
-
It may happen on Windows or on systems that
|
1452
|
+
It may happen on Windows or on systems that poorly hints to Ruby on which timezone to use. It should be solved by setting explicitely the `ENV['TZ']` before the scheduler instantiation:
|
1453
1453
|
```ruby
|
1454
1454
|
ENV['TZ'] = 'Asia/Shanghai'
|
1455
1455
|
scheduler = Rufus::Scheduler.new
|
@@ -1468,18 +1468,23 @@ end
|
|
1468
1468
|
```
|
1469
1469
|
(Hat tip to Alexander in [gh-230](https://github.com/jmettraux/rufus-scheduler/issues/230))
|
1470
1470
|
|
1471
|
-
Rails
|
1471
|
+
Rails sets its timezone under `config/application.rb`.
|
1472
1472
|
|
1473
1473
|
Rufus-Scheduler 3.3.3 detects the presence of Rails and uses its timezone setting (tested with Rails 4), so setting `ENV['TZ']` should not be necessary.
|
1474
1474
|
|
1475
1475
|
The value can be determined thanks to [https://en.wikipedia.org/wiki/List_of_tz_database_time_zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
1476
1476
|
|
1477
|
-
Use a "continent/city" identifier (for example "Asia/Shanghai"). Do not use an abbreviation (not "CST") and do not use a local time zone name (not "中国标准时间").
|
1477
|
+
Use a "continent/city" identifier (for example "Asia/Shanghai"). Do not use an abbreviation (not "CST") and do not use a local time zone name (not "中国标准时间" nor "Eastern Standard Time" which, for instance, points to a time zone in America and to another one in Australia...).
|
1478
1478
|
|
1479
|
-
If the error persists, try to add the `tzinfo-data` to your Gemfile, as in:
|
1479
|
+
If the error persists (and especially on Windows), try to add the `tzinfo-data` to your Gemfile, as in:
|
1480
1480
|
```ruby
|
1481
1481
|
gem 'tzinfo-data'
|
1482
1482
|
```
|
1483
|
+
or by manually requiring it before requiring rufus-scheduler (if you don't use Bundler):
|
1484
|
+
```ruby
|
1485
|
+
require 'tzinfo/data'
|
1486
|
+
require 'rufus-scheduler'
|
1487
|
+
```
|
1483
1488
|
|
1484
1489
|
|
1485
1490
|
## so Rails?
|
data/lib/rufus/scheduler.rb
CHANGED
@@ -41,7 +41,10 @@ class Rufus::Scheduler
|
|
41
41
|
fail ArgumentError.new(
|
42
42
|
"cannot determine timezone from #{zone.inspect}" +
|
43
43
|
" (etz:#{ENV['TZ'].inspect},tnz:#{Time.now.zone.inspect}," +
|
44
|
-
"tzid:#{defined?(TZInfo::Data).inspect})"
|
44
|
+
"tzid:#{defined?(TZInfo::Data).inspect})\n" +
|
45
|
+
"Try setting `ENV['TZ'] = 'Continent/City'` in your script " +
|
46
|
+
"(see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)" +
|
47
|
+
(defined?(TZInfo::Data) ? '' : " and adding 'tzinfo-data' to your gems")
|
45
48
|
) unless @zone
|
46
49
|
|
47
50
|
@time = nil # cache for #to_time result
|
data/sofia.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
|
2
|
+
I would take a different approach, one with a single schedule:
|
3
|
+
|
4
|
+
```ruby
|
5
|
+
# config/initializers/scheduler.rb
|
6
|
+
|
7
|
+
require 'rufus-scheduler'
|
8
|
+
|
9
|
+
Rufus::Scheduler.singleton.cron('* * * * *') do
|
10
|
+
# every minute
|
11
|
+
|
12
|
+
HarvestPlan.trigger_if_necessary
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
# app/models/harvest_plan.rb
|
18
|
+
|
19
|
+
class HarvestPlan < ApplicationRecord
|
20
|
+
|
21
|
+
def self.trigger_if_necessary
|
22
|
+
|
23
|
+
now = Time.now
|
24
|
+
|
25
|
+
HarvestPlan.where(start_date < now && repetitions > 0) do |plan|
|
26
|
+
# warning pseudo active record code !
|
27
|
+
|
28
|
+
elapsed = now - plan.last_time / 3600
|
29
|
+
next if elapsed < @harveset_plan.hours_between
|
30
|
+
# that elapsed check could even be done in the `where` above
|
31
|
+
|
32
|
+
# clear to trigger
|
33
|
+
|
34
|
+
plan.trigger
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def trigger
|
39
|
+
|
40
|
+
self.repetitions -= 1
|
41
|
+
self.last_time = Time.now
|
42
|
+
self.save
|
43
|
+
|
44
|
+
CreateHarvestFromPlanJob.perform_later(self)
|
45
|
+
# that's ugly, when do not want to perform_later, we want to perform now!
|
46
|
+
end
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
# in the controller...
|
52
|
+
|
53
|
+
def create
|
54
|
+
|
55
|
+
@harvest_plan = HarvestPlan.new(resource_params)
|
56
|
+
@harvest_plan.start_date = Time.parse(resource_params[:start_date])
|
57
|
+
|
58
|
+
return unless @harvest_plan.save
|
59
|
+
|
60
|
+
ApplicationController.new.insert_in_messages_list(
|
61
|
+
session, :success, 'Harvest plan created')
|
62
|
+
|
63
|
+
redirect_to farms_path
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
You could even avoid using rufus-scheduler:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# config/initializers/scheduler.rb
|
72
|
+
|
73
|
+
Thread.new do
|
74
|
+
loop do
|
75
|
+
begin
|
76
|
+
sleep 59
|
77
|
+
HarvestPlan.trigger_if_necessary
|
78
|
+
rescue => err
|
79
|
+
Rails.logger.warn "#{err.object_id} - problem with HarvestPlan triggering... " + err.inspect
|
80
|
+
err.backtrace.each do |line|
|
81
|
+
Rails.logger.warn "#{err.object_id} - #{line}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
Best regards.
|
89
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rufus-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- n.txt
|
79
79
|
- pics.txt
|
80
80
|
- rufus-scheduler.gemspec
|
81
|
+
- sofia.md
|
81
82
|
homepage: http://github.com/jmettraux/rufus-scheduler
|
82
83
|
licenses:
|
83
84
|
- MIT
|
@@ -98,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
99
|
version: '0'
|
99
100
|
requirements: []
|
100
101
|
rubyforge_project: rufus
|
101
|
-
rubygems_version: 2.4.5.
|
102
|
+
rubygems_version: 2.4.5.2
|
102
103
|
signing_key:
|
103
104
|
specification_version: 4
|
104
105
|
summary: job scheduler for Ruby (at, cron, in and every jobs)
|