Module: Feedisco::Checks
- Included in:
- Feedisco
- Defined in:
- lib/feedisco/checks.rb
Instance Method Summary collapse
-
#feed?(url) ⇒ Boolean
Check if the specified URL is a feed URL.
-
#looks_like_feed?(url) ⇒ Boolean
Determines if the specified URL looks like a feed.
Instance Method Details
#feed?(url) ⇒ Boolean
Check if the specified URL is a feed URL. The check is performed by opening the URL and checking the content type. If it matches a content type within Feedisco.feed_content_types, the URL is considered as a feed and the method returns true.
7 8 9 |
# File 'lib/feedisco/checks.rb', line 7 def feed?(url) feed_content_type?(url) end |
#looks_like_feed?(url) ⇒ Boolean
Determines if the specified URL looks like a feed. We consider it does if:
- it ends with a 'feed-suffix': .rdf, .xml, .rss
- it contains a 'feed=rss' or 'feed=atom' query param (well, we don't check
if it is really a query param, as long as it is in the URL)
- it ends with 'atom' or 'feed' (with or without the '/' at the end)
16 17 18 |
# File 'lib/feedisco/checks.rb', line 16 def looks_like_feed?(url) (url =~ %r{(\.(rdf|xml|rss)$|feed=(rss|atom)(&(.)+)?$|(atom|feed)/?$)}i) != nil end |