rufus-scheduler 3.3.2 → 3.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3058360f44993095ae5952e9c85c85a961059be2
4
- data.tar.gz: 7e99f90b386a9353b47bad6ab8f88228a5d46339
3
+ metadata.gz: 31bff13de665010182dbbb8aad7b32be532e0fe7
4
+ data.tar.gz: 71389925d05e4c699246d0ce5b8509270e967909
5
5
  SHA512:
6
- metadata.gz: 0ccd580286d947bdcef2f4d544f3688fd8ed66d6a23ee09adc274cb5f770598bcf39de79aede9ff68c394834091ec0d9ffb2f9845cd9945b821cee5c94a5f857
7
- data.tar.gz: 41864b63fdd2a44f2c14861cb25a8ab0523d58593edd16fa049338f413d009193f3d44bb9a14bc91820269fa0ad1bf92b84a210495e4b38bcb56447fe07ba37e
6
+ metadata.gz: 5246e1928d1a4149f47133d55f107389542bbabe5f7772d48fc64406f3ec0573ec54b213fc5b2a59f7d0675cc247bfc3ef4b801415ce3b0cc92640735b7db3af
7
+ data.tar.gz: 375afb960f519c4f57167dd6e339a5c390b6b54066ef1469b6cbbf40cbc2ffe109f6f71da6afbfc1e51ac6c8b61d5529b63cf4c969c043abc7c7aec2507bb65f
data/CHANGELOG.txt CHANGED
@@ -2,6 +2,14 @@
2
2
  = rufus-scheduler CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-scheduler - 3.3.3 released 2017-01-29
6
+
7
+ - use Rails' timezone by default if Rails is present, gh-230, gh-233,
8
+ thanks Alexander Deeb
9
+ - is_a?(Fixnum) replaced by is_a?(Integer), gh-232, thanks Cody Cutrer
10
+ - Fix for every double trigger, gh-231, thanks Sofia Bravo
11
+
12
+
5
13
  == rufus-scheduler - 3.3.2 released 2017-01-05
6
14
 
7
15
  - Fix ZoTime issue with Time.zone.now #=> 'CST', thanks zzjin
data/CREDITS.txt CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  == Contributors
6
6
 
