unicron 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/README.rdoc +69 -0
  3. metadata +21 -18
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7ba43e87dc6d00eec7c0c543b402b5d3f9f02d8b
4
+ data.tar.gz: cff45adb3cf6e095cbf160ad7dc6b821f40b857f
5
+ SHA512:
6
+ metadata.gz: d7abe6f4fd7b54f5efd37259d835ce7e2fd3d3e88a8231083297c1f41bc7359a0933776df01204816b1a1535f3dd3843f759b59dcd4245fd54b64207d2d760a3
7
+ data.tar.gz: e62feaba9e0445b490fa6ac6c908d0a8091e6da4706c5564a2f589b37bfaf01421fa51bc9ffe4ad70de3cf3f340ee831ff6e32aa774d7d6bcadbd778000da86f
@@ -0,0 +1,69 @@
1
+ = Unicron
2
+
3
+ Unicron provides a simple mechanism for scheduling one-off and repeating tasks
4
+ to execute at specific times in the background of a long-running Ruby process.
5
+ The easiest way to set up a Unicron job is to call Unicron::schedule.
6
+
7
+ The +delay+ parameter schedules a job to run a certain number of seconds in the
8
+ future:
9
+
10
+ Unicron.schedule delay: 180 do
11
+ puts "Ramen's done."
12
+ end
13
+
14
+ The +at+ parameter schedules a job to run at a certain time. If the time has
15
+ passed, the job runs immediately:
16
+
17
+ Unicron.schedule at: Time.parse('23:00') do
18
+ puts 'Go to bed!'
19
+ end
20
+
21
+ The +delay+ parameter can be combined with +repeat+ to schedule a repeating job:
22
+
23
+ Unicron.schedule delay: 1, repeat: true do
24
+ puts Time.now.sec.odd? ? 'tick' : 'tock'
25
+ end
26
+
27
+ If both +at+ and +delay+ are used with +repeat+, the job will first run at the
28
+ time specified by +at+ and then repeat every +repeat+ seconds afterwards. If
29
+ +repeat+ is Numeric, it specifies the number of times to repeat the Job.
30
+
31
+ Unicron.schedule at: Time.parse('7:00'), delay: 600, repeat: 3
32
+ puts 'WAKE UP!'
33
+ end
34
+
35
+ When both +at+ and +delay+ are specified, and +at+ is in the past, Unicron will
36
+ run the job at the first future even multiple of +delay+ seconds after +at+.
37
+ Although this sounds complicated, it's an easy way to make sure a job runs at
38
+ the same time every day, or only at the top of the hour.
39
+
40
+ Unicron.schedule at: Time.parse('12:00'), delay: 86400 do
41
+ puts 'Time for lunch!'
42
+ end
43
+
44
+ The optional +job+ block parameter can be used to modify the job settings from
45
+ within the task.
46
+
47
+ Unicron.schedule delay: rand(30), repeat: true do |job|
48
+ puts 'Peekaboo!'
49
+ delay = rand 30
50
+ if delay == 0
51
+ job.cancel
52
+ else
53
+ job.delay = delay
54
+ end
55
+ end
56
+
57
+ == Unicron is not +cron+
58
+
59
+ Although Unicron serves many of the same purposes as +cron+, there are important
60
+ distinctions between the two. Unicron runs in a background thread of a
61
+ (presumably) long-running Ruby process like your web application. This makes it
62
+ ideal for tasks that are lightweight, dependent on the main process, or which do
63
+ not need to run unless the main process is also running. Unicron also requires
64
+ no system administration, making it an attractive choice if you're authoring a
65
+ turnkey gem that needs to run periodic tasks in the background.
66
+
67
+ On the other hand, +cron+ is independent of any other processes and is always
68
+ running in the background. This makes +cron+ better suited for spawning
69
+ heavyweight tasks which have limited interaction with the main process.
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - David P Kleinschmidt
@@ -10,52 +9,56 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2011-10-18 00:00:00.000000000Z
12
+ date: 2014-03-16 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
- requirement: &83620100 !ruby/object:Gem::Requirement
18
- none: false
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  requirements:
20
- - - ~>
18
+ - - "~>"
21
19
  - !ruby/object:Gem::Version
22
- version: 2.7.0
20
+ version: '2.7'
23
21
  type: :development
24
22
  prerelease: false
25
- version_requirements: *83620100
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2.7'
26
28
  description: Schedules one-off and repeating background tasks within long-running
27
29
  ruby processes.
28
30
  email: david@kleinschmidt.name
29
31
  executables: []
30
32
  extensions: []
31
- extra_rdoc_files: []
33
+ extra_rdoc_files:
34
+ - README.rdoc
32
35
  files:
36
+ - README.rdoc
33
37
  - lib/unicron.rb
34
- - lib/unicron/schedule.rb
35
- - lib/unicron/job_queue.rb
36
38
  - lib/unicron/job.rb
37
- homepage: http://github.com/zobar/unicron
39
+ - lib/unicron/job_queue.rb
40
+ - lib/unicron/schedule.rb
41
+ homepage: http://bitbucket.org/zobar/unicron
38
42
  licenses: []
43
+ metadata: {}
39
44
  post_install_message:
40
45
  rdoc_options: []
41
46
  require_paths:
42
47
  - lib
43
48
  required_ruby_version: !ruby/object:Gem::Requirement
44
- none: false
45
49
  requirements:
46
- - - ! '>='
50
+ - - ">="
47
51
  - !ruby/object:Gem::Version
48
52
  version: '0'
49
53
  required_rubygems_version: !ruby/object:Gem::Requirement
50
- none: false
51
54
  requirements:
52
- - - ! '>='
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
57
  version: '0'
55
58
  requirements: []
56
59
  rubyforge_project:
57
- rubygems_version: 1.8.10
60
+ rubygems_version: 2.2.0
58
61
  signing_key:
59
- specification_version: 3
62
+ specification_version: 4
60
63
  summary: Schedule background tasks.
61
64
  test_files: []