herpes 0.0.2.5 → 0.0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/bin/herpes CHANGED
@@ -10,8 +10,10 @@ fail 'no configuration file passed' if ARGV.empty?
10
10
 
11
11
  herpes = Herpes.load(*ARGV)
12
12
 
13
- END {
14
- herpes.stop
13
+ %w[TERM INT HUP].each {|sig|
14
+ trap sig do
15
+ herpes.stop
16
+ end
15
17
  }
16
18
 
17
19
  herpes.start
@@ -0,0 +1,20 @@
1
+ # and this is another reason for making herpes, awesomely easy inlineable checkers
2
+ every 1.hour do
3
+ state[:mirai_nikki_torrents] ||= []
4
+
5
+ open('http://www.aozorateam.net/tracker/index/index.php').read.scan(%r((http://.*?%20Mirai%20Nikki%20-%20(\d+)%20.*\.mkv\.torrent))) {|uri, num|
6
+ next if state[:mirai_nikki_torrents].member?(uri)
7
+
8
+ state[:mirai_nikki_torrents].push(uri)
9
+
10
+ with :email do
11
+ via :procmail
12
+
13
+ to 'herpes'
14
+ from 'Mirai Nikki <rss@herpes>'
15
+ subject "Episode #{num} available"
16
+
17
+ send "Torrent: #{uri}"
18
+ end
19
+ }
20
+ end
data/lib/herpes/rss.rb CHANGED
@@ -48,7 +48,11 @@ Herpes::Module.define :rss do
48
48
  @rss.each {|r|
49
49
  (state[:rss] ||= {})[r.url] ||= []
50
50
 
51
- RSS::Parser.parse(open(r.url).read, false).tap {|p|
51
+ content = begin
52
+ open(r.url).read
53
+ rescue SocketError; end or next
54
+
55
+ RSS::Parser.parse(content, false).tap {|p|
52
56
  p.items.reverse_each {|item|
53
57
  next if state[:rss][r.url].member?(if p.is_a?(RSS::Atom::Feed)
54
58
  item.link.href
@@ -10,6 +10,6 @@
10
10
 
11
11
  class Herpes
12
12
  def self.version
13
- '0.0.2.5'
13
+ '0.0.2.6'
14
14
  end
15
15
  end
data/lib/herpes.rb CHANGED
@@ -99,6 +99,10 @@ class Herpes
99
99
  @pool.resize(number)
100
100
  end
101
101
 
102
+ def log_at (path = nil)
103
+ path ? @log_at = File.expand_path(path) : @log_at
104
+ end
105
+
102
106
  def state (path = nil)
103
107
  if path && path != @path
104
108
  @path = File.expand_path(path)
@@ -263,6 +267,14 @@ class Herpes
263
267
  }
264
268
  }
265
269
  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
266
278
  ensure
267
279
  save
268
280
 
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.5
4
+ version: 0.0.2.6
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: 2011-12-18 00:00:00.000000000 Z
12
+ date: 2012-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: threadpool
16
- requirement: &6630460 !ruby/object:Gem::Requirement
16
+ requirement: &19567300 !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: *6630460
24
+ version_requirements: *19567300
25
25
  description:
26
26
  email: meh@paranoici.org
27
27
  executables:
@@ -32,6 +32,7 @@ files:
32
32
  - README.md
33
33
  - bin/herpes
34
34
  - examples/generator.rb
35
+ - examples/mirai_nikki.rb
35
36
  - examples/rss.rb
36
37
  - herpes.gemspec
37
38
  - lib/herpes.rb