rufus-scheduler 3.1.4 → 3.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +410 -0
  3. data/CREDITS.md +142 -0
  4. data/LICENSE.txt +1 -1
  5. data/Makefile +27 -0
  6. data/README.md +407 -143
  7. data/lib/rufus/scheduler/job_array.rb +36 -66
  8. data/lib/rufus/scheduler/jobs_core.rb +369 -0
  9. data/lib/rufus/scheduler/jobs_one_time.rb +53 -0
  10. data/lib/rufus/scheduler/jobs_repeat.rb +335 -0
  11. data/lib/rufus/scheduler/locks.rb +41 -67
  12. data/lib/rufus/scheduler/util.rb +89 -179
  13. data/lib/rufus/scheduler.rb +545 -453
  14. data/rufus-scheduler.gemspec +22 -11
  15. metadata +44 -85
  16. data/CHANGELOG.txt +0 -243
  17. data/CREDITS.txt +0 -88
  18. data/Rakefile +0 -83
  19. data/TODO.txt +0 -151
  20. data/lib/rufus/scheduler/cronline.rb +0 -470
  21. data/lib/rufus/scheduler/jobs.rb +0 -633
  22. data/lib/rufus/scheduler/zones.rb +0 -174
  23. data/lib/rufus/scheduler/zotime.rb +0 -155
  24. data/spec/basics_spec.rb +0 -54
  25. data/spec/cronline_spec.rb +0 -915
  26. data/spec/error_spec.rb +0 -139
  27. data/spec/job_array_spec.rb +0 -39
  28. data/spec/job_at_spec.rb +0 -58
  29. data/spec/job_cron_spec.rb +0 -128
  30. data/spec/job_every_spec.rb +0 -104
  31. data/spec/job_in_spec.rb +0 -20
  32. data/spec/job_interval_spec.rb +0 -68
  33. data/spec/job_repeat_spec.rb +0 -357
  34. data/spec/job_spec.rb +0 -631
  35. data/spec/lock_custom_spec.rb +0 -47
  36. data/spec/lock_flock_spec.rb +0 -47
  37. data/spec/lock_lockfile_spec.rb +0 -61
  38. data/spec/lock_spec.rb +0 -59
  39. data/spec/parse_spec.rb +0 -263
  40. data/spec/schedule_at_spec.rb +0 -158
  41. data/spec/schedule_cron_spec.rb +0 -66
  42. data/spec/schedule_every_spec.rb +0 -109
  43. data/spec/schedule_in_spec.rb +0 -80
  44. data/spec/schedule_interval_spec.rb +0 -128
  45. data/spec/scheduler_spec.rb +0 -1067
  46. data/spec/spec_helper.rb +0 -126
  47. data/spec/threads_spec.rb +0 -96
  48. data/spec/zotime_spec.rb +0 -396
