forked from id774/automaticruby
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfeed.rb
More file actions
33 lines (31 loc) · 931 Bytes
/
feed.rb
File metadata and controls
33 lines (31 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
# Name:: Automatic::Plugin::SubscriptionFeed
# Author:: 774 <http://id774.net>
# Created:: Feb 22, 2012
# Updated:: Feb 21, 2014
# Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers.
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
module Automatic::Plugin
class SubscriptionFeed
def initialize(config, pipeline=[])
@config = config
@pipeline = pipeline
end
def run
@config['feeds'].each {|feed|
retries = 0
retry_max = @config['retry'].to_i || 0
begin
rss = Automatic::FeedParser.get_url(feed)
@pipeline << rss
rescue
retries += 1
Automatic::Log.puts("error", "ErrorCount: #{retries}, Fault in parsing: #{feed}")
sleep ||= @config['interval'].to_i
retry if retries <= retry_max
end
}
@pipeline
end
end
end