forked from id774/automaticruby
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaccept.rb
More file actions
62 lines (58 loc) · 1.69 KB
/
accept.rb
File metadata and controls
62 lines (58 loc) · 1.69 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
# Name:: Automatic::Plugin::Filter::Accept
# Author:: soramugi <http://soramugi.net>
# 774 <http://id774.net>
# Created:: Jun 4, 2013
# 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 FilterAccept
def initialize(config, pipeline=[])
@config = config
@pipeline = pipeline
end
def run
@return_feeds = []
@pipeline.each {|feeds|
new_feeds = []
unless feeds.nil?
feeds.items.each {|items|
new_feeds << items if contain(items) == true
}
end
@return_feeds << Automatic::FeedMaker.create_pipeline(new_feeds) if new_feeds.length > 0
}
@return_feeds
end
private
def contain(items)
detection = false
unless @config['title'].nil?
@config['title'].each {|e|
if items.title.include?(e.chomp)
detection = true
Automatic::Log.puts("info", "Contain by title: #{items.link}")
end
}
end
unless @config['link'].nil?
@config['link'].each {|e|
if items.link.include?(e.chomp)
detection = true
Automatic::Log.puts("info", "Contain by link: #{items.link}")
end
}
end
unless @config['description'].nil?
@config['description'].each {|e|
if items.description.include?(e.chomp)
detection = true
Automatic::Log.puts("info", "Contain by description: #{items.link}")
end
}
end
detection
end
end
end