@@ -1,80 +0,0 @@
1
-
2
- #
3
- # Specifying rufus-scheduler
4
- #
5
- # Wed Apr 17 06:00:59 JST 2013
6
- #
7
-
8
- require 'spec_helper'
9
-
10
-
11
- describe Rufus::Scheduler do
12
-
13
- before :each do
14
- @scheduler = Rufus::Scheduler.new
15
- end
16
- after :each do
17
- @scheduler.shutdown
18
- end
19
-
20
- describe '#in' do
21
-
22
- it 'adds a job' do
23
-
24
- @scheduler.in(3600) do
25
- end
26
-
27
- expect(@scheduler.jobs.size).to eq(1)
28
- expect(@scheduler.jobs.first.class).to eq(Rufus::Scheduler::InJob)
29
- end
30
-
31
- it 'triggers a job' do
32
-
33
- a = false
34
-
35
- @scheduler.in(0.4) do
36
- a = true
37
- end
38
-
39
- sleep 0.9
40
-
41
- expect(a).to eq(true)
42
- end
43
-
44
- it 'removes the job after execution' do
45
-
46
- @scheduler.in(0.4) do
47
- end
48
-
49
- sleep 0.700
50
-
51
- expect(@scheduler.jobs.size).to eq(0)
52
- end
53
- end
54
-
55
- describe '#schedule_in' do
56
-
57
- it 'accepts a number' do
58
-
59
- job = @scheduler.schedule_in(3600) {}
60
-
61
- expect(job.original).to eq(3600)
62
- end
63
-
64
- it 'accepts a duration string' do
65
-
66
- job = @scheduler.schedule_in('1h') {}
67
-
68
- expect(job.original).to eq('1h')
69
- expect(job.time).to be >= job.scheduled_at + 3509
70
- expect(job.time).to be <= job.scheduled_at + 3601
71
- end
72
-
73
- it 'accepts an ActiveSupport .from_now thinggy'
74
- #
75
- # schedule_in(2.days.from_now)
76
- #
77
- # that'd simply require "in" to be a bit like "at"...
78
- end
79
- end
80
-
@@ -1,128 +0,0 @@
1
-
2
- #
3
- # Specifying rufus-scheduler
4
- #
5
- # Wed Aug 7 06:20:55 JST 2013
6
- #
7
-
8
- require 'spec_helper'
9
-
10
-
11
- describe Rufus::Scheduler do
12
-
13
- before :each do
14
- @scheduler = Rufus::Scheduler.new
15
- end
16
- after :each do
17
- @scheduler.shutdown
18
- end
19
-
20
- describe '#interval' do
21
-
22
- it 'adds a job' do
23
-
24
- @scheduler.interval(10) do
25
- end
26
-
27
- expect(@scheduler.jobs.size).to eq(1)
28
- expect(@scheduler.jobs.first.class).to eq(Rufus::Scheduler::IntervalJob)
29
- end
30
-
31
- it 'triggers a job (2 times)' do
32
-
33
- counter = 0
34
-
35
- @scheduler.interval(0.4) do
36
- counter += 1
37
- end
38
-
39
- sleep 2.0
40
-
41
- expect(counter).to be > 2
42
- end
43
-
44
- it 'triggers, but reschedules after the trigger execution' do
45
-
46
- chronos = []
47
-
48
- @scheduler.interval(0.4) do
49
- now = Time.now
50
- last, delta = chronos.last
51
- chronos << [ now, last ? now - last : nil ]
52
- sleep 0.5
53
- end
54
-
55
- t = Time.now
56
- sleep 0.1 while chronos.size < 4 && Time.now < t + 5
57
-
58
- expect(chronos.size).to eq(4)
59
-
60
- deltas = chronos.collect(&:last).compact
61
-
62
- #pp chronos
63
- #pp deltas
64
-
65
- deltas.each do |d|
66
- expect(d).to be >= 0.9
67
- end
68
- end
69
-
70
- it 'does not reschedule if the job was unscheduled' do
71
-
72
- counter = 0
73
-
74
- job =
75
- @scheduler.schedule_interval '0.5s' do
76
- counter = counter + 1
77
- end
78
-
79
- sleep 1.6
80
-
81
- expect(@scheduler.jobs(:all).size).to eq(1)
82
-
83
- job.unschedule
84
- c = counter
85
-
86
- sleep 1.6
87
-
88
- expect(counter).to eq(c)
89
- expect(@scheduler.jobs(:all).size).to eq(0)
90
- end
91
-
92
- it 'raises on negative intervals' do
93
-
94
- expect {
95
- @scheduler.interval(-1) do
96
- end
97
- }.to raise_error(ArgumentError)
98
- end
99
-
100
- it 'raises on zero intervals' do
101
-
102
- expect {
103
- @scheduler.interval(0) do
104
- end
105
- }.to raise_error(ArgumentError)
106
- end
107
-
108
- #it 'raises if the job frequency is higher than the scheduler frequency' do
109
- #
110
- # @scheduler.frequency = 10
111
- #
112
- # lambda {
113
- # @scheduler.interval '1s' do; end
114
- # }.should raise_error(ArgumentError)
115
- #end
116
- end
117
-
118
- describe '#schedule_interval' do
119
-
120
- it 'accepts a duration string' do
121
-
122
- job = @scheduler.schedule_interval('1h') do; end
123
-
124
- expect(job.interval).to eq(3600)
125
- end
126
- end
127
- end
128
-