Class: Threatinator::FeedRegistry
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Registry
#clear, #count, #initialize, #keys
Class Method Details
.build(config) ⇒ Object
Builds a new FeedRegistry based on the provided config
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/threatinator/feed_registry.rb', line 36
def self.build(config)
ret = self.new
config.search_path.each do |path|
pattern = File.join(path, "**", "*.feed")
Dir.glob(pattern).each do |filename|
ret.register_from_file(filename)
end
end
ret
end
|
Instance Method Details
#each ⇒ Object
20
21
22
23
24
25
|
# File 'lib/threatinator/feed_registry.rb', line 20
def each
return enum_for(:each) unless block_given?
super do |key, feed|
yield(feed)
end
end
|
16
17
18
|
# File 'lib/threatinator/feed_registry.rb', line 16
def get(provider, name)
super([provider, name])
end
|
#register(feed) ⇒ Object
9
10
11
|
# File 'lib/threatinator/feed_registry.rb', line 9
def register(feed)
super([feed.provider, feed.name], feed)
end
|
#register_from_file(filename) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/threatinator/feed_registry.rb', line 27
def register_from_file(filename)
builder = Threatinator::FeedBuilder.from_file(filename)
feed = builder.build
register(feed)
feed
end
|