-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Cetrulo
committed
May 16, 2012
1 parent
d58e28a
commit 4830db6
Showing
2 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'feedzirra' | ||
|
||
class Planet | ||
class Parsers | ||
@@parsers = [] | ||
|
||
def self.get_parser(type) | ||
@@parsers.each do |parser| | ||
return parser if parser.type == type | ||
end | ||
|
||
raise ArgumentError, "no parser for type '#{ type }'", caller | ||
end | ||
|
||
def self.get_parser_for(feed) | ||
feed_domain = URI(feed).host | ||
|
||
@@parsers.each do |parser| | ||
return parser if parser.domains.any? { |domain| feed_domain.end_with? domain } | ||
end | ||
|
||
return Feedzirra::Feed | ||
end | ||
end | ||
end |