rufus-scheduler 3.2.1 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c40e276338f283e1d434b24ff0914bb4f9e4772c
4
- data.tar.gz: 6f675ccf7f32737bd45e96119db3f0217a9294c0
3
+ metadata.gz: d295240539281a67916e2d17affe1b83406f28ff
4
+ data.tar.gz: a597f93ce56ecd1988f65d8fe46a9cd5401974fb
5
5
  SHA512:
6
- metadata.gz: 5a263aaebb6f8f434f7b1eeeb138e0e77d19dd11cb87dcb347be5543fd079e90ab4352aa3a3df297ea46fe8be76d2d25950dee02afbc427e49aab4d316fee385
7
- data.tar.gz: 5037bcda9d0650d1404bc2c134cd3ad36e0b9fc90f95dfde27af416fb2a8794c844777ddfa42b24cbb5b07f0694c3a58b8006795321c2a3699404710c61d4860
6
+ metadata.gz: 39652b4c2cbf22b58b4a216fb866ab292eacb2042a7acc740d5d1c5bd936e3a68a0307cb4bcfc7b463b256751c1dd465bc8b32bc05130d9bce1b11fc16518b16
7
+ data.tar.gz: 37f9c3f06c4a49e75e3d38b20cd4a7bd8934263d671a78d78d5daa2c71f68d1a7273653512ca5b5fafc07412fa8a5b4c12c390bb57d9db0072887b8d84e8f7f4
@@ -2,6 +2,13 @@
2
2
  = rufus-scheduler CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-scheduler - 3.2.2 released 2016-08-14
6
+
7
+ - job opt hash preservation, as suggested in gh-212, by https://github.com/d-m-u
8
+ - introduce Job#previous_time
9
+ - countered ActiveRecord 3.2.22 on gh-210, by https://github.com/paulodelgado
10
+
11
+
5
12
  == rufus-scheduler - 3.2.1 released 2016-05-04
6
13
 
7
14
  - accept '* * * * 5L' (last friday) (equivalent to '* * * * 5#-1')
@@ -4,7 +4,9 @@
4
4
 
5
5
  == Contributors
6
6
 