7
+ - Cody Cutrer (https://github.com/ccutrer) - gh-232 is_a?(Fixnum) replacement
7
8
  - Dominik Sander (https://github.com/dsander) - gh-225, gh-226
8
9
  - Piavka (https://github.com/piavka) - Job#trigger_off_schedule, gh-214
9
10
  - Paulo Delgado (https://github.com/paulodelgado) counter ActiveRecord, gh-210
@@ -52,6 +53,8 @@
52
53
 
53
54
  == Feedback
54
55
 
56
+ - Alexander Deeb - https://github.com/adeeb1 - gh-230
57
+ - Sofia Bravo - http://stackoverflow.com/users/1123850/sofia-bravo - gh-231
55
58
  - zzjin - https://githu.com/zzjin - 3.3.x vs CST abbreviated timezone - gh-228
56
59
  - lovingyu - https://github.com/lovingyu - fallback to ENV['TZ'] - gh-222
57
60
  - Ramon Tayag - https://github.com/ramontayag - prevent day 0 in cronlines
data/README.md CHANGED
@@ -1458,6 +1458,20 @@ scheduler.every '2s' do
1458
1458
  end
1459
1459
  ```
1460
1460
 
1461
+ On Rails you might want to try with:
1462
+ ```ruby
1463
+ ENV['TZ'] = Time.zone.name # Rails only
1464
+ scheduler = Rufus::Scheduler.new
1465
+ scheduler.every '2s' do
1466
+ puts "#{Time.now} Hello #{ENV['TZ']}!"
1467
+ end
1468
+ ```
1469
+ (Hat tip to Alexander in [gh-230](https://github.com/jmettraux/rufus-scheduler/issues/230))
1470
+
1471
+ Rails set its timezone under `config/application.rb`.
1472
+
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
+
1461
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).
1462
1476
 
1463
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 "中国标准时间").
data/fail.txt ADDED
@@ -0,0 +1,2 @@
1
+ rspec ./spec/job_spec.rb:465 # Rufus::Scheduler::Job :mutex :mutex => [ array_of_mutex_names_or_instances ] prevents concurrent executions
2
+ rspec ./spec/scheduler_spec.rb:534 # Rufus::Scheduler#running_jobs(:tag/:tags => x) returns a list of running jobs filtered by tag
@@ -39,7 +39,7 @@ module Rufus
39
39
  require 'rufus/scheduler/job_array'
40
40
  require 'rufus/scheduler/locks'
41
41
 
42
- VERSION = '3.3.2'
42
+ VERSION = '3.3.3'
43
43
 
44
44
  #
45
45
  # A common error class for rufus-scheduler
@@ -86,7 +86,7 @@ class Rufus::Scheduler
86
86
 
87
87
  fail ArgumentError.new(
88
88
  "invalid cronline: '#{line}'"
89
- ) if es && es.find { |e| ! e.is_a?(Fixnum) }
89
+ ) if es && es.find { |e| ! e.is_a?(Integer) }
90
90
  end
91
91
 
92
92
  if @days && @days.include?(0) # gh-221
@@ -426,7 +426,7 @@ module Rufus
426
426
 
427
427
  fail ArgumentError.new(
428
428
  "cannot accept :times => #{@times.inspect}, not nil or an int"
429
- ) unless @times == nil || @times.is_a?(Fixnum)
429
+ ) unless @times == nil || @times.is_a?(Integer)
430
430
 
431
431
  self.first_at =
432
432
  opts[:first] || opts[:first_time] ||
@@ -567,11 +567,10 @@ module Rufus
567
567
  n = Rufus::Scheduler::ZoTime.now
568
568
 
569
569
  @next_time =
570
- if @first_at == nil || @first_at < (n - @scheduler.frequency)
571
- nt = (@next_time || trigger_time || n) + @frequency
572
- nt > n ? nt : (trigger_time || n) + @frequency
573
- else
570
+ if @first_at && (trigger_time == nil || @first_at > n)
574
571
  @first_at
572
+ else
573
+ (@next_time || n) + @frequency
575
574
  end
576
575
  end
577
576
 
@@ -193,6 +193,11 @@ class Rufus::Scheduler
193
193
  strftime('%H%M') + off + utc.strftime('(%H%M)')
194
194
  end
195
195
 
196
+ def to_time_s
197
+
198
+ strftime("%H:%M:%S.#{'%06d' % usec}")
199
+ end
200
+
196
201
  def self.now(zone=nil)
197
202
 
198
203
  ZoTime.new(Time.now.to_f, zone)
@@ -282,10 +287,19 @@ class Rufus::Scheduler
282
287
  return nil if str == nil
283
288
  return nil if str == '*'
284
289
 
290
+ ostr = str
291
+ str = :current if str == :local
292
+
293
+ # use Rails' zone by default if Rails is present
294
+
295
+ return Time.zone.tzinfo if (
296
+ ENV['TZ'].nil? && str == :current &&
297
+ Time.respond_to?(:zone) && Time.zone.respond_to?(:tzinfo)
298
+ )
299
+
285
300
  # ok, it's a timezone then
286
301
 
287
- ostr = str
288
- str = ENV['TZ'] || Time.now.zone if str == :current || str == :local
302
+ str = ENV['TZ'] || Time.now.zone if str == :current
289
303
 
290
304
  # utc_offset
291
305
 
@@ -363,9 +377,7 @@ class Rufus::Scheduler
363
377
 
364
378
  # last try with ENV['TZ']
365
379
 
366
- z =
367
- (ostr == :local || ostr == :current) &&
368
- (::TZInfo::Timezone.get(ENV['TZ']) rescue nil)
380
+ z = ostr == :current && (::TZInfo::Timezone.get(ENV['TZ']) rescue nil)
369
381
  return z if z
370
382
 
371
383
  # so it's not a timezone.
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.3
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-01-05 00:00:00.000000000 Z
11
+ date: 2017-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo
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: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.13.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: 2.13.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: chronic
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
  description: job scheduler for Ruby (at, cron, in and every jobs).
@@ -59,25 +59,25 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - CHANGELOG.txt
63
+ - CREDITS.txt
64
+ - LICENSE.txt
62
65
  - Makefile
66
+ - README.md
67
+ - TODO.txt
68
+ - fail.txt
69
+ - fail18.txt
70
+ - lib/rufus-scheduler.rb
71
+ - lib/rufus/scheduler.rb
63
72
  - lib/rufus/scheduler/cronline.rb
64
73
  - lib/rufus/scheduler/job_array.rb
65
74
  - lib/rufus/scheduler/jobs.rb
66
75
  - lib/rufus/scheduler/locks.rb
67
76
  - lib/rufus/scheduler/util.rb
68
77
  - lib/rufus/scheduler/zotime.rb
69
- - lib/rufus/scheduler.rb
70
- - lib/rufus-scheduler.rb
71
- - rufus-scheduler.gemspec
72
- - CHANGELOG.txt
73
- - CREDITS.txt
74
- - fail18.txt
75
- - LICENSE.txt
76
78
  - n.txt
77
79
  - pics.txt
78
- - t.txt
79
- - TODO.txt
80
- - README.md
80
+ - rufus-scheduler.gemspec
81
81
  homepage: http://github.com/jmettraux/rufus-scheduler
82
82
  licenses:
83
83
  - MIT
@@ -88,17 +88,17 @@ require_paths:
88
88
  - lib
89
89
  required_ruby_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - '>='
91
+ - - ">="
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project: rufus
101
- rubygems_version: 2.0.14
101
+ rubygems_version: 2.4.5.1
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: job scheduler for Ruby (at, cron, in and every jobs)
data/t.txt DELETED
@@ -1,25 +0,0 @@
1
-
2
- **phase 4 - 2016-12-22**
3
-
4
- > Added phase 3 logs to question. It looks like some how there is a new scheduler process that is subsequently created and then destroyed inside the model code. Thanks again for your diligence on this!
5
-
6
- Is that really happening in the model code? Your logs tell us that it happens in another process. Your initial Ruby process initializes rufus-scheduler then your HTTP requests are served in worker processes which are forks of your initial process (without the threads, in other words with inactive schedulers).
7
-
8
- You're using Puma in clustered mode. I should have immediately asked you about your configuration.
9
-
10
- Read carefully its documentation at https://github.com/puma/puma#configuration
11
-
12
- An easy fix would be not to use the clustered mode so that there is only one Ruby process involved, serving all the HTTP requests.
13
-
14
- If you need the clustered mode, you have to change your way of thinking. You probably don't want to have 1 rufus-scheduler instance per worker thread. You could focus on having the core (live) rufus-scheduler in the main process. It could have a "management" job that checks recently updated metrics and unschedules/schedules jobs.
15
-
16
- SCHEDULER.every '10s', overlap: false do
17
- Metric.recently_updated.each do |metric|
18
- SCHEDULER.jobs(tags: metric.id).each(&:unschedule)
19
- SCHEDULER.every(metric.frequency, tags: self.id) { metric.add_value }
20
- end
21
- end
22
- # or something like that...
23
-
24
- Have fun!
25
-