everyx 1.0.0 → 1.0.1

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. data/History.txt +4 -0
  2. data/lib/everyx.rb +16 -5
  3. metadata +2 -2
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.0.1 / 2007-11-10
2
+
3
+ * Change 'task' call to 'call', rather than 'run', so procs and all work nicely.
4
+
1
5
  == 1.0.0 / 2007-11-09
2
6
 
3
7
  * First release. Very simple periodict task runner. They run every x seconds.
data/lib/everyx.rb CHANGED
@@ -1,19 +1,30 @@
1
1
  module Everyx
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  class Everyx
4
4
  def initialize
5
5
  @threads = []
6
6
  end
7
-
8
- def add( runner, delay = 60 )
7
+
8
+ # Call the runner every `delay` seconds
9
+ def every( delay, runner )
9
10
  @threads << Thread.new(runner, delay) do |r,delay|
10
11
  loop do
11
- r.run
12
+ r.call
12
13
  sleep delay
13
14
  end
14
15
  end
15
16
  end
16
17
 
18
+ # Call the runner once, `delay` seconds from now.
19
+ def in( delay, runner )
20
+ @threads << Thread.new( runner, delay ) do |r, delay|
21
+ sleep delay
22
+ r.call
23
+ end
24
+ end
25
+
26
+ # Join all the threads. Call this when you're all done with the
27
+ # Everyx instance.
17
28
  def join
18
29
  @threads.each {|t| t.join }
19
30
  end
@@ -36,7 +47,7 @@ module Everyx
36
47
  @last = nil
37
48
  end
38
49
 
39
- def run
50
+ def call
40
51
  rss = RSS::Parser.parse( open(@uri) {|s| s.read }, false )
41
52
  new = []
42
53
  first_new = nil
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4.5
3
3
  specification_version: 2
4
4
  name: everyx
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2007-11-09 00:00:00 -05:00
6
+ version: 1.0.1
7
+ date: 2007-11-10 00:00:00 -05:00
8
8
  summary: Code to run some classes every x seconds
9
9
  require_paths:
10
10
  - lib