7
- - Kyle Simukka (https://githuc.om/simook) raise on "*/0 * * * *"
7
+ - Paulo Delgado (https://github.com/paulodelgado) counter ActiveRecord, gh-210
8
+ - Anjali Sharma (https://github.com/anjali-sharma) enhance job#last_time example
9
+ - Kyle Simukka (https://github.com/simook) raise on "*/0 * * * *"
8
10
  - Ryan McGeary (https://github.com/rmm5t) svg badges for the readme
9
11
  - Balasankar C (https://github.com/balasankarc) fix CronJob spec vs December
10
12
  - Matthieu Rosinski (https://github.com/Korrigan) prevent "every" shifts
@@ -48,6 +50,7 @@
48
50
 
49
51
  == Feedback
50
52
 
53
+ - d-m-u duhlmann - https://github.com/d-m-u - job opt hash preservation
51
54
  - Anjali Sharma - https://github.com/anjali-sharma - fix typographical error
52
55
  - Jonathan Campos - https://github.com/jonbcampos - negative cron day idea
53
56
  - Andrey Morskov - https://github.com/accessd - fix typographical error
data/README.md CHANGED
@@ -123,7 +123,7 @@ Yes, issues can be reported in [rufus-scheduler issues](https://github.com/jmett
123
123
  * [Passenger and rufus-scheduler (2)](http://stackoverflow.com/questions/21861387/rufus-cron-job-not-working-in-apache-passenger#answer-21868555)
124
124
  * [Passenger in-depth spawn methods](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/)
125
125
  * [Passenger in-depth spawn methods (smart spawning)](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#smart-spawning-hooks)
126
- * [The scheduler comes up when running the Rails console](https://github.com/jmettraux/rufus-scheduler#avoid-scheduling-when-running-the-ruby-on-rails-console)
126
+ * [The scheduler comes up when running the Rails console or a Rake task](https://github.com/jmettraux/rufus-scheduler#avoid-scheduling-when-running-the-ruby-on-rails-console)
127
127
  * [I don't get any of this, I just want it to work in my Rails application](#so-rails)
128
128
 
129
129
 
@@ -181,7 +181,7 @@ Interval jobs, trigger, execute and then trigger again after the interval elapse
181
181
 
182
182
  Cron jobs are based on the venerable cron utility (```man 5 crontab```). They trigger following a pattern given in (almost) the same language cron uses.
183
183
 
184
- ####
184
+ ####
185
185
 
186
186
  ### #schedule_x vs #x
187
187
 
@@ -641,12 +641,31 @@ job.scheduled_at
641
641
  ### last_time
642
642
 
643
643
  Returns the last time the job triggered (is usually nil for AtJob and InJob).
644
- k
645
644
  ```ruby
646
- job = scheduler.schedule_every('1d') do; end
647
- # ...
645
+ job = scheduler.schedule_every('10s') do; end
646
+
648
647
  job.scheduled_at
649
648
  # => 2013-07-17 23:48:54 +0900
649
+ job.last_time
650
+ # => nil (since we've just scheduled it)
651
+
652
+ # after 10 seconds
653
+
654
+ job.scheduled_at
655
+ # => 2013-07-17 23:48:54 +0900 (same as above)
656
+ job.last_time
657
+ # => 2013-07-17 23:49:04 +0900
658
+ ```
659
+
660
+ ### previous_time
661
+
662
+ Returns the previous `#next_time`
663
+ ```ruby
664
+ scheduler.every('10s') do |job|
665
+ puts "job scheduled for #{job.previous_time} triggered at #{Time.now}"
666
+ puts "next time will be around #{job.next_time}"
667
+ puts "."
668
+ end
650
669
  ```
651
670
 
652
671
  ### last_work_time, mean_work_time
@@ -1449,7 +1468,7 @@ The rufus-scheduler singleton is instantiated in the ```config/initializers/sche
1449
1468
 
1450
1469
  (Written in reply to https://github.com/jmettraux/rufus-scheduler/issues/186 )
1451
1470
 
1452
- If you don't want rufus-scheduler to kick in when running the Ruby on Rails console, you can wrap your initializer in a conditional:
1471
+ If you don't want rufus-scheduler to kick in when running the Ruby on Rails console or invoking a rake task, you can wrap your initializer in a conditional:
1453
1472
 
1454
1473
  ```ruby
1455
1474
  #
@@ -1460,8 +1479,10 @@ require 'rufus-scheduler'
1460
1479
  s = Rufus::Scheduler.singleton
1461
1480
 
1462
1481
 
1463
- unless defined?(Rails::Console)
1482
+ unless defined?(Rails::Console) || File.split($0).last == 'rake'
1483
+
1464
1484
  # only schedule when not running from the Ruby on Rails console
1485
+ # or from a rake task
1465
1486
 
1466
1487
  s.every '1m' do
1467
1488
 
@@ -39,7 +39,7 @@ module Rufus
39
39
  require 'rufus/scheduler/job_array'
40
40
  require 'rufus/scheduler/locks'
41
41
 
42
- VERSION = '3.2.1'
42
+ VERSION = '3.2.2'
43
43
 
44
44
  #
45
45
  # A common error class for rufus-scheduler
@@ -252,6 +252,9 @@ module Rufus
252
252
 
253
253
  def schedule(arg, callable=nil, opts={}, &block)
254
254
 
255
+ callable, opts = nil, callable if callable.is_a?(Hash)
256
+ opts = opts.dup
257
+
255
258
  opts[:_t] = Scheduler.parse(arg, opts)
256
259
 
257
260
  case opts[:_t]
@@ -263,6 +266,9 @@ module Rufus
263
266
 
264
267
  def repeat(arg, callable=nil, opts={}, &block)
265
268
 
269
+ callable, opts = nil, callable if callable.is_a?(Hash)
270
+ opts = opts.dup
271
+
266
272
  opts[:_t] = Scheduler.parse(arg, opts)
267
273
 
268
274
  case opts[:_t]
@@ -609,9 +615,11 @@ module Rufus
609
615
 
610
616
  fail NotRunningError.new(
611
617
  'cannot schedule, scheduler is down or shutting down'
612
- ) if @started_at == nil
618
+ ) if @started_at.nil?
613
619
 
614
620
  callable, opts = nil, callable if callable.is_a?(Hash)
621
+ opts = opts.dup unless opts.has_key?(:_t)
622
+
615
623
  return_job_instance ||= opts[:job]
616
624
 
617
625
  job_class =
@@ -53,6 +53,10 @@ module Rufus
53
53
  #
54
54
  attr_accessor :next_time
55
55
 
56
+ # previous "next trigger time"
57
+ #
58
+ attr_accessor :previous_time
59
+
56
60
  # anything with a #call(job[, timet]) method,
57
61
  # what gets actually triggered
58
62
  #
@@ -117,6 +121,7 @@ module Rufus
117
121
 
118
122
  def trigger(time)
119
123
 
124
+ @previous_time = @next_time
120
125
  set_next_time(time)
121
126
 
122
127
  return if (
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.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec