herpes 0.0.2.6 → 0.0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/herpes/rss.rb CHANGED
@@ -50,7 +50,7 @@ Herpes::Module.define :rss do
50
50
 
51
51
  content = begin
52
52
  open(r.url).read
53
- rescue SocketError; end or next
53
+ rescue Exception; end or next
54
54
 
55
55
  RSS::Parser.parse(content, false).tap {|p|
56
56
  p.items.reverse_each {|item|
@@ -10,6 +10,6 @@
10
10
 
11
11
  class Herpes
12
12
  def self.version
13
- '0.0.2.6'
13
+ '0.0.2.7'
14
14
  end
15
15
  end
data/lib/herpes.rb CHANGED
@@ -237,6 +237,8 @@ class Herpes
237
237
  end
238
238
 
239
239
  def until_next
240
+ return 0 unless running?
241
+
240
242
  callbacks = @callbacks.reject(&:calling?).reject(&:gonna_call?)
241
243
 
242
244
  return if callbacks.empty?
@@ -255,6 +257,8 @@ class Herpes
255
257
  while running?
256
258
  sleep until_next
257
259
 
260
+ break unless running?
261
+
258
262
  @callbacks.select {|callback|
259
263
  callback.next_in <= 0 && !(callback.gonna_call? || callback.calling?)
260
264
  }.each {|callback|
@@ -263,18 +267,20 @@ class Herpes
263
267
  callback.gonna_call!
264
268
 
265
269
  process {
266
- callback.call(self)
270
+ begin
271
+ callback.call(self)
272
+ rescue Exception => e
273
+ (log_at ? File.open(log_at, ?a) : STDOUT).tap {|f|
274
+ f.write "[#{Time.now}] "
275
+ f.write "From: #{caller[0, 1].join "\n"}\n"
276
+ f.write "#{e.class}: #{e.message}\n"
277
+ f.write e.backtrace.to_a.join "\n"
278
+ f.write "\n\n"
279
+ }
280
+ end
267
281
  }
268
282
  }
269
283
  end
270
- rescue Exception => e
271
- File.open(log_at, ?a) {|f|
272
- f.write "[#{Time.now}] "
273
- f.write "From: #{caller[0, 1].join "\n"}\n"
274
- f.write "#{e.class}: #{e.message}\n"
275
- f.write e.backtrace.to_a.join "\n"
276
- f.write "\n\n"
277
- } if log_at
278
284
  ensure
279
285
  save
280
286
 
@@ -282,6 +288,8 @@ class Herpes
282
288
  end
283
289
 
284
290
  def stop!
291
+ return unless running?
292
+
285
293
  @running = false
286
294
 
287
295
  wake_up
@@ -291,7 +299,5 @@ class Herpes
291
299
 
292
300
  def stop
293
301
  stop!
294
-
295
- sleep 0.01 until stopped?
296
302
  end
297
303
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: herpes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.6
4
+ version: 0.0.2.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-10 00:00:00.000000000 Z
12
+ date: 2012-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: threadpool
16
- requirement: &19567300 !ruby/object:Gem::Requirement
16
+ requirement: &16037080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *19567300
24
+ version_requirements: *16037080
25
25
  description:
26
26
  email: meh@paranoici.org
27
27
  executables:
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  requirements: []
66
66
  rubyforge_project:
67
- rubygems_version: 1.8.10
67
+ rubygems_version: 1.8.15
68
68
  signing_key:
69
69
  specification_version: 3
70
70
  summary: A event/notification handler.